利用Python来实现网站目录扫描器

在这里插入图片描述
  有人问为什么要去扫描网站目录:懂的人自然懂
  这个Python脚本的特点:
  1.基本完善
  2.界面美观(只是画了个图案)
  3.可选参数增加了线程数
  4.User Agent细节处理
  5.多线程显示进度
  扫描目标:Metasploitable Linux
代码:WebDirScanner.py
#-- coding:utf-8 --
author = “Yiqing”
import sys
import threading
import random
from Queue import Queue
from optparse import OptionParsertry:
import requests
except Exception:
print “[!] You need to install requests module!”
print “[!] Usage:pip install requests”
exit()
class WebDirScan:
“”"
Web目录扫描器
“”" def init(self, options):
self.url = options.url
self.file_name = options.file_name
self.count = options.count class DirScan(threading.Thread):
“”"
多线程
“”" def init(self, queue, total):
threading.Thread.init(self)
self.queue = queue
self.total = total def run(self):
while not self.queue.empty():
url = self.queue.get()
# 多线程显示进度
threading.Thread(target=self.msg).start()
try:
r = requests.get(url=url, headers=get_user_agent(), timeout=5)
if r.status_code == 200:
sys.stdout.write(’\r’ + ‘[+]%s\t\t\n’ % url)
# 保存到本地文件,以HTML的格式
result = open(‘result.html’, ‘a+’)
result.write(’_
\ / __/ ` | ’ \
| |
| | | | ) | (| (| | | | |
|
/||| |/ ____,|| |_| Welcome to WebDirScan
Version:1.0 Author: %s
‘’’ % author
parser = OptionParser(‘python WebDirScanner.py -u -f [-t <Thread_count>]’)
parser.add_option(’-u’, ‘–url’, dest=‘url’, type=‘string’, help=‘target url for scan’)
parser.add_option(’-f’, ‘–file’, dest=‘file_name’, type=‘string’, help=‘dictionary filename’)
parser.add_option(’-t’, ‘–thread’, dest=‘count’, type=‘int’, default=10, help=‘scan thread count’)
(options, args) = parser.parse_args()
if options.url and options.file_name:
dirscan = WebDirScan(options)
dirscan.start()
sys.exit(1)
else:
parser.print_help()
sys.exit(1)
if name == ‘main’:
main()
  需要一个字典文件:
  我存进去了一些,一部分是确定存在的目录
  dict.txt
index.php
login
dvwa
phpMyAdmin
dav
twiki
login.php
结果:得到一个HTML文件:
http://192.168.232.129/twikihttp://192.168.232.129/index.phphttp://192.168.232.129/phpMyAdmin  
脚本的使用:
在这里插入图片描述
文章来自:https://www.itjmd.com/news/show-5382.html

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值