网上各种扫描工具dirsearch dirb 御剑 都连接不到指定网站的情况下,使用python自定义字典进行网站目录扫描。
import threadpool
url=input('目标网站url:')
url=url.strip('/')
adress=input('字典配置位置:')
adress=adress.replace('"','')
error_show=int(input('是否显示未到的网页 1 or 0:'))
reach_time=0.2#default请求相应时间
print('timeout:',reach_time)
def scan_one_dir(name):
'''
:param url: 目标url
:param name: 自定义文件名字
:return:
'''
import requests
try:
name=name.strip()#去除换行符
respones = requests.get(url + name,timeout=reach_time)
print(url + name + " statu:" + str(respones.status_code))
except Exception as e:
if error_show:
print('('+url + name + ' : ' + ' can not reach ! pass)')
with open(adress) as f:
name_list=f.readlines()
# 定义了一个线程池,最多创建10个线程
pool = threadpool.ThreadPool(10)
# 创建要开启多线程的函数,以及函数相关参数和回调函数,其中回调数可以不写,default是none
requests = threadpool.makeRequests(scan_one_dir, name_list)
# 将所有要运行多线程的请求扔进线程池
[pool.putRequest(req) for req in requests]
# 所有的线程完成工作后退出
pool.wait()
// An highlighted block