4个常用实战脚本

脚本一:利用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 None

def 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。

以上脚本仅用于授权渗透测试,未授权使用本公众号知识渗透后果自负!!!

  • 8
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值