子域名探测方法大全
字数 2290 2025-08-18 11:36:36

子域名探测方法大全

为什么要进行子域名探测?

子域名探测是渗透测试和信息收集的关键环节,具有以下重要意义:

  1. 扩大攻击面:发现更多服务,增加发现漏洞的可能性
  2. 寻找被遗忘的系统:较少访问的子域名可能运行着存在关键漏洞的旧版应用
  3. 发现重复漏洞:同一组织的不同域名/应用中可能存在相同漏洞
  4. 定位关键资产:子域名中常包含办公系统、邮箱系统、论坛、商城和管理后台等重要资产

子域名探测方法分类

1. 在线接口查询

利用公开的在线服务快速获取子域名信息:

https://crt.sh/
https://censys.io/
https://transparencyreport.google.com/https/certificates
https://dnsdumpster.com/
https://hackertarget.com/find-dns-host-records/
https://x.threatbook.cn/
https://www.virustotal.com/gui/home/search
https://phpinfo.me/domain/
https://site.ip138.com/baidu.com/domain.htm
https://www.t1h2ua.cn/tools/
http://tool.chinaz.com/subdomain/
https://spyse.com/site/not-found?q=domain%3A%22github%22&criteria=cert

2. 暴力枚举技术

工具推荐:

  1. Layer子域名爆破机

    • Windows平台工具
    • 使用子域名字典进行爆破
    • 简单易用
  2. Amass

    • 功能:爆破、Google搜索、VirusTotal查询、备用名称收集
    • 安装:go get -u github.com/OWASP/Amass/...
    • 使用:amass -d target.com -o $outfile
  3. Knock

    • 功能:AXFR查询、VirusTotal查询、爆破
    • 安装:
      apt-get install python-dnspython
      git clone https://xxx.com/guelfoweb/knock.git
      cd knock
      python setup.py install
      

3. 搜索引擎技术

Google搜索技巧:

  • site:target.com - 查找目标域所有子域名
  • intitle=公司名称 - 查找特定公司网站
  • site:*.wikimedia.org -www -store -jobs -uk - 排除特定子域名

其他搜索引擎:

  • Bingsite:target.com
  • 百度intitle=公司名称
  • 钟馗之眼site=域名
  • FOFAdomain="baidu.com"

4. 证书透明(Certificate Transparency)技术

SSL/TLS证书通常包含域名、子域名和邮件地址,可通过以下方式查询:

在线查询:

https://crt.sh/
https://censys.io/
https://developers.facebook.com/tools/ct/
https://google.com/transparencyreport/https/ct/
https://transparencyreport.google.com/https/certificates

工具推荐:

  1. CTFR

    • 滥用证书透明记录
    • 使用:
      git clone https://xxx.com/UnaPibaGeek/ctfr.git
      cd ctfr
      pip3 install -r requirements.txt
      python3 ctfr.py -d target.com -o $outfile
      
  2. Censys_subdomain_enum.py

    • 从Censys的SSL/TLS证书中收集子域名
    • 安装:pip install censys
    • 使用:python censys_enumeration.py target.com

5. 主题备用名称(SAN)技术

SAN证书允许在安全证书中使用subjectAltName字段关联多个域名。

工具san_subdomain_enum.py

git clone https://xxx.com/appsecco/the-art-of-subdomain-enumeration.git
./san_subdomain_enum.py target.com

6. 公开数据集查询

利用互联网扫描数据集获取子域名信息:

  1. Rapid7 Forward DNS dataset (Project Sonar)

    • 数据来源:https://scans.io/data/rapid7/sonar.fdns_v2/
    • 解析命令:
      curl -silent https://scans.io/data/rapid7/sonar.fdns_v2/20170417-fdns.json.gz | pigz -dc | grep ".icann.org" | jq
      
  2. 其他数据源

    • https://scans.io/study/sonar.rdns_v2
    • https://opendata.rapid7.com/

7. 信息泄露利用

常见信息泄露点:

  • 官网底部信息
  • 文件泄漏:
    • crossdomain.xml(跨域策略文件cdx)
    • robots.txt
    • Git仓库泄露
  • 流量分析

8. 内容解析技术

从HTML、JavaScript和文件中提取子域名:

  1. BiLE-suite

    • HTML解析和反向DNS解析
    • 安装:
      aptitude install httrack
      git clone https://xxx.com/sensepost/BiLE-suite.git
      perl BiLE.pl target.com
      
  2. Second Order

    • 第二阶段域名扫描
    • 安装:
      go get xxx.com/mhmdiaa/second-order
      second-order -base https://target.com -config config.json -output target.com
      

9. DNS解析技术

在线查询:

  • VirusTotal(https://www.virustotal.com/)
  • ViewDNS(https://viewdns.info/)
  • DNSdumpster(https://dnsdumpster.com/)
  • Threatcrowd(https://www.threatcrowd.org/)

工具推荐:

Massdns

  • 高性能DNS解析
  • 安装:
    git clone https://xxx.com/blechschmidt/massdns.git
    cd massdns/
    make
    
  • 使用:
    # 解析域名
    /bin/massdns -r lists/resolvers.txt -t AAAA -w results.txt domains.txt -o S -w output.txt
    
    # 爆破域名
    ./scripts/subbrute.py wordlist.txt target.com | ./bin/massdns -r lists/resolvers.txt -t A -o S -w output.txt
    
    # CT解析
    ./scripts/ct.py target.com | ./bin/massdns -r lists/resolvers.txt -t A -o S -w output.txt
    

10. 区域传送技术

域传送漏洞可获取DNS服务器的全部域文件副本。

Windows方法:

nslookup
server [DNS服务器]
ls [目标域名]

Linux方法:

dig +multi AXFR target.com
dig +multi AXFR $ns_server target.com

11. DNS缓存侦测技术

通过检查DNS服务器缓存判断域名是否被访问过。

12. DNSSEC区域漫步技术

利用DNSSEC处理不存在域名的方式遍历整个域。

工具ldns-walk

aptitude install ldnsutils
ldns-walk target.com
ldns-walk @nsserver.com target.com

13. CSP HTTP首部分析

从内容安全策略(CSP)头中提取子域名。

工具domains-from-csp

git clone https://xxx.com/yamakira/domains-from-csp.git
pip install click
python csp_parser.py $URL
python csp_parser.py $URL -r

14. SPF记录分析

SPF记录列出了被授权代表域名发送电子邮件的主机。

工具assets-from-spf

git clone https://xxx.com/yamakira/assets-from-spf.git
pip install click ipwhois
python assets_from_spf.py target.com

15. 虚拟主机爆破

工具推荐:

  1. vhost-brute

    aptitude install php-curl
    git clone https://xxx.com/gwen001/vhost-brute.git
    
  2. Virtual-host-discovery

    git clone https://xxx.com/jobertabma/virtual-host-discovery.git
    ruby scan.rb --ip=1.1.1.1 --host=target.com --output output.txt
    

16. ASN发现技术

通过域名查询ASN,再通过ASN查询所属的所有IP范围。

17. 综合工具推荐

  1. OneForAll

    • 功能全面的子域名收集工具
    • 地址:https://github.com/shmilylty/OneForAll
  2. Sublist3r

    • 快速子域枚举工具
    • 地址:https://github.com/aboul3la/Sublist3r

最佳实践建议

  1. 定期DNS解析:维持数据的实时性,保存历史解析的IP
  2. 多源数据整合
    • 爬取域名首页抓取二级域名
    • 整理sonar.fdns和sonar.http数据集
    • 结合域传送、爆破和搜索引擎结果
  3. 解决泛解析问题
    • 先获取不存在域名的响应内容作为基准
    • 遍历字典比对响应内容相似度
    • 牺牲速度换取准确性

参考资料

  1. https://www.freebuf.com/news/133873.html
  2. https://xz.aliyun.com/t/5509
子域名探测方法大全 为什么要进行子域名探测? 子域名探测是渗透测试和信息收集的关键环节,具有以下重要意义: 扩大攻击面 :发现更多服务,增加发现漏洞的可能性 寻找被遗忘的系统 :较少访问的子域名可能运行着存在关键漏洞的旧版应用 发现重复漏洞 :同一组织的不同域名/应用中可能存在相同漏洞 定位关键资产 :子域名中常包含办公系统、邮箱系统、论坛、商城和管理后台等重要资产 子域名探测方法分类 1. 在线接口查询 利用公开的在线服务快速获取子域名信息: 2. 暴力枚举技术 工具推荐: Layer子域名爆破机 : Windows平台工具 使用子域名字典进行爆破 简单易用 Amass : 功能:爆破、Google搜索、VirusTotal查询、备用名称收集 安装: go get -u github.com/OWASP/Amass/... 使用: amass -d target.com -o $outfile Knock : 功能:AXFR查询、VirusTotal查询、爆破 安装: 3. 搜索引擎技术 Google搜索技巧: site:target.com - 查找目标域所有子域名 intitle=公司名称 - 查找特定公司网站 site:*.wikimedia.org -www -store -jobs -uk - 排除特定子域名 其他搜索引擎: Bing : site:target.com 百度 : intitle=公司名称 钟馗之眼 : site=域名 FOFA : domain="baidu.com" 4. 证书透明(Certificate Transparency)技术 SSL/TLS证书通常包含域名、子域名和邮件地址,可通过以下方式查询: 在线查询: 工具推荐: CTFR : 滥用证书透明记录 使用: Censys_ subdomain_ enum.py : 从Censys的SSL/TLS证书中收集子域名 安装: pip install censys 使用: python censys_enumeration.py target.com 5. 主题备用名称(SAN)技术 SAN证书允许在安全证书中使用subjectAltName字段关联多个域名。 工具 : san_subdomain_enum.py 6. 公开数据集查询 利用互联网扫描数据集获取子域名信息: Rapid7 Forward DNS dataset (Project Sonar) : 数据来源:https://scans.io/data/rapid7/sonar.fdns_ v2/ 解析命令: 其他数据源 : https://scans.io/study/sonar.rdns_ v2 https://opendata.rapid7.com/ 7. 信息泄露利用 常见信息泄露点: 官网底部信息 文件泄漏: crossdomain.xml(跨域策略文件cdx) robots.txt Git仓库泄露 流量分析 8. 内容解析技术 从HTML、JavaScript和文件中提取子域名: BiLE-suite : HTML解析和反向DNS解析 安装: Second Order : 第二阶段域名扫描 安装: 9. DNS解析技术 在线查询: VirusTotal(https://www.virustotal.com/) ViewDNS(https://viewdns.info/) DNSdumpster(https://dnsdumpster.com/) Threatcrowd(https://www.threatcrowd.org/) 工具推荐: Massdns : 高性能DNS解析 安装: 使用: 10. 区域传送技术 域传送漏洞可获取DNS服务器的全部域文件副本。 Windows方法: Linux方法: 11. DNS缓存侦测技术 通过检查DNS服务器缓存判断域名是否被访问过。 12. DNSSEC区域漫步技术 利用DNSSEC处理不存在域名的方式遍历整个域。 工具 : ldns-walk 13. CSP HTTP首部分析 从内容安全策略(CSP)头中提取子域名。 工具 : domains-from-csp 14. SPF记录分析 SPF记录列出了被授权代表域名发送电子邮件的主机。 工具 : assets-from-spf 15. 虚拟主机爆破 工具推荐: vhost-brute : Virtual-host-discovery : 16. ASN发现技术 通过域名查询ASN,再通过ASN查询所属的所有IP范围。 17. 综合工具推荐 OneForAll : 功能全面的子域名收集工具 地址:https://github.com/shmilylty/OneForAll Sublist3r : 快速子域枚举工具 地址:https://github.com/aboul3la/Sublist3r 最佳实践建议 定期DNS解析 :维持数据的实时性,保存历史解析的IP 多源数据整合 : 爬取域名首页抓取二级域名 整理sonar.fdns和sonar.http数据集 结合域传送、爆破和搜索引擎结果 解决泛解析问题 : 先获取不存在域名的响应内容作为基准 遍历字典比对响应内容相似度 牺牲速度换取准确性 参考资料 https://www.freebuf.com/news/133873.html https://xz.aliyun.com/t/5509