子域名探測方法大全


子域名探測方法

在線接口
暴力枚舉
搜索引擎
Certificate Transparency(證書透明)
Subject Alternate Name (SAN) - 主題備用名稱
Public datasets(公開數據集)
信息泄露
內容解析(HTML,JavaScript,文件)
DNS解析
區域傳送
DNS aggregators(DNS聚合器)
DNS Cache Snooping(域名緩存偵測)
Alterations & permutations(換置 & 排序)
DNSSEC(Domain Name System Security Extensions),DNS安全擴展,DNSSEC區域漫步
CSP HTTP首部
SPF記錄
虛擬主機爆破
ASN發現
爬蟲 Scraping(抓取)

子域名探測

通過收集子域名信息來進行滲透是目前常見的一種手法。
子域名信息收集可以通過手工,也可以通過工具,還可以通過普通及漏洞搜索引擎來進行分析。
在挖SRC漏洞時,子域名信息的收集至關重要!

為什么要進行子域名探測?

子域名探測可以幫我們發現滲透測試中更多的服務,這將增加發現漏洞的可能性

查找一些用戶上較少,被人遺忘的子域名,其上運行的應用程序可能會使我們發現關鍵漏洞

通常,同一組織的不同域名/應用程序中存在相同的漏洞

子域名中的常見資產類型一般包括辦公系統,郵箱系統,論壇,商城等,其他管理系統,網站管理后台等較少出現在子域名中

子域名探測方法大全

在線接口

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"github"&criteria=cert

暴力枚舉

Layer子域名爆破機 Layer是windows下的一款子域名探測工具,其工作原理是利用子域名字典進行爆破,使用簡單容易上手。

Amass 工具描述:爆破, google, VirusTotal, alt names
go get -u github.com/OWASP/Amass/...
amass -d target.com -o $outfile
Knock

工具描述:AXFR, virustotal, 爆破
apt-get install python-dnspython git clone https://xxx.com/guelfoweb/knock.git
cd knock
nano knockpy/config.json # <- set your virustotal API_KEY python setup.py install

搜索引擎

•Google
intitle=公司名稱
過濾掉 -site:www.target.com
我們可以在Google搜索中使用 site:運算符來查找一個域的所有子域名
谷歌還額外支持減號運算符 site:*.wikimedia.org -www -store -jobs -uk 以排除我們不感興趣的子域名

•Bing
Bing搜索引擎也支持一些高級搜索運算符。
與Google一樣,Bing也支持site:運算符,可以幫助您檢查除Google搜索之外的其他結果。
發現子域名: site:target.com

•百度
intitle=公司名稱

•鍾馗之眼
https://www.zoomeye.org/ site=域名

•FOFA
https://fofa.so/
語法:domain=”baidu.com”
提示:以上方法無需爆破,查詢速度快,需要快速收集資產時可以優先使用,后面再用其他方法補充。

Certificate Transparency(證書透明)

SSL/TLS證書

證書透明度(Certificate Transparency)是證書授權機構的一個項目,證書授權機構會將每個SSL/TLS證書發布到公共日志中。
一個SSL/TLS證書通常包含域名、子域名和郵件地址。
查找某個域名所屬證書的最簡單的方法就是使用搜索引擎搜索一些公開的CT日志。

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

CTFR 工具描述:濫用證書透明記錄
git clone https://xxx.com/UnaPibaGeek/ctfr.git
cd ctfr
pip3 install -r requirements.txt
python3 ctfr.py -d target.com -o $outfile

Censys_subdomain_enum.py
工具描述:提取子域名,從Censys的SSL/TLS證書中收集子域名

pip install censys
git clone https://xxx.com/appsecco/the-art-of-subdomain-enumeration.git
python censys_enumeration.py target.com

Cloudflare_enum.py
工具描述:從Cloudflare提取子域名 dns聚合器

pip install censys
git clone https://xxx.com/appsecco/the-art-of-subdomain-enumeration.git
cloudflare_subdomain_enum.py your@cloudflare.email target.com

Crt_enum_web.py
工具描述:解析https://crt.sh/頁面的子域名

pip install psycopg2
git clone https://xxx.com/appsecco/the-art-of-subdomain-enumeration.git
python3 crtsh_enum_web.py target.com

San_subdomain_enum.py
工具描述:SSL/TLS證書中的SAN獲取子域名

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

Subject Alternate Name (SAN) - 主題備用名稱

SAN(Subject Alternate Name)主題備用名稱,主題備用名稱證書簡單來說,在需要多個域名,將其用於各項服務時,可使用SAN證書。
允許在安全證書中使用subjectAltName字段將多種值與證書關聯,這些值被稱為主題備用名稱。名稱可包括:IP地址、DNS名稱等。

San_subdomain_enum.py
工具描述:SSL/TLS證書中的SAN獲取子域名 如上。

Public datasets(公開數據集)

有些項目收集了全互聯網范圍內的掃描數據,並將其提供給研究人員和安全社區。
該項目發布的數據集是子域名信息的寶庫。
雖然在這個龐大的數據集中找到子域名就像大海撈針,但卻值得我們去一試。

Rapid7 Forward DNS dataset (Project Sonar)
工具描述:來自rapid7 sonar項目的公共數據集

wget https://scans.io/data/rapid7/sonar.fdns_v2/20170417-fdns.json.gz cat 20170417-fdns.json.gz | pigz -dc | grep ".target.org" | jq`

Forward DNS(https://scans.io/study/sonar.fdns_v2) 數據集作為Project Sonar的一部分發布。
數據格式是通過gzip壓縮的JSON文件。
我們可以解析數據集以查找給定域名的子域名。
數據集很大(壓縮后:20+GB,壓縮前:300+GB)
Command to parse & extract sub-domains for a given domain $ curl -silent https://scans.io/data/rapid7/sonar.fdns_v2/20170417-fdns.json.gz | pigz -dc | grep ".icann.org" | jq

數據聚合網站
threatcrowd
https://scans.io/study/sonar.rdns_v2
https://opendata.rapid7.com/

信息泄露

•信息泄露
首先找到目標站點,在官網中可能會找到相關資產(多為辦公系統,郵箱系統等),關注一下頁面底部,也許有管理后台等收獲。

•文件泄漏
crossdomain.xml(跨域策略文件cdx) robots.txt

•Git倉庫泄露

•從流量中分析提取

內容解析(HTML,JavaScript,文件)

BiLE-suite
工具描述:HTML解析,反向dns解析

aptitude install httrack
git clone https://xxx.com/sensepost/BiLE-suite.git
perl BiLE.pl target.com

Second Order
工具描述:第二階段域名掃描 通過HTML提取子域名

go get xxx.com/mhmdiaa/second-order
cp ~/go/src/xxx.com/mhmdiaa/second-order/config.json
~/go/src/xxx.com/mhmdiaa/second-order/config-subs-enum.json
編輯修改LogCrawledURLs為True
second-order -base https://target.com -config config.json -output target.com

DNS解析

在線查詢:
VirusTotal(https://www.virustotal.com/)
ViewDNS(https://viewdns.info/)
DNSdumpster(https://dnsdumpster.com/)
Threatcrowd(https://www.threatcrowd.org/)

BiLE-suite
工具描述:HTML解析,反向dns解析 如上。

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

區域傳送

域傳送是一種DNS事務,DNS服務器將其全部或部分域文件的副本傳遞給另一個DNS服務器。
如果未安全地配置域傳輸送,則任何人都可以對指定名稱的服務器啟動域傳送並獲取域文件的副本。
根據設計,域文件包含有關域和保存在域中的大量主機信息。

Windows:

1.nslookup命令進入交互式shell
2.server命令 參數設定查詢將要使用的DNS服務器
3.ls命令列出某個域中的所有域名

Linux:
Dig
工具描述:dns區域傳送,dns反向解析,dns解析

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

DNS aggregators(DNS聚合器)

Cloudflare_enum.py
工具描述:從Cloudflare提取子域名 dns聚合器

pip install censys
git clone https://xxx.com/appsecco/the-art-of-subdomain-enumeration.git
cloudflare_subdomain_enum.py your@cloudflare.email[4] target.com

DNS Cache Snooping(域名緩存偵測)

域名緩存偵測(DNS Cache Snooping)技術
在企業網絡中,通常都會配置DNS服務器,為網絡內的主機提供域名解析服務。
這些DNS不僅解析自己的私有域名,還會用遞歸方式,請求公網的DNS解析第三方域名,如baidu.com之類。
為了提升性能,通常會使用緩存記錄,記錄解析過的域名,尤其是第三方域名。
域名緩存偵測(DNS Cache Snooping)技術就是向這些服務器發送域名解析請求,但要求不使用遞歸模式。
這樣DNS只能解析私有域名和緩存中保存的域名。
借助該項技術,滲透測試人員就知道哪些域名是否被過請求過。
例如,測試人員可以提交某安全軟件更新所使用的域名,如果有記錄,說明該網絡使用該種安全軟件。

Alterations & permutations(換置 & 排序)

AltDNS
工具描述:通過換置&排序技術發現子域名

git clone https://xxx.com/infosec-au/altdns.git
cd altdns
pip install -r requirements.txt
./altdns.py -i subdomains.txt -o data_output -w words.txt -r -s results_output.txt

DNSSEC(Domain Name System Security Extensions),DNS安全擴展,DNSSEC區域漫步

由於DNSSEC處理不存在域名的方式,您可以"遍歷"DNSSEC域並枚舉該域中的所有域名。
您可以從這里(https://info.menandmice.com/blog/bid/73645/Take-your-DNSSEC-with-a-grain-of-salt) 了解有關此技術的更多信息。

Ldns-walk
工具描述:DNSSEC zone walking, 如果DNSSEC NSEC開啟,可以獲得全部域名。

aptitude install ldnsutils
ldns-walk target.com
ldns-walk @nsserver.com target.com
如果DNSSEC NSEC開啟,可以獲得全部域名。

CSP HTTP首部

Domains-from-csp
工具描述:從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

SPF記錄

SPF是通過域名的TXT記錄來進行設置的,SPF記錄列出了所有被授權代表域名發送電子郵件的主機

Assets-from-spf
工具描述:SPF域名記錄

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

虛擬主機爆破

vhost-brute
工具描述:虛擬主機爆破

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

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

ASN發現

通過域名查詢到 ASN,再通過 ASN 查詢到所屬的所有 ip 范圍

爬蟲 Scraping(抓取)

泛解析問題

目前最好的解決方式是通過先獲取一個絕對不存在域名的響應內容,再遍歷獲取每個字典對應的子域名的響應內容,通過和不存在域名的內容做相似度比對,來枚舉子域名,但這樣的實現是以犧牲速度為代價

https://www.freebuf.com/news/133873.html
https://xz.aliyun.com/t/5509

Tools

OneForAll

https://github.com/shmilylty/OneForAll
工具也有很多厲害的,平時我一般使用 OneForALL + ESD + JSfinder 來進行搜集,(ESD 可以加載 layer 的字典,很好用)

Sublist3r

https://github.com/aboul3la/Sublist3r
- 強大的快速子域枚舉工具 評分: 🌟🌟🌟🌟🌟 | 編程語言: Python 2.x/3.x | 仍在維護: ✔️

guelfoweb/knock

https://github.com/guelfoweb/knock
- Knock子域名獲取,可用於查找子域名接管漏洞 評分: 🌟🌟🌟🌟🌟 | 編程語言: Python 2.x | 仍在維護: ✔️

subdomain3

https://github.com/yanxiu0614/subdomain3
- 一款便捷高效的子域名爆破工具 評分: 🌟🌟🌟🌟🌟 | 編程語言: Python 3.x | 仍在維護: ✔️

amass

https://github.com/caffix/amass
- Go語言開發的子域名枚舉工具 評分: 🌟🌟🌟🌟🌟 | 編程語言: Go | 仍在維護: ✔️

Ice3man543/subfinder

https://github.com/Ice3man543/subfinder
- 繼承於Sublist3r項目的模塊化體系結構,一個強勁的子域名枚舉工具 評分: 🌟🌟🌟🌟🌟 | 編程語言: Go | 仍在維護: ✔️

horn3t

https://github.com/janniskirschner/horn3t
- 帶有網頁截圖功能的子可視化域名枚舉工具 評分: 🌟🌟🌟🌟🌟 | 編程語言: Python 3.x | 仍在維護: ✔️

subDomainsBrute

https://github.com/lijiejie/subDomainsBrute
- Lijiejie開發的一款使用廣泛的子域名爆破枚舉工具 評分: 🌟🌟🌟🌟🌟 | 編程語言: Python 2.x | 仍在維護: ✖️

wydomain

https://github.com/ring04h/wydomain
- 豬豬俠開發的一款域名收集全面、精准的子域名枚舉工具 評分: 🌟🌟🌟🌟🌟 | 編程語言: Python 2.x | 仍在維護: ✖️

子域名監控

LangSrcCurise

https://github.com/LangziFun/LangSrcCurise

Sublert

https://www.freebuf.com/sectool/198396.html

參考

https://mp.weixin.qq.com/s/m8ucI1bDxILM8wLU6pLmoQ
https://xz.aliyun.com/t/3478 https://blog.csdn.net/qq_39293438/article/details/104829825


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM