xray批量扫描脚本
2022-09-06 14:39 rnss 阅读(1266) 评论(0) 编辑 收藏 举报xray批量主动爬虫扫描脚本:
# -*- coding: utf-8 -*-
from queue import Queue
from threading import Thread
from optparse import OptionParser
import os
import re
def get_targets(input):
queue = Queue()
checker = [k.strip() for k in open(input, encoding='utf-8')]
for target in checker:
queue.put(target)
return queue
def scan(queue, path):
while True:
try:
target = queue.get()
html_output_g = re.search(r'(.*?//)?(.*)', target)
if html_output_g:
html_output = html_output_g.group(2)
if ":" in html_output:
html_output = html_output.replace(":", "_")
if "/" in html_output:
html_output = html_output.replace("/", "_")
command = path + " webscan --basic-crawler " + target + " --html-output " + html_output + ".html"
output = os.popen(command)
print(command)
try:
result = output.read()
if "[Vuln:" in result:
print(result)
except UnicodeDecodeError:
pass
finally:
queue.task_done()
if __name__ == "__main__":
parser = OptionParser(
usage='%prog -i input -p path -t threads\r\nexample: %prog -i 1.txt -p "D:\\Tools\\xray_windows_amd64.exe" -t 10')
parser.add_option('-i', '--input', dest='input', help='要扫描的目标,txt格式,每行一个,如:1.txt')
parser.add_option('-p', '--path', dest='path', help='xray的绝对路径,如:"D:\\Tools\\xray_windows_amd64.exe"')
parser.add_option('-t', '--threads', dest='threads', help='线程数,默认10', default=10, type=int)
options, args = parser.parse_args()
if options.path and options.input:
queue = get_targets(options.input)
for i in range(options.threads):
t = Thread(target=scan, args=(queue, options.path))
t.daemon = True
t.start()
queue.join()
python xray_batch.py -i 要扫描的txt -p xray的绝对路径 -t 线程数,默认为10
python xray_batch.py -i 1.txt -p "D:\Tools\xray.exe" -t 10
报告会在python脚本的目录生成