最近整理外网暴露面时发现需要一个批量测试的任务。
实现对fofa导出的数据进行批量存活测试
话不多说直接上代码
import warnings
import requests
for line in open("url.txt"):
try:
warnings.filterwarnings("ignore")
url = line.strip()
print(url)
response = requests.get(url,verify=False,timeout=3)
state = [200,503,304]
content1 = ('nginx')
content2 = ('apache')
content2 = ('openresty')
if response.status_code in zh:
print('is accessible\n')
elif ch in response.text:
print('含有nginx字段!\n')
elif dh in response.text:
print('含有apache字段!\n')
elif fh in response.text:
print('含有openresty字段!\n')
else:
print('已关闭\n')
except:
print ('超时或未找到服务器\n')
通过修改state可对相应状态码进行判断服务器运行状态
可自行添加content对网页回包进行字段匹配,可检测是否有敏感信息泄露
注释版项目地址: