简单的流程化信息收集
脚本
| import os |
| import fnmatch |
| import socket |
| import shutil |
| import csv |
| |
| def checkcdn(host): |
| ip_list=[] |
| try: |
| addrs = socket.getaddrinfo(host, None) |
| for item in addrs: |
| if item[4][0] not in ip_list: |
| ip_list.append(item[4][0]) |
| count_ip = len(ip_list) |
| if count_ip > 1: |
| return False |
| elif count_ip == 1: |
| return ip_list[0] |
| else: |
| return False |
| except Exception as e: |
| return False |
| |
| print("by k1115h0t") |
| print("根域名放置在domians.txt中") |
| print("当前文件夹下放置httpx") |
| os.system('subfinder/subfinder -dL domains.txt -all -o subfinder_subdomains.txt') |
| os.system('python3 oneforall/oneforall.py --targets domains.txt run') |
| oneforall_result='' |
| for f_name in os.listdir('oneforall/results'): |
| if fnmatch.fnmatch(f_name, 'all*.txt'): |
| oneforall_result='oneforall/results/'+f_name |
| |
| with open(oneforall_result, 'r',encoding='gbk') as file1: |
| content1 = file1.readlines() |
| |
| elif fnmatch.fnmatch(f_name, 'all*.csv'): |
| oneforall_result = 'oneforall/results/' + f_name |
| content1=[''] |
| table = csv.reader(open(oneforall_result, 'r')) |
| header = next(table) |
| for row in table: |
| content1.append(row[5]+'\n') |
| |
| |
| with open('subfinder_subdomains.txt', 'r') as file2: |
| content2 = file2.readlines() |
| |
| |
| merged_content = content1 + content2 |
| |
| |
| unique_content = list(set(merged_content)) |
| |
| |
| with open('subdomains_ports.txt', 'w',encoding='utf-8') as merged_file: |
| merged_file.writelines(unique_content) |
| |
| print("================================================") |
| print("================================================") |
| print("================================================") |
| print("子域名已经全部扫描完成,子域名结果存储在 subdomains.txt") |
| print("开始识别CDN") |
| print("================================================") |
| print("================================================") |
| print("================================================") |
| if os.path.exists('oneforall/results'): |
| shutil.rmtree(r'oneforall/results') |
| os.remove('subfinder_subdomains.txt') |
| f1=open(file='subdomains_ports.txt',mode='r',encoding='utf-8') |
| f2=open(file='cdn.txt',mode='a',encoding='utf-8') |
| f3=open(file='nocdn.txt',mode='a',encoding='utf-8') |
| f4=open(file='nocdn_ip.txt',mode='a',encoding='utf-8') |
| l1=[] |
| num=1 |
| for i in f1.readlines(): |
| newi=i.strip('\n') |
| result=checkcdn(newi) |
| |
| num=num+1 |
| if result!=False: |
| f3.write(i) |
| if result not in l1: |
| l1.append(result) |
| else: |
| f2.write(i) |
| for j in l1: |
| f4.write(j+'\n') |
| f1.close() |
| f2.close() |
| f3.close() |
| f4.close() |
| print("开始调用rustscan") |
| print("================================================") |
| print("================================================") |
| print("================================================") |
| os.system("rustscan -a nocdn_ip.txt -r 1-65535 -g >> rustscan_nocdn.txt") |
| f5=open(file='rustscan_nocdn.txt',mode='r') |
| l1=f5.readlines() |
| l2=[] |
| f5.close() |
| for a in l1: |
| tmp_l1=a.split(' ') |
| str_host=tmp_l1[0] |
| tmpstr_port=tmp_l1[2] |
| tmpstr_port=tmpstr_port.strip('\n').strip('[').strip(']') |
| port_li=tmpstr_port.split(',') |
| for b in port_li: |
| open_port=str_host+':'+b |
| l2.append(open_port) |
| f6=open(file='subdomains_ports.txt',mode='a') |
| for t in l2: |
| f6.write(t+'\n') |
| f6.close() |
| print("开始调用httpx") |
| print("================================================") |
| print("================================================") |
| print("================================================") |
| os.system('./httpx -l subdomains_ports.txt -o httpx_subdomains_ports.txt') |
| print("================================================") |
| print("================================================") |
| print("================================================") |
| print("httpx识别完成,结果存储在 httpx_subdomains_ports.txt") |
| os.system('/root/nuclei/nuclei -ut') |
| os.system('/root/nuclei/nuclei -l /root/collect_info/httpx_subdomains_ports.txt -o /root/collect_info/nuclei_httpx_subdomains_ports.txt -es info -ept ssl,dns') |
使用时需要新建一个domains.txt用于存放根域名(baidu.com)
脚本的流程
-
调用 subfinder 和 oneforall进行子域名扫描
| 生成 subdomains.txt 存储所有的子域名 |
-
对子域名结果进行分析去重,并识别cdn
| 生成 cdn.txt nocdn.txt nocdn_ip.txt |
-
使用httpx进行扫描
| 生成 cdn_httpx.txt nocdn_httpx.txt |
-
使用rustscan对无cdn的ip进行端口扫描
目录下面工具的放置
在第二次使用的时候,需要先手动删除所有txt文件
目录结构:
| ├── cdn_httpx.txt 有cdn的域名的httpx 结果 |
| ├── cdn.txt 没有cdn的域名 |
| ├── domains.txt 要进行信息收集的根域名 |
| ├── httpx httpx二进制文件 |
| ├── nocdn_httpx.txt 无cdn的域名的httpx 结果 |
| ├── nocdn_ip.txt 无cdn域名解析出的ip |
| ├── nocdn.txt |
| ├── oneforall |
| ├── rustscan_nocdn.txt |
| ├── start.py |
| ├── subdomains.txt |
| └── subfinder |
| |

工具链接
| 工具链接: |
| https://github.com/shmilylty/OneForAll |
| https://github.com/projectdiscovery/subfinder |
| https://github.com/projectdiscovery/httpx |
| https://github.com/RustScan/RustScan |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】