子域收集总结
什么是子域
子域是域的扩展,通过子域可以方便分类和扩展网页的内容.如 shop.example.com 是 example.com 下负责提供购物功能的一个站点.
为什么要进行子域收集
通过子域收集可以扩大攻击面,这些子域可能没有进行充分的安全评估或者年久失修,更容易存在漏洞,不安全的配置,信息泄露等问题.在这些子域上更加容易发现漏洞.
子域收集的方法
Google Dorking
google 搜索引擎所支持的高级搜索语法,利用 google dorking 可以发现子域

DNS区域转移(DNS Zone Transfers)
DNS Zone Transfers(DNS区域传输)是指一台备用服务器使用主服务器的数据来刷新自己的域数据库,其目的是为了防止主域名服务器因意外故障尔影响到整个域名的解析
当DNS服务器被错误设置成只要有client发出请求,就会向对方提供一个子域数据库的详细信息时,就产生了DNS域传送漏洞
攻击流程:
确定名称解析服务器,如用
nslookup,host等工具1
host -t ns www.owasp.org
NS 代表“域名服务器”,域名服务器记录指示哪个 DNS 服务器对该域具有权威性(即,哪个服务器包含实际 DNS 记录)
向NS申请区域转移
1
host -l domain domainserver
证书透明度(Certificate Transparency)
证书透明度(英语:Certificate Transparency,简称CT)也称证书透明、证书透明化,是一个实验性的IETF开源标准[1]和开源框架,目的是监测和审计数字证书。透过证书日志、监控和审计系统,证书透明度使网站用户和域名持有者可以识别不当或恶意签发的证书,以及识别数字证书认证机构(CA)的行为。
因此可以从存储证书日志的数据库中获得子域信息,这些信息一般存储在 SAN(Subject Alternative Name) 中,这个字段表明其中有多个域名使用同一个证书保护
下面是一个利用 jq 从 https://crt.sh/ 中提取域名的一个命令1
curl -s "https://crt.sh/?q=$DOMAIN&output=json" | jq -r ".[] | .name_value" | sort -u
暴力枚举(brute)
通过字典枚举子域名
Whois反查
whois
用于查询域名的ip和其所有人的相关信息
反向whois
根据其所有人的部分信息反查出域名信息
第三方聚合应用
子域收集工具
subfinder
subfinder -dL targets.txt -all -recursive -silent
nmap
nmap --script hostmap-crtsh.nse baidu.com
从 Google’s Certificate Transparency logs database 中发现子域
nmap -T4 -p 53 --script dns-brute baidu.com
尝试枚举常见子域名
sublist3r
python3 sublist3r -d baidu.com
anew Append lines from stdin to a file, but only if they don’t already appear in the file. Outputs new lines to stdout too, making it a bit like a tee -a that removes duplicates
assetfinder
assetfinder --subs-only domain
findomain
finddomain -t example.com -u targets.txt
amass
amass enum -passive -d example.com | grep example.com
gau
gau --subs tesla.com | cut -d "/" -f 3 | sort -u
oneforall
python3 oneforall --target xxx.com run
python3 oneforall --targets xxx.txt run
httpx
用于检测子域存活情况
cat domains.txt > httpx
DNS字典
- https://gist.github.com/jhaddix/86a06c5dc309d08580a018c66354a056
- https://wordlists-cdn.assetnote.io/data/manual/best-dns-wordlist.txt
- https://localdomain.pw/subdomain-bruteforce-list/all.txt.zip
- https://github.com/pentester-io/commonspeak
- https://github.com/danielmiessler/SecLists/tree/master/Discovery/DNS
对于只能接单域名的工具1
cat targets.txt | while read line ; do <TOOL> | anew domains.txt ; done
对于没有 slicent 输出,只能输出到文件的工具:1
cat targets.txt | while read line ; do randname=$$.txt ; touch $randname ; python3 sublist3r.py -d $line -o $randname ; cat $randname | anew domains.txt ; rm $randname ; done