从子域枚举到漏洞发现
字数 2975 2025-08-25 22:58:34

从子域枚举到漏洞发现 - 全面教学指南

子域枚举的意义与价值

子域枚举是渗透测试中至关重要的侦察阶段,其核心价值在于:

  • 增加发现漏洞的概率,服务于渗透测试的成功
  • 子域通常运行着各种应用程序,提供了更多漏洞发现机会
  • 相同漏洞常出现在不同子域中
  • 隐藏子域可能包含关键应用程序,发现后可直击目标核心

子域枚举技术详解

1. 通过搜索引擎枚举

Google语法

site:*.example.com -www -search -chrome -news
  • 使用site:*操作符查找所有子域
  • 使用-排除不感兴趣的子域
  • 适用于所有主流搜索引擎

2. 第三方DNS数据集服务

VirusTotal

  • 网址:https://www.virustotal.com/gui/home/search
  • 提供比搜索引擎更直观全面的信息
  • 可查找子域、WHOIS等关键信息

DNSdumpster

  • 网址:https://dnsdumpster.com/
  • 特色功能:提供可视化映射图
  • 示例映射图URL:https://dnsdumpster.com/static/map/google.com.png

3. 工具枚举

Sublist3r

  • GitHub:https://github.com/aboul3la/Sublist3r
  • 功能特点:
    • 集成多个搜索引擎(Google/Yahoo/Bing/Ask/Baidu)
    • 使用Netcraft、VirusTotal、ThreatCrowd、DNSdumpster、ReverseDNS
    • 支持爆破和端口扫描

基本用法:

python sublist3r.py -e google,bing,yahoo,virustotal -d example.com -b -p 80,443

参数说明:

  • -e:指定搜索引擎
  • -b:启用爆破
  • -p:指定端口

assetfinder

  • GitHub:https://github.com/tomnomnom/assetfinder
  • 特点:
    • 跨平台支持良好
    • 执行速度快
    • 简单易用

基本用法:

assetfinder [--subs-only] example.com

altdns

  • GitHub:https://github.com/infosec-au/altdns
  • 功能:通过变更和排列发现符合模式的子域

dnsrecon

  • GitHub:https://github.com/darkoperator/dnsrecon
  • 功能:全面的DNS枚举脚本

4. 证书透明度(Certificate Transparency, CT)

CT是记录、审核和监视CA颁发证书的系统,SSL/TLS证书常包含域名、子域等有价值信息。

crt.sh

  • 网址:https://crt.sh/?q=%25.example.com
  • 提供PostgreSQL接口查询子域

Shell脚本示例:

#!/bin/sh
# Script by Hanno Bock - https://github.com/hannob/tlshelpers/blob/master/getsubdomain

query="SELECT ci.NAME_VALUE NAME_VALUE FROM certificate_identity ci WHERE ci.NAME_TYPE = 'dNSName' AND reverse(lower(ci.NAME_VALUE)) LIKE reverse(lower('%.$1'));"
echo $query | \
    psql -t -h crt.sh -p 5432 -U guest certwatch | \
    sed -e 's:^ ::g' -e 's:^.::g' -e '/^$/d' | \
    sort -u | sed -e 's:*.::g'

massdns

  • GitHub:https://github.com/blechschmidt/massdns
  • 编译:在根目录运行make
  • 支持crt.sh查询:
./scripts/ct.py github.com | ./bin/massdns -r lists/resolvers.txt -t A -o S -w results.txt
  • 子域暴力枚举:
./scripts/subbrute.py lists/names.txt github.com | ./bin/massdns -r lists/resolvers.txt -t A -o S -w results.txt

censys

  • 网址:https://censys.io/
  • 类似Shodan的搜索引擎,用于信息侦察
  • 需要注册获取API密钥:https://censys.io/register
  • 设置环境变量:
export CENSYS_API_ID="your_api_id"
export CENSYS_API_SECRET="your_api_secret"

相关工具:

  • censys-subdomain-finder:https://github.com/christophetd/censys-subdomain-finder
  • censys-enumeration:https://github.com/0xbharath/censys-enumeration

5. 自治系统/自治域(AS)枚举

自治系统(AS)是一个或多个实体管辖下的IP网络和路由器的组合。

相关资源:

  • RFC 1930:https://tools.ietf.org/html/rfc1930
  • IANA AS编号分配:https://www.iana.org/assignments/as-numbers/as-numbers.xhtml

工具和服务:

  • ASN查询:https://asn.cymru.com/cgi-bin/whois.cgi
  • UltraTools ASN信息:https://www.ultratools.com/tools/asnInfo
  • Nmap ASN脚本:
nmap --script targets-asn --script-args targets-asn.asn=ASN编号

实战案例:从子域枚举到XSS漏洞发现

  1. 使用crt.sh查找多级子域

    • 通过证书透明度数据发现潜在目标
  2. assetfinder配合httprobe枚举子域

    • 发现目标:https://client-beta.global.chalet.8x8.com/
  3. dirsearch目录探测

    • GitHub:https://github.com/maurosoria/dirsearch
    • 用于发现网站目录结构
  4. Arjun查找隐藏参数

    • GitHub:https://github.com/s0md3v/Arjun
    • 用于发现未公开的URL参数
  5. XSS漏洞利用

    • Payload:">
    • 通过参数注入实现反射型XSS

参考资源

工具集合

  • Sublist3r:https://github.com/aboul3la/Sublist3r
  • assetfinder:https://github.com/tomnomnom/assetfinder
  • altdns:https://github.com/infosec-au/altdns
  • dnsrecon:https://github.com/darkoperator/dnsrecon
  • massdns:https://github.com/blechschmidt/massdns
  • censys-subdomain-finder:https://github.com/christophetd/censys-subdomain-finder
  • censys-enumeration:https://github.com/0xbharath/censys-enumeration

学习资料

  • 子域枚举艺术:https://github.com/appsecco/the-art-of-subdomain-enumeration
  • 渗透测试者子域枚举指南:https://hakin9.org/a-penetration-testers-guide-to-subdomain-enumeration/
  • 证书透明度详解:https://blog.appsecco.com/certificate-transparency-the-bright-side-and-the-dark-side-8aa47d9a6616
  • ASN基础知识:https://en.wikipedia.org/wiki/Autonomous_system_(Internet)

在线服务

  • VirusTotal:https://www.virustotal.com/gui/home/search
  • DNSdumpster:https://dnsdumpster.com/
  • crt.sh:https://crt.sh/
  • censys:https://censys.io/
  • ASN查询:https://asn.cymru.com/cgi-bin/whois.cgi

通过系统性地应用这些技术和工具,安全研究人员可以有效地枚举目标组织的子域,进而发现潜在的安全漏洞。

从子域枚举到漏洞发现 - 全面教学指南 子域枚举的意义与价值 子域枚举是渗透测试中至关重要的侦察阶段,其核心价值在于: 增加发现漏洞的概率,服务于渗透测试的成功 子域通常运行着各种应用程序,提供了更多漏洞发现机会 相同漏洞常出现在不同子域中 隐藏子域可能包含关键应用程序,发现后可直击目标核心 子域枚举技术详解 1. 通过搜索引擎枚举 Google语法 : 使用 site:* 操作符查找所有子域 使用 - 排除不感兴趣的子域 适用于所有主流搜索引擎 2. 第三方DNS数据集服务 VirusTotal : 网址:https://www.virustotal.com/gui/home/search 提供比搜索引擎更直观全面的信息 可查找子域、WHOIS等关键信息 DNSdumpster : 网址:https://dnsdumpster.com/ 特色功能:提供可视化映射图 示例映射图URL:https://dnsdumpster.com/static/map/google.com.png 3. 工具枚举 Sublist3r : GitHub:https://github.com/aboul3la/Sublist3r 功能特点: 集成多个搜索引擎(Google/Yahoo/Bing/Ask/Baidu) 使用Netcraft、VirusTotal、ThreatCrowd、DNSdumpster、ReverseDNS 支持爆破和端口扫描 基本用法: 参数说明: -e :指定搜索引擎 -b :启用爆破 -p :指定端口 assetfinder : GitHub:https://github.com/tomnomnom/assetfinder 特点: 跨平台支持良好 执行速度快 简单易用 基本用法: altdns : GitHub:https://github.com/infosec-au/altdns 功能:通过变更和排列发现符合模式的子域 dnsrecon : GitHub:https://github.com/darkoperator/dnsrecon 功能:全面的DNS枚举脚本 4. 证书透明度(Certificate Transparency, CT) CT是记录、审核和监视CA颁发证书的系统,SSL/TLS证书常包含域名、子域等有价值信息。 crt.sh : 网址:https://crt.sh/?q=%25.example.com 提供PostgreSQL接口查询子域 Shell脚本示例: massdns : GitHub:https://github.com/blechschmidt/massdns 编译:在根目录运行 make 支持crt.sh查询: 子域暴力枚举: censys : 网址:https://censys.io/ 类似Shodan的搜索引擎,用于信息侦察 需要注册获取API密钥:https://censys.io/register 设置环境变量: 相关工具: censys-subdomain-finder:https://github.com/christophetd/censys-subdomain-finder censys-enumeration:https://github.com/0xbharath/censys-enumeration 5. 自治系统/自治域(AS)枚举 自治系统(AS)是一个或多个实体管辖下的IP网络和路由器的组合。 相关资源: RFC 1930:https://tools.ietf.org/html/rfc1930 IANA AS编号分配:https://www.iana.org/assignments/as-numbers/as-numbers.xhtml 工具和服务: ASN查询:https://asn.cymru.com/cgi-bin/whois.cgi UltraTools ASN信息:https://www.ultratools.com/tools/asnInfo Nmap ASN脚本: 实战案例:从子域枚举到XSS漏洞发现 使用crt.sh查找多级子域 通过证书透明度数据发现潜在目标 assetfinder配合httprobe枚举子域 发现目标:https://client-beta.global.chalet.8x8.com/ dirsearch目录探测 GitHub:https://github.com/maurosoria/dirsearch 用于发现网站目录结构 Arjun查找隐藏参数 GitHub:https://github.com/s0md3v/Arjun 用于发现未公开的URL参数 XSS漏洞利用 Payload: "> 通过参数注入实现反射型XSS 参考资源 工具集合 Sublist3r:https://github.com/aboul3la/Sublist3r assetfinder:https://github.com/tomnomnom/assetfinder altdns:https://github.com/infosec-au/altdns dnsrecon:https://github.com/darkoperator/dnsrecon massdns:https://github.com/blechschmidt/massdns censys-subdomain-finder:https://github.com/christophetd/censys-subdomain-finder censys-enumeration:https://github.com/0xbharath/censys-enumeration 学习资料 子域枚举艺术:https://github.com/appsecco/the-art-of-subdomain-enumeration 渗透测试者子域枚举指南:https://hakin9.org/a-penetration-testers-guide-to-subdomain-enumeration/ 证书透明度详解:https://blog.appsecco.com/certificate-transparency-the-bright-side-and-the-dark-side-8aa47d9a6616 ASN基础知识:https://en.wikipedia.org/wiki/Autonomous_ system_ (Internet) 在线服务 VirusTotal:https://www.virustotal.com/gui/home/search DNSdumpster:https://dnsdumpster.com/ crt.sh:https://crt.sh/ censys:https://censys.io/ ASN查询:https://asn.cymru.com/cgi-bin/whois.cgi 通过系统性地应用这些技术和工具,安全研究人员可以有效地枚举目标组织的子域,进而发现潜在的安全漏洞。