首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >渗透测试中的域名收集:方法与自动化工具指南

渗透测试中的域名收集:方法与自动化工具指南

作者头像
qife122
发布2025-11-13 16:54:06
发布2025-11-13 16:54:06
1240
举报

在渗透测试中,我们需要尽可能多地收集目标信息。资产发现与信息收集的完整度,直接决定了发现安全漏洞的可能性。如何最大化目标收集范围,尽可能多地收集更全的子域名及相关域名信息,对我们后续的渗透测试工作至关重要。

1. 什么是域名?

域名,又称网络域,是互联网上计算机或计算机组的名称,由一串用点分隔的字符组成,用于在数据传输时定位计算机(有时也指地理位置)。

由于IP地址不易记忆,且无法显示地址组织的名称和性质,人们设计了域名,并通过域名系统(DNS)实现域名与IP地址的相互映射,使得人们更方便地访问互联网,而无需记住机器可直接读取的IP地址字符串。

2. 主域名收集

第一步是确定目标主域名。我们可以通过百度、谷歌等搜索引擎直接搜索目标名称(推荐谷歌)。通常可以直接得到目标的官方网站,从而获取目标的主域名,也可以通过该篇文章的方法Domain Collector高效域名收集工具收集尽量多的主域名。有了主域名,我们就可以开始下一步工作。

2.1 Google Hacking

Google Hacking 是一种利用谷歌搜索引擎及其他谷歌应用来查找网站安全漏洞的技术。该技术主要利用谷歌的高级搜索运算符,例如:sitefiletypeinurlintext 等。

2.2 Whois 查询

Whois(发音为“Who is”,并非缩写)是一种用来查询域名IP及所有者的传输协议。简言之,whois就是一个用来查询域名是否已被注册、以及已注册域名的域名持有人及域名注册商信息的工具。早期的whois查询多以命令行界面存在,现如今出现了一些网页界面简化的在线查询工具,可以一次向不同的数据库查询。网页界面查询工具仍然依赖whois协议向服务器发送查询请求,命令行界面工具仍然被系统管理员广泛使用。Whois通常使用TCP协议43端口。每个域名/IP的whois信息由对应的管理机构保存。

在线查询网站示例:

  • http://whois.chinaz.com
  • https://whois.aizhan.com
  • https://whois.cnnic.cn
  • https://www.whois365.com
  • https://whois.cloud.tencent.com
  • https://whois.aliyun.com
  • http://whois.bugscaner.com

2.3 SSL证书查询

SSL证书遵循SSL协议,由受信任的数字证书颁发机构(CA)在验证服务器身份后颁发,具有服务器身份验证和数据传输加密功能。通过查询共享SSL证书的网站,可以找到其他相关域名,或查询IP地址的归属。

2.4 通过网站页面搜索

通过搜索网站的主营业务介绍、友情链接和JS文件,获取更多域名。

2.5 从APK中提取域名

APK中存在一些域名和IP地址,可以通过反编译搜索域名。

2.6 漏洞众测平台 & SRC

一些在漏洞平台上进行众测或拥有SRC的厂商,会在漏洞赏金项目规则中列出其测试范围,其中包含大量域名。我们可以通过收集这些项目中列出的域名来完善资产收集。

例如:TECNO Web安全漏洞奖励计划

3. 子域名收集

3.1 证书透明度(Certificate Transparency)

证书透明度(CT)是一个实验性的IETF开源标准和开源框架,旨在监控和审计数字证书。通过证书日志、监控和审计系统,证书透明度使网站用户和域名持有者能够识别不当或恶意颁发的证书,以及数字证书颁发机构(CA)的行为。

相关网站:

  • https://crt.sh/
  • https://censys.io/certificates
  • https://sslmate.com/certspotter/api/
  • https://www.entrust.com/ct-search/
  • https://developers.facebook.com/tools/ct
  • https://transparencyreport.google.com/https/certificates

3.2 DNS公共数据集

DNS公共数据集是域名系统(DNS)查询和响应数据的集合,通常公开发布用于研究、教育、分析和开发目的。DNS是互联网的核心组件,它将人类可读的域名(如 example.com)转换为机器可读的IP地址(如 192.0.2.1)。公共DNS数据集可以帮助研究人员和开发人员更好地理解DNS的行为和性能、检测和防御网络攻击、优化网络基础设施。

相关网站:

  • https://hackertarget.com/find-dns-host-records/
  • https://www.robtex.com/dns-lookup/
  • https://searchdns.netcraft.com/
  • https://dnsdumpster.com/
  • http://www.sitedossier.com/
  • https://www.circl.lu/services/passive-dns/#passive-dns

3.3 第三方在线平台

可以通过一些第三方在线平台(如威胁情报平台)收集子域名。

  • https://www.virustotal.com/
  • https://bevigil.com/osint-api
  • https://www.threatminer.org/index.php
  • http://tool.chinaz.com/subdomain/?domain=
  • https://rapiddns.io/subdomain/example.com#result
  • https://x.threatbook.com/
  • https://otx.alienvault.com/
  • https://community.riskiq.com/
  • https://www.threatminer.org/
  • https://securitytrails.com/dns-trails

3.4 搜索引擎

搜索引擎在爬取互联网后,通常会收集大量子域名。我们只需输入相应的语法,即可从搜索引擎数据库中查询所需内容。

Google搜索:可以在Google上使用 site 语法收集子域名。

空间搜索引擎

- https://fofa.info/

- https://www.zoomeye.org/

- https://www.shodan.io/

- https://quake.360.net/

- https://hunter.qianxin.com/

3.5 DNS域传输(Zone Transfer)

DNS服务器分为主服务器、备份服务器和缓存服务器。

域传输是指备份服务器从主服务器复制数据,然后更新自己的数据库,以达到数据同步的目的。这是为了增加冗余性,一旦主服务器出现问题,备份服务器可以直接接管。

域传输漏洞是由于DNS配置不当,导致匿名用户能够获取某个域的所有记录,造成整个网络拓扑泄露给潜在攻击者。攻击者凭借这份网络蓝图,可以节省大量扫描时间,并提高攻击目标的准确性。

3.6 子域名枚举(爆破)

子域名枚举爆破是通过不断拼接字典中的子域名前缀来枚举域名的A记录,例如将 example.com 拼接前缀 test 形成 test.example.com,然后进行验证。但这种方法通常需要解决泛解析问题。

收集方法:获取一些常见的子域名前缀后,整理成字典,通过域名爆破工具进行枚举。

3.7 构造域名

我们通过各种收集方法获得了大量子域名,但这就是全部了吗?当然不是!

我们可以通过替换的方式生成一批域名。例如,我们收集到了 admin.aaa.xxx.com,那么是否存在 dev-admin.aaa.xxx.com

通过这种方式生成一批,然后验证存活率,结果肯定会更全面。欢迎尝试并反馈。

4. 自动化工具

通过前面手动操作部分,我们可以看到大部分收集步骤都是重复性工作。如果将所有手动操作自动化并整合到一个工具中,势必会事半功倍。下面我们来看看自动化工具。

4.1 JSINFO-SCAN

地址:https://github.com/p1g3/JSINFO-SCAN

简介:一个用于递归爬取域名(netloc/domain)以及从JS中递归获取信息的工具。

4.2 bbscope

地址:https://github.com/sw33tLie/bbscope

简介:适用于HackerOne、Bugcrowd、Intigriti、Immunefi和YesWeHack的终极范围收集工具。

安装与使用示例

代码语言:javascript
复制
# Installation
GO111MODULE=on go install GitHub.com/sw33tLie/bbscope@latest
# Usage
# Collect all range of Android APK from HackerOne
bbscope HackerOne -t <YOUR_TOKEN> -u <YOUR_H1_USERNAME> -o t -c android 
# Collect all valid URLs in the scope from HackerOne
bbscope HackerOne -t <YOUR_TOKEN> -u <YOUR_HackerOne_USERNAME> -b -a -o t -c url | sort -u | anew HackerOne_url.txt
# Collect private projects)
bbscope HackerOne -t <YOUR_TOKEN> -u <YOUR_H1_USERNAME> -b -p -o t -c all
# Collect Bugcrowd assets, same as HackerOne command
bbscope Bugcrowd -t <YOUR_TOKEN> -b -o t 
bbscope Bugcrowd -t <YOUR_TOKEN> -b -o t -c url
bbscope Bugcrowd -t <YOUR_TOKEN> -b -o t -c android
bbscope Bugcrowd -t <YOUR_TOKEN> -b -p -o t -c url
# Collect Intigriti assets
bbscope Intigriti -t <YOUR_TOKEN> -b -o t 
bbscope Intigriti -t <YOUR_TOKEN> -b -o t -c url
bbscope Intigriti -t <YOUR_TOKEN> -b -o t -c android
bbscope Intigriti -t <YOUR_TOKEN> -b -p -o t -c url
# Collect YesWeHack assets
bbscope YesWeHack -t <YOUR_TOKEN> -b -o t 
bbscope YesWeHack -t <YOUR_TOKEN> -b -o t -c url
bbscope YesWeHack -t <YOUR_TOKEN> -b -o t -c android
bbscope YesWeHack -t <YOUR_TOKEN> -b -p -o t -c url
# Collect Immunefi assets
bbscope Immunefi -b -o t 
代码语言:javascript
复制
Usage:
  bbscope h1 [flags]
  bbscope h1 [command]
Available Commands:
  Hacktivist  HackerOne Activity
Flags:
  -a, --active-only         Show only active programs
  -c, --categories string   Scope categories, comma separated (Available: all, url, cidr, mobile, android, apple, ai, other, hardware, code, executable) (default "all")
      --concurrency int     Concurrency of HTTP requests sent for fetching data (default 3)
  -h, --help                help for h1
      --public-only         Only print scope for public programs
  -t, --token string        HackerOne API token, get it here: https://hackerone.com/settings/api_token/edit
  -u, --username string     HackerOne username
Global Flags:
  -b, --bbpOnly            Only fetch programs offering monetary rewards (by default private programs are included)
      --config string      config file (default is $HOME/.bbscope.yaml)
  -d, --delimiter string   Delimiter character used when printing multiple data using the output flag (default " ")
  -l, --loglevel string    Set log level. Available: debug, info, warn, error, fatal (default "info")
      --oos                Also print out of scope items with [OOS] - Intigriti only for now
  -o, --output string      Output flags. Supported: t (target), d (target description), c (category), u (program URL). Can be combined. Example: -o tdu (default "t")
      --proxy string       HTTP Proxy (Useful for debugging. Example: http://127.0.0.1:8080)
  -p, --pvtOnly            Only fetch data from private programs

4.3 AppInfoScanner

地址:https://github.com/kelvinBen/AppInfoScanner

简介:适用于HW行动/红队/渗透测试团队场景的移动端(Android、iOS、WEB、H5、静态网站)信息收集扫描工具,可帮助渗透测试工程师、攻击队成员、红队成员快速收集到移动端或静态WEB站点中关键资产信息,并输出基本信息,如:Title、Domain、CDN、指纹信息、状态信息等。

代码语言:javascript
复制
# Download and install
git clone https://github.com/kelvinBen/AppInfoScanner.git
cd AppInfoScanner
pip3 install -r requirements.txt
# Usage
# Scan the APK files and DEX files of Android applications, the download address of the APK files to be downloaded, and the directory where the files to be scanned are saved
python app.py android -i <Your APK File or DEX File or APK Download Url or Save File Dir>
# Scan the IPA files and Mach-o files of iOS applications, the download address of the IPA files to be downloaded, and the directory of files to be scanned
python app.py ios -i <Your IPA file or Mach-o File or IPA Download Url or Save File Dir>
# Scan the files, directories, and URLs of websites that need to be cached
python app.py web -i <Your Web file or Save Web Dir or Web Cache Url>

4.4 OneForAll

地址:https://github.com/shmilylty/OneForAll

简介:它解决了大多数传统子域名收集工具功能不够强大、不够人性化、缺少维护、效率低等痛点。它是一个集百家之长,功能强大的全面快速子域名收集终极工具。

代码语言:javascript
复制
# install
git clone https://gitee.com/shmilylty/OneForAll.git
cd OneForAll && pip3 install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
# usage
python3 oneforall.py version
python3 oneforall.py check
python3 oneforall.py --target example.com run
python3 oneforall.py --targets ./domains.txt run
python3 oneforall.py --target example.com --alive False run
python3 oneforall.py --target example.com --brute False run
python3 oneforall.py --target example.com --port medium run
python3 oneforall.py --target example.com --fmt csv run
python3 oneforall.py --target example.com --dns False run
python3 oneforall.py --target example.com --req False run
python3 oneforall.py --target example.com --takeover False run
python3 oneforall.py --target example.com --show True run

4.5 Amass

地址:https://github.com/OWASP/Amass

简介:Amass是OWASP的开源项目。该工具使用Go语言开发,它可以通过遍历数据源和Web文档来爬取信息,或者使用IP地址搜索相关的网络块和ASN,并利用所有收集到的信息来构建目标网络拓扑。

代码语言:javascript
复制
# install
go install -v github.com/owasp-amass/amass/v4/...@master
# usage
amass enum -passive -d example.com

4.6 Subfinder

地址:https://github.com/projectdiscovery/subfinder

简介:Subfinder是一个子域名发现工具,它通过使用被动的在线资源来发现网站的有效子域名。它具有简单的模块化架构,并针对速度进行了优化。Subfinder的构建目的只有一个——被动子域名枚举,并且做得很好。

代码语言:javascript
复制
# install
go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest
# usage
# Single domain name
subfinder -d domain -all
# Bulk domain names
subfinder -dL domain.txt -all  
# -exclude-sources:This option enables you to exclude certain passive sources from domain enumeration
subfinder -exclude-sources:virustotal -d example.com
# -max-time: Set a new timeout when waiting for subdomain enumeration results (default is 10)
subfinder -max-time 1 -d example.com
# -o: Output is saved in an external file
subfinder -d example.com -o output.txt
# -oJ: Set the output to JSON format
subfinder -dL domain.txt -o output.json -oJ -nW
# -nW: This parameter is absolutely necessary if you use the JSON output we mentioned. It enables domain parsing and ensures efficient searching of this format.
# List all configurable sources
subfinder -ls  

4.7 GitHub-subdomains

地址:https://github.com/gwen001/github-subdomains

简介:通过在GitHub上执行搜索并解析结果,查找给定域名的子域名。

代码语言:javascript
复制
# install
go install github.com/gwen001/github-subdomains@latest
#usage
github-subdomains -d example.com -t github_token

4.8 ksubdomain

地址:https://github.com/boy-hack/ksubdomain

简介:ksubdomain是一款无状态子域名爆破工具,支持在Windows/Linux/Mac上使用,它可以快速进行DNS爆破。在Mac和Windows上理论发包速度最高为30w/s,在Linux上为160w/s。

代码语言:javascript
复制
# install
go install -v github.com/boy-hack/ksubdomain/cmd/ksubdomain@latest
# usage
# Verification mode
# Read from file
./ksubdomain verify -f subdomain.txt
# Read from stdin
echo "www.example.com"|./ksubdomain verify --stdin
# Enumeration Mode
./ksubdomain enum -d baidu.com
# Get from stdin
echo "example.com"|./ksubdomain enum --stdin

4.9 massdns

地址:https://github.com/blechschmidt/massdns

简介:MassDNS是一个简单的高性能DNS存根解析器,专为希望解析数百万甚至数十亿域名的用户设计。无需特殊配置,MassDNS能够使用公共解析器每秒解析超过35万个域名。

代码语言:javascript
复制
# install
▶Run : git clone https://github.com/blechschmidt/massdns.git
▶Run : cd massdns
▶Run : make
▶Run : sudo make install
▶Run (Check/Usage) : massdns -h
# usage
# Parse the A record of the domain name and output it to the document
massdns -r lists/resolvers.txt -t A domains.txt > results.txt
massdns -r lists/resolvers.txt -t A -w results.txt domains.txt
massdns --resolvers ./resolvers.txt --output J --outfile ./out.json ./domains.txt

4.10 shuffleDNS

地址:https://github.com/projectdiscovery/shuffledns

简介:shuffleDNS是一个用go编写的massdns包装器,它允许您使用主动暴力破解来枚举有效的子域名,并使用通配符处理来解析子域名,支持简单的输入和输出。Shuffledns需要安装massdns才能执行其操作。

代码语言:javascript
复制
# install
go install -v github.com/projectdiscovery/shuffledns/cmd/shuffledns@latest
# usage
# To batch verify subdomains, you need to be able to identify massdns. Windows configures massdns to the environment variable
shuffledns -l subdomains.txt -r resolvers.txt -mode resolve  
# Subdomain blasting, batch subdomain blasting is not supported
shuffledns -d hackerone.com -w wordlist.txt -r resolvers.txt -mode bruteforce 
# Subdomain blasting output to file
shuffledns -d domains.txt -w wordlist.txt -r resolver.txt -mode bruteforce  | anew sub.txt
# Specify massdns path and output to file
shuffledns -d hackerone.com -w wordlist.txt -m massdns_binary -o output.txt
# Linux uses brute force mode
shuffledns -d domain.txt -w wordlist.txt -r nameservers.txt -mode bruteforce | anew subs.txt | wc -l

4.11 puredns

地址:https://github.com/d3mondev/puredns

简介:快速的域名解析和子域名暴力破解,具备过滤泛解析的功能。同样需要安装massdns才能执行其操作。

代码语言:javascript
复制
# install
go install github.com/d3mondev/puredns/v2@latest
# usage
# PureDNS's resolve command is used to resolve domain names
puredns resolve domain.com
# Parse from file, save to file, and process pan-parse
puredns resolve domains.txt -r resolvers.txt -w valid_result.txt
或 cat domains.txt | puredns resolve
# Quiet mode parsing
puredns resolve domain.com -q 
或 cat domains.txt | puredns resolve -q
# Save the results to a file
puredns resolve -f domains.txt --write valid_domains.txt
# Specify the parser list
puredns resolve domain.com -r resolvers.txt
# Using Linux pipes
puredns resolve subs.txt -r nameservers.txt -w resolved.txt | wc -l

4.12 AlterX

地址:https://github.com/projectdiscovery/alterx

简介:Altdns是一款子域名发现工具,它利用排列扫描技术,通过已知域名或子域名的排列、变形和组合来识别新的子域名。

代码语言:javascript
复制
# install
go install github.com/projectdiscovery/alterx/cmd/alterx@latest
# usage
alertx -l www.example.com
alterx -list example.com -enrich -p '{{word}}-{{year}}.{{suffix}}' -pp word=keywords.txt -pp year=2023

4.13 cdnCheck

地址:https://github.com/damit5/cdnCheck_go

简介:使用 github.com/projectdiscovery/cdncheck,通过ASN、CIDR、CNAME快速批量判断目标是否存在CDN,并保存不存在于CDN的域名和IP。

代码语言:javascript
复制
# install
go install github.com/damit5/cdnCheck_go@latest
# usage
Usage of cdnCheck_go.exe:
  -as string
        All the mappings between domain names and IP addresses can be left blank if not saved
  -nd string
        There is no CDN domain name to save the address, just leave it blank if you don’t want to save it
  -ni string
        There is no CDN IP address to save, just leave it blank if you don’t want to save it
  -t string
        Documents to be scanned
  -thread int
        Concurrency (default 20)
.\cdnCheck_go.exe -t ..\all_subdomain_result.txt -nd nocdndomain.txt -ni nocdnip.txt -as domainip.txt

4.14 httpx

地址:https://github.com/projectdiscovery/httpx

简介:httpx是一个快速且多功能的HTTP工具包。

代码语言:javascript
复制
# install
go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest
# Common commands
# Get title, length, status code
httpx -title -content-length -status-code
# Request a single URL
httpx -u https://example.com
# Read a list of URLs from a file
httpx -l urls.txt
# Output the results to a file
httpx -u https://example.com -o output.txt
# Output the results in JSON format
httpx -u https://example.com -json output.json
# Status code filtering
httpx -u https://example.com -mc 200,302
# Skip SSL verification
httpx -u https://example.com -tls-skip-verify
# Display the status code, title, body length, and 301 redirect address
httpx -u https://example.com -l url.txt -sc -title -cl -location

4.15 Ehole

地址:https://github.com/EdgeSecurityTeam/EHole

简介:Ehole是一款对资产中重点系统指纹识别的工具。在红队行动中,信息收集是重要的环节,如何才能从大量的资产中提取有用的系统(如OA、VPN、Web Logic...)?Ehole就是为了帮助红队人员在信息收集期间能够快速从C段、大量杂乱的资产中定位重点系统,从而实施进一步攻击。

代码语言:javascript
复制
# Install, download binary files and configure them into environment variables
https://github.com/EdgeSecurityTeam/EHole/releases
# Common commands
# Fingerprinting a single URL or IP address
ehole finger -u http://example.com
# Batch identify and specify output files to json
ehole finger -l urls.txt -o output.json
# Batch identify and specify output files to xlsx
ehole finger -l urls.txt -o output.xlsx
# Output detailed information
ehole finger -l urls.txt -v

5. 总结

本文介绍了信息收集中域名收集的一些方式。大体的流程是,先收集公司关联的所有主域,再收集所有主域的子域。

收集子域的最佳方式是使用工具自动收集。虽然域名收集的自动化工具有很多,但实际上并没有一款很好的工具能够完整覆盖整体流程,这个时候就需要自己写脚本来完善。

总之,全面收集目标的域名,有助于我们扩大目标的攻击面,发现更多的安全漏洞。如果你有其他更好的方法,也欢迎分享给大家。

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2025-09-23,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 网络安全技术点滴分享 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1. 什么是域名?
  • 2. 主域名收集
    • 2.1 Google Hacking
    • 2.2 Whois 查询
    • 2.3 SSL证书查询
    • 2.4 通过网站页面搜索
    • 2.5 从APK中提取域名
    • 2.6 漏洞众测平台 & SRC
  • 3. 子域名收集
    • 3.1 证书透明度(Certificate Transparency)
    • 3.2 DNS公共数据集
    • 3.3 第三方在线平台
    • 3.4 搜索引擎
    • 3.5 DNS域传输(Zone Transfer)
    • 3.6 子域名枚举(爆破)
    • 3.7 构造域名
  • 4. 自动化工具
    • 4.1 JSINFO-SCAN
    • 4.2 bbscope
    • 4.3 AppInfoScanner
    • 4.4 OneForAll
    • 4.5 Amass
    • 4.6 Subfinder
    • 4.7 GitHub-subdomains
    • 4.8 ksubdomain
    • 4.9 massdns
    • 4.10 shuffleDNS
    • 4.11 puredns
    • 4.12 AlterX
    • 4.13 cdnCheck
    • 4.14 httpx
    • 4.15 Ehole
  • 5. 总结
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档