信息收集思路小结
字数 3943 2025-09-01 11:26:17
信息收集技术全面指南
主域名搜集
主域名搜集是信息收集的第一步,决定了后续能够搜索到的资产范围。以下是几种有效的搜集方法:
1. 谷歌语法搜索
使用Google高级搜索语法可以高效定位目标资产:
- 查找相似网站:
related:kelnur.com- 查找与目标网站内容相似的站点 - 搜索主域名含关键词:
site:.com "kelnur" -site:*.com- 在.com主域名中搜索关键词,排除子域名 - 查找反向链接的主域名:
link:kelnur.com -site:*.com- 查找直接链接到目标网站的主域名 - 查找新注册的含关键词域名:
"kelnur" daterange:20240101-20241231 -site:*.com- 搜索特定时间段内新注册的域名
2. 网站图标(Favicon)查询
通过空间测绘工具(如FOFA、Shodan)使用网站图标哈希值进行查询,可能发现使用相同图标的其他主域名网站。
3. IP查询法
- 空间测绘:根据网站的真实IP地址查询绑定的主域名
- IP域名反查:使用
https://viewdns.info/reverseip/等工具进行反查
4. 网站关联分析
通过分析网站的友情链接、合作伙伴等关联信息,寻找可能的主域名。
子域名收集
1. 被动收集方法
- DNS查询:使用
https://dnsdumpster.com/ - 证书查询:使用
https://crt.sh/查询SSL证书中出现的子域名
2. 主动收集工具
Ksubdomain
- 特点:主动收集工具,异步DNS数据包,使用pcap每秒可扫描160万个子域名
- 安装:
https://github.com/boy-hack/ksubdomain - 常用命令:
cat url.txt|./ksubdomain e --stdin -o url2.txte:枚举子域名--silent:静默模式输出-o url2.txt:结果输出到文件
Subfinder
- 特点:快速被动子域枚举工具
- 安装:
https://github.com/projectdiscovery/subfinder - 常用命令:
./subfinder -dL url.txt -o url2.txt-dL url.txt:从文件读取多个主域名-o url2.txt:结果输出到文件
3. 去重处理
使用Python脚本进行高效去重:
seen = set()
with open('url3.txt', 'r', encoding='utf-8') as infile, open('url4.txt', 'w', encoding='utf-8') as outfile:
for line in infile:
line = line.strip()
if line:
first_part = line.split('=>')[0].strip()
if first_part not in seen:
seen.add(first_part)
outfile.write(first_part + '\n')
IP地址收集
1. 子域名解析IP
使用Python脚本批量解析子域名IP并去重:
import dns.resolver
import concurrent.futures
import sys
from tqdm import tqdm
def get_ip_from_local_dns(domain, dns_server="8.8.8.8", dns_port=53):
resolver = dns.resolver.Resolver()
resolver.nameservers = [dns_server]
resolver.port = dns_port
resolver.timeout = 2
resolver.lifetime = 3
try:
answers = resolver.resolve(domain, 'A')
ip_list = [rdata.address for rdata in answers]
return domain, ip_list, None
except Exception as e:
return domain, [], str(e)
def read_urls_from_file(file_path):
try:
with open(file_path, 'r') as file:
urls = file.readlines()
return [url.strip() for url in urls if url.strip()]
except FileNotFoundError:
print(f"[-] 文件 {file_path} 未找到")
return []
def write_ips_to_file(results, output_path="ips.txt"):
try:
with open(output_path, 'w') as file:
for ip in results:
file.write(f"{ip}\n")
print(f"[+] 所有 IP 地址已写入 {output_path} 文件")
except Exception as e:
print(f"[-] 写入文件时出错: {e}")
def process_result(result):
domain, ips, error = result
if error:
print(f"[-] {domain} 解析失败: {error}")
else:
print(f"[+] {domain} => {','.join(ips)}")
return ips
def main():
if len(sys.argv) > 1:
file_path = sys.argv[1]
else:
file_path = input("请输入包含域名的文件路径 (如url.txt): ")
domains = read_urls_from_file(file_path)
if not domains:
print("[-] 没有找到有效的域名")
return
print(f"[*] 开始处理 {len(domains)} 个域名...")
all_ips = []
with concurrent.futures.ThreadPoolExecutor(max_workers=50) as executor:
future_to_domain = {executor.submit(get_ip_from_local_dns, domain): domain for domain in domains}
for future in tqdm(concurrent.futures.as_completed(future_to_domain), total=len(domains), desc="解析进度"):
result = future.result()
domain_ips = process_result(result)
all_ips.extend(domain_ips)
unique_ips = list(set(all_ips))
print(f"[+] 共发现 {len(unique_ips)} 个唯一IP地址")
write_ips_to_file(unique_ips)
if __name__ == "__main__":
main()
2. CDN绕过技术
CDN简介:内容分发网络,通过分布式服务器缓存内容,提升访问速度并隐藏真实IP。
绕过方法:
-
内部邮箱资源:
- 通过目标网站的注册或RSS订阅功能获取邮件头
- 查找邮件服务器域名并解析其IP
-
扫描网站测试文件:
- 如.phpinfo、.test等可能暴露真实IP的文件
-
子域名反推法:
- 查找未启用CDN的子域名(如mail.example.com)并解析其IP
-
网络空间引擎搜索:
- 使用FOFA、Shodan等直接查询主域名
-
全球Ping:
- 使用
https://tool.chinaz.com/speedworld/等工具进行全球Ping测试
- 使用
-
phpinfo.php探针:
- 查找可能暴露服务器信息的探针文件
-
C段查询:
- 对已知IP的C段进行查询,可能发现真实服务器
端口收集
1. Naabu端口扫描
- 特点:Go编写的快速端口扫描程序,注重可靠性和简单性
- 安装:
https://github.com/projectdiscovery/naabu - 常用命令:
.\naabu.exe -l ips.txt -silent-l ips.txt:指定IP列表文件-silent:静默模式输出
2. 常见端口及攻击方式
| 端口 | 服务 | 攻击方式 |
|---|---|---|
| 21 | FTP/TFTP | 爆破/嗅探/溢出/后门 |
| 22 | SSH | 爆破/OpenSSH漏洞 |
| 23 | Telnet | 爆破/嗅探/弱口令 |
| 25 | SMTP | 邮件伪造 |
| 53 | DNS | 域传送/劫持/缓存投毒/欺骗 |
| 80/443 | HTTP/HTTPS | Web应用漏洞/心脏滴血 |
| 1433 | MSSQL | 爆破/注入/SA弱口令 |
| 3306 | MySQL | 爆破/注入 |
| 3389 | RDP | 爆破/shift后门 |
| 6379 | Redis | 未授权访问/爆破 |
| 7001/7002 | WebLogic | Java反序列化/控制台弱口令 |
| 8080 | Tomcat/JBoss | 爆破/PUT文件上传/反序列化 |
| 9200/9300 | Elasticsearch | 远程代码执行 |
| 27017 | MongoDB | 未授权访问/爆破 |
存活探测
HTTPX工具
-
特点:快速多功能HTTP工具包,支持多种探测功能
-
安装:
https://github.com/projectdiscovery/httpx -
常用命令:
cat url4.txt | .\httpx.exe -status-code -title -tech-detect -follow-redirects -mc 200,302,403 -proxy http://127.0.0.1:7897 -threads 200 -timeout 10 -o result.json参数说明:
-status-code:显示HTTP状态码-title:抓取网页标题-tech-detect:检测Web技术-follow-redirects:跟随重定向-mc 200,302,403:只显示指定状态码的结果-proxy:通过代理发送请求-threads 200:使用200个并发线程-timeout 10:设置10秒超时-o result.json:输出JSON格式结果
指纹识别
EHole_magic
-
特点:支持路径指纹识别、重点资产漏洞检测、FTP服务识别及爆破
-
安装:
https://github.com/lemonlove7/EHole_magic -
常用命令:
.\ehole_windows.exe finger -l .\url.txt --proxy http://127.0.0.1:7897参数说明:
finger:指纹识别模块-l .\url.txt:指定目标列表文件--proxy:通过代理发送请求
网站基本信息收集
- 编程语言:使用Wappalyzer工具分析
- 数据库类型:Wappalyzer或FOFA识别
- Web容器:Wappalyzer和FOFA识别
- 操作系统:
- 大小写测试(Windows不区分大小写,Linux区分)
- Ping TTL值分析
目录扫描
FFUF工具
-
特点:Go编写的快速Web模糊器
-
安装:
https://github.com/ffuf/ffuf -
常用命令:
.\ffuf.exe -u https://www.example.com/FUZZ -w ./common.txt -x http://127.0.0.1:7897 -mc 200 -recursion -recursion-depth 2 -c参数说明:
-u:目标URL,FUZZ为占位符-w:字典文件路径-x:通过代理发送请求-mc 200:只显示200状态码结果-recursion:自动递归爆破-recursion-depth 2:限制递归深度为2层-c:彩色输出
推荐字典
- SecLists:
https://github.com/danielmiessler/SecLists- 包含用户名、密码、URL、敏感数据模式、模糊测试载荷等
- 非常全面的安全测试字典集合
JS文件信息提取
JSFinder工具
-
特点:自动提取JS文件中的敏感信息(API路径、域名、密钥等)
-
安装:
https://github.com/Threezh1/JSFinder -
常用命令:
python .\JSFinder.py -u https://example.com/ -c "_gscu_1123603759:434164374obd12" -d参数说明:
-u:目标网址-c:指定Cookie(可获取更多接口信息)-d:深度扫描模式
总结
本指南系统介绍了信息收集的全流程技术,从主域名搜集到子域名枚举,从IP收集到端口扫描,再到存活探测、指纹识别和目录扫描。关键点包括:
- 主域名是信息收集的基础,使用多种方法确保全面性
- 子域名枚举结合主动和被动方法提高覆盖率
- IP收集和CDN绕过是定位真实服务器的关键
- 端口扫描扩展攻击面,识别潜在脆弱服务
- 指纹识别帮助快速定位已知漏洞
- 目录扫描可能发现隐藏的敏感资源
实际工作中,可根据目标特点灵活组合这些技术,也可编写自动化脚本提高效率。信息收集的质量直接决定了后续渗透测试的广度和深度,是安全评估中不可忽视的重要环节。