import argparse import requests import textwrap import threading import queue import colorama colorama.init() class myThread(threading.Thread): def __init__(self, res, url, thr): threading.Thread.__init__(self) self.res = res self.url = url self.thr = thr def run(self): while not q.empty(): dists = q.get() tart = self.url + dists.strip() try: qwer = requests.get(tart, verify=False) if qwer.status_code == int(self.res): print(colorama.Fore.RED + '%s----------------%s' % (tart, qwer.status_code) + colorama.Style.RESET_ALL) except Exception as e: break def dict(dic, thr): for dist in open(dic, 'r', encoding='utf-8'): dist = dist.replace('\n', '') q.put(dist) for i in range(thr): t = myThread(res=args.res, url=args.url, thr=args.thr) t.start() if __name__ == '__main__': q = queue.Queue() parser = argparse.ArgumentParser(description="Directory Scan Tool", formatter_class=argparse.RawDescriptionHelpFormatter, epilog=textwrap.dedent( """Example: test.py -w D:\Desktop\DIRD1.txt -t http://www.baidu.com/ -r 404 -th 11 """)) parser.add_argument('-w', '--dictionary', dest='dic', help='Dictionary file location') # parser.add_argument('-e', '--Exclude ', dest='exc', help='Exclude status codes') parser.add_argument('-r', '--reserve', dest='res', help='Reserved status code') parser.add_argument('-u', '--target', dest='url', help='specified ip') parser.add_argument('-t', '--threading', dest='thr', help='specified ip') args = parser.parse_args() dict(args.dic, int(args.thr))
多线程目录扫描脚本
于 2023-06-07 15:47:15 首次发布
该脚本是一个使用Python实现的多线程目录扫描工具,它结合argparse模块处理命令行参数,利用requests库发送HTTP请求,通过线程池进行并发扫描。工具从指定字典文件读取目录路径,对目标URL发起请求,检查并打印出特定状态码的响应。
摘要由CSDN通过智能技术生成