域名信息收集
域名介绍¶
由于IP地址不方便记忆,且不能显示地址组织的名称和性质。因此人们设计出了域名,并通过网域名称系统(DNS,Domain Name System)来将域名和IP地址相互映射,使人更方便地访问互联网,而不用去记住能够被机器直接读取的IP地址数串。
例:当我们访问www.baidu.com这个域名时,我们的电脑会向DNS查询百度的IP地址。然后我们再通过百度的IP地址进行访问百度。因此我们在输入网址时,实质上也是通过IP地址访问的服务器,只是从域名到IP地址的转换阶段对我们屏蔽了。
域名(Domain Name),简称域名、网域,是由一串用点分隔的名字组成的Internet上某一台计算机或计算机组的名称,用于在数据传输时标识计算机的电子方位(有时也指地理位置)。
DNS(域名系统,Domain Name System)是互联网的一项服务。它作为将域名和IP地址相互映射的一个分布式数据库,能够使人更方便地访问互联网。
域名的分类¶

DNS解析¶
DNS域名解析中添加的各项解析记录¶
A记录: 将域名指向一个IPv4地址(例如:100.100.100.100),需要增加A记录CNAME记录: 如果将域名指向一个域名,实现与被指向域名相同的访问效果,需要增加CNAME记录。这个域名一般是主机服务商提供的一个域名MX记录: 建立电子邮箱服务,将指向邮件服务器地址,需要设置MX记录。建立邮箱时,一般会根据邮箱服务商提供的MX记录填写此记录NS记录: 域名解析服务器记录,如果要将子域名指定某个域名服务器来解析,需要设置NS记录TXT记录: 可任意填写,可为空。一般做一些验证记录时会使用此项,如:做SPF(反垃圾邮件)记录AAAA记录: 将主机名(或域名)指向一个IPv6地址(例如:ff03:0:0:0:0:0:0:c1),需要添加AAAA记录SRV记录: 添加服务记录服务器服务记录时会添加此项,SRV记录了哪台计算机提供了哪个服务。格式为:服务的名字.协议的类型(例如:_example-server._tcp)。SOA记录: SOA叫做起始授权机构记录,NS用于标识多台域名解析服务器,SOA记录用于在众多NS记录中那一台是主服务器PTR记录: PTR记录是A记录的逆向记录,又称做IP反查记录或指针记录,负责将IP反向解析为域名显性URL转发记录: 将域名指向一个http(s)协议地址,访问域名时,自动跳转至目标地址。例如:将www.liuht.cn显性转发到www.itbilu.com后,访问www.liuht.cn时,地址栏显示的地址为:www.itbilu.com。隐性UR转发记录L: 将域名指向一个http(s)协议地址,访问域名时,自动跳转至目标地址,隐性转发会隐藏真实的目标地址。例如:将www.liuht.cn显性转发到www.itbilu.com后,访问www.liuht.cn时,地址栏显示的地址仍然是:www.liuht.cn。
DNS解析中一些问题¶
A记录与CNAME记录¶
A记录是把一个域名解析到一个IP地址,而CNAME记录是把域名解析到另外一个域名,而这个域名最终会指向一个A记录,在功能实现在上A记录与CNAME记录没有区别。
CNAME记录在做IP地址变更时要比A记录方便。CNAME记录允许将多个名字映射到同一台计算机,当有多个域名需要指向同一服务器IP,此时可以将一个域名做A记录指向服务器IP,然后将其他的域名做别名(即:CNAME)到A记录的域名上。
当服务器IP地址变更时,只需要更改A记录的那个域名到新IP上,其它做别名的域名会自动更改到新的IP地址上,而不必对每个域名做更改。
A记录与AAAA记录¶
二者都是指向一个IP地址,但对应的IP版本不同。A记录指向IPv4地址,AAAA记录指向IPv6地址。AAAA记录是A记录的升级版本。
IPv4与IPv6¶
IPv4,是互联网协议(Internet Protocol,IP)的第四版,也是第一个被广泛使用的版本,是构成现今互联网技术的基础协议。IPv4 的下一个版本就是IPv6,在将来将取代目前被广泛使用的IPv4。
IPv4中规定IP地址长度为32位(按TCP/IP参考模型划分) ,即有2^32-1个地址。IPv6的提出最早是为了解决,随着互联网的迅速发展IPv4地址空间将被耗尽的问题。为了扩大地址空间,IPv6将IP地址的长度由32位增加到了128位。在IPv6的设计过程中除了一劳永逸地解决了地址短缺问题以外,还解决了IPv4中的其它问题,如:端到端IP连接、服务质量(QoS)、安全性、多播、移动性、即插即用等。
TTL值¶
生存时间(Time To Live),表示解析记录在DNS服务器中的缓存时间,TTL的时间长度单位是秒,一般为3600秒。
比如:在访问www.itbilu.com时,如果在DNS服务器的缓存中没有该记录,就会向某个NS服务器发出请求,获得该记录后,该记录会在DNS服务器上保存TTL的时间长度,在TTL有效期内访问www.itbilu.com,DNS服务器会直接缓存中返回刚才的记录。
whois¶
是用来查询**域名的IP**以及**所有者**等的信息的传输协议
域名查询网站总收录:
- https://www.chaicp.com/ --ICP
- https://whois.aizhan.com --爱站
- https://whois.chinaz.com --站长
- https://www.virustotal.com --VirusTotal
- https://whois.aliyun.com --原万网
- https://www.whois365.com/cn --全球WHOIS
DNS记录查询总收录:
- https://www.racent.com/dns-check?
- https://www.itdog.cn/dns
- https://ipw.cn/dns/
Whois 简单来说,就是一个用来查询域名是否已经被注册,以及注册域名的详细信息的数据库(如域名所有人、域名注册商、域名注册日期和过期日期等)。通过域名 Whois 服务器查询,可以查询域名归属者联系方式,以及注册和到期时间
下面就是使用域名Whois查询 - 站长之家 (chinaz.com)查询的结果

在kali系统中,whois默认安装了可以直接使用:

whois反查¶
- 方式
(1)根据已知域名反查,分析出此域名的注册人、邮箱、电话等字段;
(2)根据已知域名WHOIS中的注册邮箱来反查得出其它域名WHOIS中注册邮箱与此相同的域名列表;
(3)根据已知域名WHOIS中的注册人来反查得出其它域名WHOIS中注册人与此相同的域名列表;
- 缺点
很多公司都是DNS解析的运行商注册的,查到的是运行商代替个人和公司注册的网站信息
- 可以通过下面的网站进行反查
域名反查:https://whois.chinaz.com/reverse?ddlSearchMode=0
邮箱反查:https://whois.chinaz.com/reverse?ddlSearchMode=1
注册人反查:https://whois.chinaz.com/reverse?ddlSearchMode=2
电话反查:https://whois.chinaz.com/reverse?ddlSearchMode=3
- https://viewdns.info/reversewhois/ - Free
- https://domaineye.com/reverse-whois - Free
- https://www.reversewhois.io/ - Free
- https://www.whoxy.com/ - Free web, not free API.
- http://reversewhois.domaintools.com/ - Not free
- https://drs.whoisxmlapi.com/reverse-whois-search - Not Free (only 100 free searches)
- https://www.domainiq.com/ - Not Free
You can automate this task using DomLink (requires a whoxy API key). You can also perform some automatic reverse whois discovery with amass: amass intel -d tesla.com -whois
Note
you can use this technique to discover more domain names every time you find a new domain.
利用证书透明度收集子域¶
引用谷歌的项目介绍:“要向用户提供加密流量,网站必须先向可信的证书授权中心 (CA) 申请证书。然后,当用户尝试访问相应网站时,此证书即会被提供给浏览器以验证该网站。近年来,由于 HTTPS 证书系统存在结构性缺陷,证书以及签发证书的 CA 很容易遭到入侵和操纵。Google 的证书透明度项目旨在通过提供一个用于监测和审核 HTTPS 证书的开放式框架,来保障证书签发流程安全无虞。”
那么,通过这样的证书透明度项目,我们就可以在其中获取一些有价值的域名。
实现方法:访问以下链接搜索需要查询的域名如:http://tencent.com
(1)crtsh:https://crt.sh/
(2)facebook:https://developers.facebook.com/tools/ct
(3)entrust:https://www.entrust.com/ct-search/
(4)certspotter:https://sslmate.com/certspotter/api/
(5)spyse:https://spyse.com/search/certificate
(6)censys:https://censys.io/certificates
(7)google: https://google.com/transparencyreport/https/ct/
(8)myssl: myssl

- sodan
As you already know the name of the organisation owning the IP space. You can search by that data in shodan using: org:"Tesla, Inc." Check the found hosts for new unexpected domains in the TLS certificate.
You could access the TLS certificate of the main web page, obtain the Organisation name and then search for that name inside the TLS certificates of all the web pages known by shodan with the filter : ssl:"Tesla Motors" or use a tool like sslsearch.
Monitorization¶
You can monitor if new subdomains of a domain are created by monitoring the Certificate Transparency Logs sublert does.
常规检查收集子域¶
为什么要进行子域名收集
- 子域名探测可以帮助我们发现渗透测试中更多的服务,他们在安全评估范围内,从而也就增加了发现漏洞的机会。
- 通常同一组织的不同域名/应用程序中存在相同的漏洞。
- 查找一些用户上较少,被人遗忘的子域名,其上运行的应用程序可能会使我们发现关键漏洞。
域传送¶
域传送操作是指备用服务器向主服务器查询来刷新自己的Zone数据库,保证数据一致性。此操作的目的是为了防止主域名服务器因意外故障变得不可用时影响到全局。
正常情况下,只有在网络里存在备用域名 DNS 服务器时,DNS区域传送操作才有必要执行。一旦DNS服务器被错误地配置成任何人发出请求,都向其提供Zone数据库的拷贝,就会被攻击者利用。
实现方法:
(1) dig命令
(2) python中dns库
xfr = dns.query.xfr(where=server, zone=self.domain, timeout=5.0, lifetime=10.0)
zone = dns.zone.from_xfr(xfr)
(3)dnsrecon
Let's try to get subdomains from the DNS records. We should also try for Zone Transfer (If vulnerable, you should report it).
一般情况下,DNS服务器都配置正确,关闭了dns传输或设置了白名单,漏洞利用成功的概率较低。
站点配置文件¶
信息泄露问题主要就是某域名下的一些文件会存储与其相关的一些域名,如子域名。此类文件包括跨域策略文件crossdomain.xml, sitemap文件。
实现方法:
建立文件列表,拼接域名后直接访问,判断改文件是否存在。若存在则提取数据,若不存在则跳过。
(1) crossdomain.xml文件
直接访问crossdomain.xml路径
(2) sitemap文件
直接访问sitemap.xml、sitemap.txt、sitemap.html、sitemap*index.xml、sitemap*index.xml路径
文件往往不存在,即使存在,域名信息也不够多不够完全。
检查内容安全策略¶
内容安全策略(CSP,Content Security Policy)是一种声明的安全机制,可以让网站运营者能够控制遵循CSP的用户代理(通常是浏览器)的行为。通过控制要启用哪些功能,以及从哪里下载内容,可以减少网站的攻击面。
CSP的主要目的是防御跨站点脚本(cross-ste scripting,XSS)攻击。例如,CSP可以完全禁止内联的JavaScript,并且控制外部代码从哪里加载。它也可以禁止动态代码执行。禁用了所有的攻击源,XSS攻击变得更加困难。
CSP中的关键字有default-src、img-src、object-src和script-src。其中*-src可能会存在域名信息。
实现方法:
(1) 手动抓包获取
HTTP header的Content-Security-Policy属性
利用DNS查询收集子域¶
通过枚举常见的SRV记录并做查询来收集子域srv,以及通过查询域名的DNS记录中的MX,NS,SOA,TXT记录来收集子域。
SRV记录: 添加服务记录服务器服务记录时会添加此项,SRV记录了哪台计算机提供了哪个服务。格式为:服务的名字.协议的类型(例如:*example-server.*tcp)。
以下命令枚举给定域名的SRV记录:

MX记录: 建立电子邮箱服务,将指向邮件服务器地址,需要设置MX记录。建立邮箱时,一般会根据邮箱服务商提供的MX记录填写此记录。

NS记录: 域名解析服务器记录,如果要将子域名指定某个域名服务器来解析,需要设置NS记录。

SOA记录: SOA叫做起始授权机构记录,NS用于标识多台域名解析服务器,SOA记录用于在众多NS记录中那一台是主服务器。

TXT记录: 可任意填写,可为空。一般做一些验证记录时会使用此项,如:做SPF(反垃圾邮件)记录。

Favicon¶
Did you know that we can find related domains and sub domains to our target by looking for the same favicon icon hash? This is exactly what favihash.py tool made by @m4ll0k2 does. Here’s how to use it:
cat my_targets.txt | xargs -I %% bash -c 'echo "http://%%/favicon.ico"' > targets.txt
# my_targets.txt include all the domains
python3 favihash.py -f https://target/favicon.ico -t targets.txt -s

favihash - discover domains with the same favicon icon hash
Simply said, favihash will allow us to discover domains that have the same favicon icon hash as our target.
Moreover, you can also search technologies using the favicon hash as explained in this blog post. That means that if you know the hash of the favicon of a vulnerable version of a web tech you can search if in shodan and find more vulnerable places:
shodan search org:"Target" http.favicon.hash:<hash> --fields ip_str,port --separator " " | awk '{print $1":"$2}'
This is how you can calculate the favicon hash of a web:
import mmh3
import requests
import codecs
def fav_hash(url):
response = requests.get(url)
favicon = codecs.encode(response.content,"base64")
fhash = mmh3.hash(favicon)
print(f"{url} : {fhash}")
return fhash
Copyright / Uniq string¶
Search inside the web pages strings that could be shared across different webs in the same organisation. The copyright string could be a good example. Then search for that string in google, in other browsers or even in shodan: shodan search http.html:"Copyright string"
CRT Time¶
It's common to have a cron job such as
to renew the all the domain certificates on the server. This means that even if the CA used for this doesn't set the time it was generated in the Validity time, it's possible to find domains belonging to the same company in the certificate transparency logs. Check out this writeup for more information.
Note
企业通常会通过自动化手段进行证书的renew,这就导致同一批的证书开始时间几乎相同,所以我们可以搜索证书的开始时间(延迟几秒)来获得更多子域名
Mail DMARC information¶
You can use a web such as https://dmarc.live/info/google.com or a tool such as https://github.com/Tedixx/dmarc-subdomains to find domains and subdomain sharing the same dmarc information.
Passive Takeover¶
Apparently is common for people to assign subdomains to IPs that belongs to cloud providers and at some point lose that IP address but forget about removing the DNS record. Therefore, just spawning a VM in a cloud (like Digital Ocean) you will be actually taking over some subdomains(s).
This post explains a store about it and propose a script that spawns a VM in DigitalOcean, gets the IPv4 of the new machine, and searches in Virustotal for subdomain records pointing to it.
使用工具进行子域名查询¶
kali自带工具¶
(1)Dnsenum:域名信息收集
Dnsenum的目的是尽可能收集一个域的信息,它能够通过谷歌或者字典文件猜测可能存在的域名,并对一个网段进行反向查询。
它不仅可以查询网站的主机地址信息、域名服务器和邮件交换记录,还可以在域名服务器上执行axfr请求,然后通过谷歌脚本得到扩展域名信息,提取子域名并查询,最后计算C类地址并执行whois查询,执行反向查询,把地址段写入文件
(2)Dnsmap:收集信息和枚举DNS信息
Dnsmap主要用来收集信息和枚举DNS信息,信息的收集面较多
(3)Dnsrecon:用于DNS侦察
As you have found all the IP ranges of the domains you could try to perform reverse dns lookups on those IPs to find more domains inside the scope. Try to use some dns server of the victim or some well-known dns server (1.1.1.1, 8.8.8.8)
dnsrecon -r <DNS Range> -n <IP_DNS> #DNS reverse of all of the addresses
dnsrecon -d facebook.com -r 157.240.221.35/24 #Using facebooks dns
dnsrecon -r 157.240.221.35/24 -n 1.1.1.1 #Using cloudflares dns
dnsrecon -r 157.240.221.35/24 -n 8.8.8.8 #Using google dns
For this to work, the administrator has to enable manually the PTR. You can also use a online tool for this info: http://ptrarchive.com/
(4)Fierce :子域名查询
测试区域传输漏洞和子域名暴力破解,进行子域名列表查询
osint¶
The fastest way to obtain a lot of subdomains is search in external sources. The most used tools are the following ones (for better results configure the API keys):
# subdomains
bbot -t tesla.com -f subdomain-enum
# subdomains (passive only)
bbot -t tesla.com -f subdomain-enum -rf passive
# subdomains + port scan + web screenshots
bbot -t tesla.com -f subdomain-enum -m naabu gowitness -n my_scan -o .
amass enum [-active] [-ip] -d tesla.com
amass enum -d tesla.com | grep tesla.com # To just list subdomains
# Subfinder, use -silent to only have subdomains in the output
./subfinder-linux-amd64 -d tesla.com [-silent]
# findomain, use -silent to only have subdomains in the output
./findomain-linux -t tesla.com [--quiet]
theHarvester -d tesla.com -b "anubis, baidu, bing, binaryedge, bingapi, bufferoverun, censys, certspotter, crtsh, dnsdumpster, duckduckgo, fullhunt, github-code, google, hackertarget, hunter, intelx, linkedin, linkedin_links, n45ht, omnisint, otx, pentesttools, projectdiscovery, qwant, rapiddns, rocketreach, securityTrails, spyse, sublist3r, threatcrowd, threatminer, trello, twitter, urlscan, virustotal, yahoo, zoomeye"
There are other interesting tools/APIs that even if not directly specialised in finding subdomains could be useful to find subdomains, like:
- Crobat: Uses the API https://sonar.omnisint.io to obtain subdomains
# Get list of subdomains in output from the API
## This is the API the crobat tool will use
curl https://sonar.omnisint.io/subdomains/tesla.com | jq -r ".[]"
- RapidDNS free API
# Get Domains from rapiddns free API
rapiddns(){
curl -s "https://rapiddns.io/subdomain/$1?full=1" \
| grep -oE "[\.a-zA-Z0-9-]+\.$1" \
| sort -u
}
rapiddns tesla.com
# Get Domains from crt free API
crt(){
curl -s "https://crt.sh/?q=%25.$1" \
| grep -oE "[\.a-zA-Z0-9-]+\.$1" \
| sort -u
}
crt tesla.com
- gau: fetches known URLs from AlienVault's Open Threat Exchange, the Wayback Machine, and Common Crawl for any given domain.
- SubDomainizer & subscraper: They scrap the web looking for JS files and extract subdomains from there.
# Get only subdomains from SubDomainizer
python3 SubDomainizer.py -u https://tesla.com | grep tesla.com
# Get only subdomains from subscraper, this already perform recursion over the found results
python subscraper.py -u tesla.com | grep tesla.com | cut -d " " -f
# Get info about the domain
shodan domain <domain>
# Get other pages with links to subdomains
shodan search "http.html:help.domain.com"
export CENSYS_API_ID=...
export CENSYS_API_SECRET=...
python3 censys-subdomain-finder.py tesla.com
- securitytrails.com has a free API to search for subdomains and IP history
- chaos.projectdiscovery.io
This project offers for free all the subdomains related to bug-bounty programs. You can access this data also using chaospy or even access the scope used by this project https://github.com/projectdiscovery/chaos-public-program-list
You can find a comparison of many of these tools here: https://blog.blacklanternsecurity.com/p/subdomain-enumeration-tool-face-off
第三方网站查询:¶
- https://rapiddns.io/subdomain
- https://dnsdumpster.com/
- https://phpinfo.me/domain/
利用DNS数据集收集子域¶
利用DNS记录公开数据收集
加粗的是我们认为效果较好的
(1)ip138:https://site.ip138.com//domain.htm (2)百度云观测:http://ce.baidu.com/index/getRelatedSites?site_address= (3)hackertarget:https://hackertarget.com/find-dns-host-records/ (4)riddler:https://riddler.io/search?q=pld: (5)bufferover:https://dns.bufferover.run/dns?q= (6)dnsdb:https://dnsdb.io/zh-cn/search?q= (7)ipv4info:http://ipv4info.com/ (8)robtex:https://www.robtex.com/dns-lookup/ (9)chinaz:https://alexa.chinaz.com/ (10)netcraft:https://searchdns.netcraft.com/ (11)dnsdumpster:https://dnsdumpster.com/ (12)sitedossier:http://www.sitedossier.com/ (13)findsubdomains:https://findsubdomains.com/
(14)virustotal:https://www.virustotal.com/gui/home/upload
利用威胁情报平台数据收集子域¶
以下平台均需注册,注册后免费试用)
- (1) https://otx.alienvault.com/api/v1/indicators/domain/{domain}/{section}指其他指令动作,可参考Docs关于API的使用说明。
- https://otx.alienvault.com/api/v1/indicators/domain/qq.com/url_list
- (2) https://community.riskiq.com/search//subdomains
- (3) https://x.threatbook.cn/nodev4/domain/
- API:https://api.threatbook.cn/v3/domain/sub_domains
- (4) https://www.threatminer.org/domain.php?q={domain}
- (5) https://www.virustotal.com/ui/domains/{domain}/subdomains
- 或者https://www.virustotal.com/gui/domain/{domain}/relations
- (6) https://pentest-tools.com/information-gathering/find-subdomains-of-domain#
利用搜索引擎发现子域¶
- site
当使用site提交查询时,**Google会将查询限制在某个网站/某个域下面进行,此时配合其他指令效果更佳,**如使用减号“-”来排除不想要搜集到的域名。

- Site:x.x.x.*
当我们获取到了子域名的真实ip后,可以尝试搜索site:x.x.x.* 进行C段搜索,通过这种方法也能找出很多有价值的其他相关域名。经笔者尝试,这种方法在搜狗、谷歌搜索引擎上使用有效,谷歌搜索引擎效果更好。

| 语法 | 解释 | 使用方法 |
|---|---|---|
| intext | 寻找正文中含有关键字的网页 | intext: 成都信息工程大学 |
| intile | 寻找标题中含有关键字的网页 | intitle: 成都信息工程大学 |
| allintitle | 指定多个关键词 | allintititle: keywords |
| info | 返回站点的指定信息 | info: www.baidu.com |
| inurl | 寻找url中含有关键词的网页 | inurl: keywords |
GHDB谷歌黑客数据库¶
链接:https://www.exploit-db.com/google-hacking-database/
这是全世界的黑客朋友们自发维护的一个汇集着各种已经被优化的查询语句的数据库,每天都在不断地更新各种好用有效的Google查询语句。
域名备案搜集资产¶
在对一些大型的目标进行信息搜集时,还可以**通过查找域名备案信息来发现同备案的其他域名资产。**如搜集qq的子域名时,最常见的即为对http://qq.com进行子域名搜集,此时就会遗漏其余顶级域名资产。
查询网址:www.beianbeian.com


如上图通过查询http://qq.com的网站备案/许可证号,再对其进行反查,即可发现http://qq.com同备案的其他顶级域名资产。
通过域名备案查找同备案的其他域名资产,能够更全面的搜集目标资产信息,提升发现漏洞的概率。
whois查询和关联查询¶
在此我们以http://facebook.com做演示,如何进行whois查询和反查
(1) 查询whois
http://whois.chinaz.com/facebook.com

(2) 反查whois
http://whois.chinaz.com/reverse?host=**in@fb.com&ddlSearchMode=1&domain=facebook.com

获得关联域名信息。
域名爆破¶
爆破的原理其实是通过枚举的方式来实现的,通过不断的拼接字典中的内容去枚举域名的A记录,但是该方法一般需要解决泛解析问题。
比如开源工具oneforall会首先访问一个随机的并不存在的域,通过返回结果判断是否存在泛解析,确定存在泛解析以后,程序会开始不断的循环产生随机域名,去向服务器查询,将每次查询到的IP和TTL记录下来,直到大部分的IP地址出现次数都大于两次,则IP黑名单的收集结束,在得到了IP黑名单以后,oneforall接下来会将自己的字典中的每一项和要指定查询的域名进行拼接。
在爆破过程中根据IP黑名单进行过滤。但这种宽泛的过滤容易导致漏报,所以oneforall将 TTL 也作为黑名单规则的一部分,评判的依据是:在权威 DNS 中,泛解析记录的 TTL 肯定是相同的,如果子域名记录相同,但 TTL 不同,那这条记录可以说肯定不是泛解析记录。
First DNS Brute-Force Round¶
Let's try to find new subdomains brute-forcing DNS servers using possible subdomain names.
For this action you will need some common subdomains wordlists like:
- 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
And also IPs of good DNS resolvers. In order to generate a list of trusted DNS resolvers you can download the resolvers from https://public-dns.info/nameservers-all.txt and use dnsvalidator to filter them. Or you could use: https://raw.githubusercontent.com/trickest/resolvers/main/resolvers-trusted.txt
The most recommended tools for DNS brute-force are:
- massdns: This was the first tool that performed an effective DNS brute-force. It's very fast however it's prone to false positives.
sed 's/$/.domain.com/' subdomains.txt > bf-subdomains.txt
./massdns -r resolvers.txt -w /tmp/results.txt bf-subdomains.txt
grep -E "tesla.com. [0-9]+ IN A .+" /tmp/results.txt
- gobuster: This one I think just uses 1 resolver
- shuffledns is a wrapper around
massdns, written in go, that allows you to enumerate valid subdomains using active bruteforce, as well as resolve subdomains with wildcard handling and easy input-output support.
- puredns: It also uses
massdns.
- aiodnsbrute uses asyncio to brute force domain names asynchronously.
Second DNS Brute-Force Round¶
After having found subdomains using open sources and brute-forcing, you could generate alterations of the subdomains found to try to find even more. Several tools are useful for this purpose:
- dnsgen: Given the domains and subdomains generate permutations.
- goaltdns: Given the domains and subdomains generate permutations.
- You can get goaltdns permutations wordlist in here.
- gotator: Given the domains and subdomains generate permutations. If not permutations file is indicated gotator will use its own one.
- altdns: Apart from generating subdomains permutations, it can also try to resolve them (but it's better to use the previous commented tools).
- You can get altdns permutations wordlist in here.
- dmut: Another tool to perform permutations, mutations and alteration of subdomains. This tool will brute force the result (it doesn't support dns wild card).
- You can get dmut permutations wordlist in here.
cat subdomains.txt | dmut -d /tmp/words-permutations.txt -w 100 \
--dns-errorLimit 10 --use-pb --verbose -s /tmp/resolvers-trusted.txt
- alterx: Based on a domain it generates new potential subdomains names based on indicated patterns to try to discover more subdomains.
Smart permutations generation¶
- regulator: For more info read this post but it will basically get the main parts from the discovered subdomains and will mix them to find more subdomains.
python3 main.py adobe.com adobe adobe.rules
make_brute_list.sh adobe.rules adobe.brute
puredns resolve adobe.brute --write adobe.valid
- subzuf: subzuf is a subdomain brute-force fuzzer coupled with an immensly simple but effective DNS reponse-guided algorithm. It utilizes a provided set of input data, like a tailored wordlist or historical DNS/TLS records, to accurately synthesize more corresponding domain names and expand them even further in a loop based on information gathered during DNS scan.
Subdomain Discovery Workflow¶
Check this blog post I wrote about how to automate the subdomain discovery from a domain using Trickest workflows so I don't need to launch manually a bunch of tools in my computer:
Full Subdomain Discovery Using Automated Trickest Workflow - Part 1 | TrickestTrickest
Full Subdomain Brute Force Discovery | Trickest
VHosts / Virtual Hosts¶
If you found an IP address containing one or several web pages belonging to subdomains, you could try to find other subdomains with webs in that IP by looking in OSINT sources for domains in an IP or by brute-forcing VHost domain names in that IP.
OSINT¶
You can find some VHosts in IPs using HostHunter or other APIs.
Brute Force
If you suspect that some subdomain can be hidden in a web server you could try to brute force it:
ffuf -c -w /path/to/wordlist -u http://victim.com -H "Host: FUZZ.victim.com"
gobuster vhost -u https://mysite.com -t 50 -w subdomains.txt
wfuzz -c -w /usr/share/wordlists/SecLists/Discovery/DNS/subdomains-top1million-20000.txt --hc 400,404,403 -H "Host: FUZZ.example.com" -u http://example.com -t 100
#From https://github.com/allyshka/vhostbrute
vhostbrute.py --url="example.com" --remoteip="10.1.1.15" --base="www.example.com" --vhosts="vhosts_full.list"
#https://github.com/codingo/VHostScan
VHostScan -t example.com
With this technique you may even be able to access internal/hidden endpoints.
CORS Brute Force¶
Sometimes you will find pages that only return the header Access-Control-Allow-Origin when a valid domain/subdomain is set in the Origin header. In these scenarios, you can abuse this behaviour to discover new subdomains.
ffuf -w subdomains-top1million-5000.txt -u http://10.10.10.208 -H 'Origin: http://FUZZ.crossfit.htb' -mr "Access-Control-Allow-Origin" -ignore-body
Buckets Brute Force¶
While looking for subdomains keep an eye to see if it is pointing to any type of bucket, and in that case check the permissions. Also, as at this point you will know all the domains inside the scope, try to brute force possible bucket names and check the permissions.
DNS泛解析解决¶
什么是泛解析?¶
泛域名解析是一种高级的域名解析技术,允许将多个子域名解析到同一个IP地址。通过使用通配符(*)作为次级域名,泛域名解析能够实现所有次级域名均指向同一IP地址
泛域名解析的用途
- 支持无限子域名:泛域名解析最大的用途是允许一个域名支持无限的子域名,这对于需要大量二级域名的网站非常有用,例如论坛、博客平台等
- 防止用户错误输入:用户在访问网站时可能会因为输入错误而导致无法访问。通过设置泛域名解析,可以确保用户即使输入错误的子域名也能正常访问网站
- 简化网址输入:有些用户可能不知道网站的完整域名,但知道部分域名或子域名。通过设置泛域名解析,用户可以输入更简洁的网址来访问网站
解决思路¶
泛解析一直都是域名爆破中的大问题,目前的解决思路是根据确切不存在的子域名记录(md5(domain).domain)获取黑名单 IP,对爆破 过程的结果进行黑名单过滤。
但这种宽泛的过滤很容易导致漏报,如泛解析记录为1.1.1.1,但某存在子域名也指向1.1.1.1,此时这个子域名便可能会被黑名单过滤掉。 可以将 TTL 也作为黑名单规则的一部分,评判的依据是:在权威 DNS 中,泛解析记录的 TTL 肯定是相同的,如果子域名记录相同,但 TTL 不同,那这条记录可以说肯定不是泛解析记录。
Note
子域名枚举工具-oneforall就使用该方法对抗泛解析
Monitorization¶
You can monitor if new subdomains of a domain are created by monitoring the Certificate Transparency Logs sublert does.