python編寫web目錄掃描
阿新 • • 發佈:2020-09-21
#!/usr/bin/python3 import requests import sys import queue import threading class Dirscan(threading.Thread): def __init__(self,q): super(Dirscan, self).__init__() self.q=q def run(self): while not self.q.empty(): url=self.q.get() try: headers={'User-Agent':'xixi scan for web ver=1.0' } r=requests.get(url=url,headers=headers) if r.status_code==200: print(url) except : pass def start(url,ext,count): q=queue.Queue() threads=[] threads_count=int(count) f=open('C:/Users/18910/Desktop/%s.txt'% ext,'r') for i in f: q.put(url+i.rstrip('\n')) for i in range(threads_count): threads.append(Dirscan(q)) for t in threads: t.start() for t in threads: t.join() if __name__ == '__main__': url='http://www.qiduyy.com' ext='asp' count=10 start(url,ext,count)
。。。掃描結果如下:
D:\untitled2\venv\Scripts\python.exe D:/untitled2/venv/1.py
http://www.qiduyy.com/down.htm
http://www.qiduyy.com/star.asp
http://www.qiduyy.com/index.asp
http://www.qiduyy.com/index.html
http://www.qiduyy.com/get.htm
http://www.qiduyy.com/moban.asp
http://www.qiduyy.com/changepwd.asp
http://www.qiduyy.com/admin_index.asp
http://www.qiduyy.com/book.asp
http://www.qiduyy.com/productcn.asp
http://www.qiduyy.com/aspadmin.asp
http://www.qiduyy.com/admin.htm
http://www.qiduyy.com/2006.asp
http://www.qiduyy.com/admin.asp
Process finished with exit code 0