有人问为什么要去扫描网站目录:懂的人自然懂
这个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
利用Python来实现网站目录扫描器
最新推荐文章于 2024-04-07 00:19:18 发布