直接执行py文件即可

1
python xxx.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

# author: 想学点black技术
# 用法: 在py的同目录下生成url.txt,根据自己的需求更改scan_command即可
# time: 2020年12月16日20:27:40
# 环境: python3
# 说明: command中的xray路径需要手动修改,报告生成的位置在同一目录下

import os
import hashlib
import re
import datetime
import random
from time import strftime

# 扫描
def get_url():
f = open("url.txt")
lines = f.readlines()
# 匹配http | https请求头
pattern = re.compile(r'^(https|http)://')
for line in lines:
try:
if not pattern.match(line.strip()):
targeturl="http://"+line.strip()
else:
targeturl=line.strip()
# print(targeturl.strip())
## outputfilename=hashlib.md5(targeturl.encode("utf-8"))
now=datetime.datetime.now() #当前日期
outputfilename = now.strftime("%Y-%m-%d_") + str(random.randint(1,1000000))
do_scan(targeturl.strip(), outputfilename)
except Exception as e:
print(e)
pass
f.close()
print("Xray Scan End~")
return

# 报告
def do_scan(targeturl,outputfilename="xray"):
scan_command="xray.exe webscan --basic-crawler {} --html-output {}.html".format(targeturl,outputfilename)
# scan_command = "ping 943ogg.dnslog.cn"
# print(scan_command)
os.system(scan_command)
return

if __name__ == '__main__':
get_url()