脚本一:利用curl批量测试是否可以访问web服务
适用:利用findsomething找到大量API接口,不想一个个访问就可以利用这个脚本了。
脚本代码:
import requests
# 读取文件 3.txt 中的 URL
with open('3.txt', 'r') as f:
urls = f.readlines()# 测试每个 URL 是否可以访问,并将可访问的 URL 写入文件 4.txt
with open('4.txt', 'w') as f:
for url in urls:
url = url.strip() # 去除 URL 前后的空白字符
try:
response = requests.get(url)
if response.status_code == 200:
f.write(f'{url}n') # 只写入可访问的 URL,不添加其他信息
except requests.exceptions.RequestException:
pass # 如果发生异常,直接跳过
用法:将findsomething找到的API放在文件3.txt。与脚本放在同一文件夹,运行,即可得出结果,结果装在文件4.txt。
脚本二:利用powershell开启一个监听端口
脚本如下:
$listener = New-Object System.Net.Sockets.TcpListener ([System.Net.IPAddress]::Any, 6666)
$listener.Start()
$connection = $listener.AcceptTcpClient()
$stream = $connection.GetStream()
$reader = New-Object System.IO.StreamReader($stream)
$data = $reader.ReadToEnd()
$data
$stream.Close()
$connection.Close()
$listener.Stop()
脚本三:利用python在域名前加上https://以便访问
# 打开输入文件,读取域名列表
with open('2.txt', 'r') as input_file:
domain_names = input_file.readlines()# 对每个域名添加 'https://' 前缀
modified_domain_names = ['https://' + domain.strip() for domain in domain_names]# 将修改后的域名写入输出文件
with open('3.txt', 'w') as output_file:
output_file.write('n'.join(modified_domain_names))
用法:将收集到的域名放在2.txt里面,运行脚本即可。
脚本四,收集到大量域名提取域名里面的IP
import socket
def get_ip(domain):
try:
ip = socket.gethostbyname(domain)
return ip
except socket.gaierror:
return Nonedef main():
with open('1.txt', 'r') as infile:
domains = infile.readlines()results = []
for domain in domains:
domain = domain.strip()
ip = get_ip(domain)
if ip:
result = f"{domain},{ip}"
results.append(result)
print(result)with open('2.txt', 'w') as outfile:
for result in results:
outfile.write(result + 'n')if __name__ == "__main__":
main()
用法:将收集到的域名放在1.txt,运行即可得到域名对应的IP。
以上脚本仅用于授权渗透测试,未授权使用本公众号知识渗透后果自负!!!
原文始发于微信公众号(黄公子学安全):4个实战脚本,总有适合你的吧
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论