再谈信息收集-子域名收集
字数 2844 2025-08-10 23:41:56
子域名收集技术详解
信息收集的重要性
信息收集是渗透测试成功的关键环节,其中子域名收集是信息收集的重要组成部分。通过收集目标公司的子域名,可以扩大攻击面,发现更多潜在漏洞。
公司备案域名收集
在国内,域名使用前需要备案,可以通过以下方式查询公司备案域名:
-
站长工具:
- 接口:
https://micp.chinaz.com/Handle/AjaxHandler.ashx?action=GetBeiansl&query={domain}&type=host
- 接口:
-
爱企查:
- 接口:
https://aiqicha.baidu.com/detail/icpinfoajax?p=1&size=20&pid={公司pid}
- 接口:
子域名收集方法
主动收集技术
-
DNS域传送漏洞
- 检查方法:
nslookup -type=ns xxxx.com nslookup server dns服务 ls domain - 如果存在漏洞,可以获取完整的域名列表
- 检查方法:
-
子域名爆破
- 原理:通过枚举字典内容查询域名的A记录
- 处理泛解析问题:
- 先访问随机不存在的域名判断是否存在泛解析
- 收集IP黑名单(出现次数>2次的IP)
- 结合TTL值进行过滤(泛解析记录的TTL相同)
- 工具推荐:
subDomainsBrute
-
站点配置文件扫描
- 检查文件:
- 跨域策略文件:
crossdomain.xml - Sitemap文件:
sitemap.xml,sitemap.txt,sitemap.html,sitemapindex.xml
- 跨域策略文件:
- 检查文件:
-
网站内容分析
- 从网页、JS文件中提取子域名信息
- 工具推荐:
- JSFinder: https://gitee.com/kn1fes/JSFinder
- Packer-Fuzzer: https://github.com/rtcatc/Packer-Fuzzer
- SecretFinder: https://gitee.com/mucn/SecretFinder
被动收集技术
-
搜索引擎查询
- 常用搜索引擎及语法:
- 百度:
intitle=公司名称;site:xxx.com - Google:
intitle=公司名称;site:xxx.com - FOFA:
title="公司名称"; domain="xxx.cn" - 钟馗之眼:
site=域名或hostname:xxx.com - Shodan:
hostname:"xxx.com" - 360测绘空间:
domain:"xxx.cn"
- 百度:
- 常用搜索引擎及语法:
-
在线子域名查询网站
- 站长之家:https://tool.chinaz.com/subdomain?domain=
- DNSdumpster:https://dnsdumpster.com/
- 查询网:https://site.ip138.com/
- 爱站:http://dns.aizhan.com
-
威胁情报平台
- 微步查询:https://x.threatbook.com/
- AlienVault:https://otx.alienvault.com/
- RiskIQ:https://community.riskiq.com/
- ThreatMiner:https://www.threatminer.org/
- 奇安信威胁情报中心:https://ti.qianxin.com/
- 启明星辰威胁情报中心:https://www.venuseye.com.cn/
-
第三方DNS服务
- 常用服务:
- https://decoder.link/
- https://searchdns.netcraft.com/
- https://dnsdumpster.com/
- https://pentest-tools.com/information-gathering/find-subdomains-of-domain
- https://hackertarget.com/find-dns-host-records/
- 常用服务:
-
GitHub搜索
- 搜索语法:
in:name xxx- 仓库标题中含有关键字in:descripton xxx.com- 仓库描述搜索in:readme xxx- Readme文件搜索
- 搜索语法:
-
网盘搜索
- 常用平台:
- 凌云搜索:https://www.lingfengyun.com/
- 盘搜搜:http://www.pansoso.com/
- 常用平台:
-
WHOIS查询及关联查询
- 通过WHOIS查询域名信息
- 反查手机号或邮箱获取相关域名
-
证书透明度收集
- 原理:通过证书颁发机构公开的证书信息获取域名
- 常用网站:
- https://crt.sh/
- https://developers.facebook.com/tools/ct
- https://www.entrust.com/ct-search/
- https://sslmate.com/certspotter/api/
- https://censys.io/certificates
- https://google.com/transparencyreport/https/ct/
-
DNS记录查询
- 查询SRV记录:
nmap --script dns-srv-enum.nse --script-args "dns-srv-enum.domain='baidu.com'" - 查询MX、NS、SOA、TXT记录获取子域名
- 查询SRV记录:
-
IP反查域名
- 通过域名获取IP,再查询解析到该IP的域名记录
- 工具推荐:https://github.com/Sma11New/ip2domain
- 在线工具:
- https://stool.chinaz.com/same
- https://site.ip138.com/
常用子域名收集工具对比
| 工具名称 | 描述 | 优点 | 缺点 | 下载地址 |
|---|---|---|---|---|
| OneForAll | 功能全面的子域名收集工具,集成多种收集方式 | 功能全面,输出格式多 | 速度慢,泛解析处理不理想 | https://github.com/shmilylty/OneForAll |
| SubdomainBrute | 采用协程加速爆破 | 速度快,准确率高 | 收集来源单一 | https://github.com/lijiejie/subDomainsBrute |
| Sublist3r | 通过爆破收集子域名 | 结果多、基数大、速度快 | 收集来源单一 | - |
| ShuiZe | 全方位资产收集工具 | 信息全面,包含公司、IP等信息 | 运行慢,安装复杂 | https://github.com/0x727/ShuiZe_0x727 |
最佳实践建议
- 组合使用多种工具:单一工具无法覆盖所有收集方式,建议组合使用多个工具
- 定期更新字典:爆破效果取决于字典质量,需要定期更新字典
- 验证收集结果:收集到的子域名需要验证其有效性和相关性
- 注意日志记录:主动收集方法会在目标服务器留下日志记录
- 遵守法律法规:信息收集应在授权范围内进行
通过以上全面的子域名收集技术,可以有效地扩大渗透测试的攻击面,为后续的漏洞发现和利用奠定基础。