子域名探测方法大全 - ershiyi

admin 2021年12月31日15:02:21评论71 views1字数 6914阅读23分2秒阅读模式

子域名探测

通过收集子域名信息来进行渗透是目前常见的一种手法。
子域名信息收集可以通过手工,也可以通过工具,还可以通过普通及漏洞搜索引擎来进行分析。
在挖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%22github%22&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 [email protected] 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 [email protected] 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(抓取)

泛解析问题

目前最好的解决方式是通过先获取一个绝对不存在域名的响应内容,再遍历获取每个字典对应的子域名的响应内容,通过和不存在域名的内容做相似度比对,来枚举子域名,但这样的实现是以牺牲速度为代价

tools

OneForAll

https://github.com/shmilylty/OneForAll
工具也有很多厉害的,平时我一般使用 OneForALL + ESD + JSfinder 来进行搜集,(ESD 可以加载 layer 的字典,很好用)

Sublist3r

https://github.com/aboul3la/Sublist3r - 强大的快速子域枚举工具
评分:

BY:先知论坛

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年12月31日15:02:21
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   子域名探测方法大全 - ershiyihttp://cn-sec.com/archives/710545.html

发表评论

匿名网友 填写信息