使用方法
首先找个网站,我们可以看到URL中有php后缀名,说明该网站为php网站
输入参数:URL,文件类型,线程数,即可扫出目录文件
验证一下,访问成功
代码
环境
pycharm,python3.9
文件结构
dics文件夹下为各个后缀名的字典,网上可以下载,第二个参数即为选择要使用的字典
user_agent_list.py是随机生成user-agent的文件,用来绕过cc流量拦截,常见的user-agent也可在网上找
user_agent_list.py
# coding:utf-8import randomdef get_user_agent():user_agent_list=[{'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17763'},{'User-Agent':'Mozilla / 5.0(WindowsNT6.1;WOW64) AppleWebKit / 535.1(KHTML, likeGecko) Chrome / 14.0.835.163Safari / 535.1'},{'User-Agent':'Mozilla / 5.0(WindowsNT10.0;Win64;x64) AppleWebKit / 537.36(KHTML, likeGecko) Chrome / 73.0.3683.103Safari / 537.36'},{'User-Agent':'Mozilla / 5.0(Macintosh;IntelMacOSX10_7_0) AppleWebKit / 535.11(KHTML, likeGecko) Chrome / 17.0.963.56Safari / 535.11'},{'User-Agent':'Mozilla / 5.0(WindowsNT6.1;WOW64;rv: 6.0) Gecko / 20100101Firefox / 6.0'},{'User-Agent':'Mozilla / 5.0(Macintosh;IntelMacOSX10.6;rv: 2.0.1) Gecko / 20100101'},{'User-Agent':'Mozilla / 5.0(Macintosh;U;IntelMacOSX10_6_8;en - us) AppleWebKit / 534.50(KHTML, likeGecko) Version / 5.1Safari / 534.50'},{'User-Agent':'Mozilla / 5.0(Windows;U;WindowsNT6.1;en - us) AppleWebKit / 534.50(KHTML, likeGecko) Version / 5.1Safari / 534.50'}]return random.choice(user_agent_list)
main.py
# coding:utf-8import requests
import queue
import sys
import threading
import user_agent_listclass DirScan(threading.Thread):def __init__(self, queue):threading.Thread.__init__(self)self._queue = queuedef run(self):while not self._queue.empty():url = self._queue.get()try:r = requests.get(url=url, headers=user_agent_list.get_user_agent(), timeout=8,) #请求url并随机生成user-agent绕过ccif r.status_code == 200: #状态码为200时,请求成功,说明存在请求的目录文件,输出urlprint('[*]'+url)except Exception as e:passdef start(url, ext, count):q = queue.Queue()f = open('./dics/%s.txt'%ext, 'r') #根据ext参数选择对应字典for i in f:q.put(url+i.rstrip('\n')) #拼接输入的url与字典中的测试路径组成要请求的目录文件threads = []thread_count = int(count)for i in range(thread_count):threads.append(DirScan(q))for t in threads:t.start()for t in threads:t.join()if __name__ == '__main__':if len(sys.argv) != 4:sys.exit(-1)else:start(sys.argv[1], sys.argv[2], sys.argv[3],)
后续将进行美化,敬请期待!