0x00 前言
首先信息收集包含资产收集但不限于资产收集,信息收集包含whois,真实IP,网站架构,子域名收集,敏感目录,DNS信息,旁站,C段,端口等;而资产收集主要收集IP和域名,找到属于目标的域名和真实IP,目标的域名和真实IP相对应上这就是一条资产。不管是平时的渗透项目还是挖掘SRC,资产收集都是重中之重,不然你忙活半天,很可能不是给定的目标。
0x01 什么是资产?
网络资产主要是计算机(或通讯)网络中使用的各种设备。主要包括主机(服务器)、网络设备(路由器、交换机等)和安全设备(防火墙、安全网关等)。
0x02 如何搜集资产?
1. 子域名
暴力猜解:layer、oneforall、subDomainsBrute
python oneforall.py --target example.com run
搜索引擎:
Google Hacking:
site:bilibili.com -www
web工具:
http://tool.chinaz.com/subdomain
https://phpinfo.me/domain
利用DNS:
(1) 域传送 (记录)
原理:
域传送操作是指备用服务器向主服务 器查询来刷新自己的Zone数据库,保证数据一致性。此操作的目的是为了防止主域名服务器因意外故障变得不可用时影响到全局。正常情况下,只有在网络里存在备用域名 DNS 服务器时,DNS区域传送操作才有必要执行。一旦DNS服务器被错误地配置成任何人发出请求,都向其提供Zone数据库的拷贝,就会被攻击者利用。
实现方法:
dig命令
如dig @ns2.xxx.com xxx.com axfr
ns2.xxx.com为提供数据的服务器,xxx.com为要传输的关键字,axfr为区域传输选项。
python中dns库
xfr = dns.query.xfr(where=server, zone=self.domain, timeout=5.0, lifetime=10.0)
zone = dns.zone.from_xfr(xfr)
(2) DNS查询
原理:
通过枚举常见的SRV记录并做查询来收集子域srv,以及通过查询域名的DNS记录中的MX,NS,SOA,TXT记录来收集子域。
SRV记录: 添加服务记录服务器服务记录时会添加此项,SRV记录了哪台计算机提供了哪个服务。格式为:服务的名字.协议的类型(例如:example-server.tcp)。
nmap --script dns-srv-enum.nse --script-args "dns-srv-enum.domain='baidu.com'"
Starting Nmap 7.91 ( https://nmap.org ) at 2021-01-06 15:22 CST
Pre-scan script results:
| dns-srv-enum:
| Exchange Autodiscovery
| service prio weight host
| 443/tcp 0 0 email.baidu.com
| SIP
| service prio weight host
| 5060/tcp 0 0 vcs.wshifen.com
| XMPP client-to-server
| service prio weight host
| 5222/tcp 0 0 xmpp.wshifen.com
| XMPP server-to-server
| service prio weight host
|_ 5269/tcp 0 0 xmpp.wshifen.com
WARNING: No targets were specified, so 0 hosts scanned.
Nmap done: 0 IP addresses (0 hosts up) scanned in 2.40 seconds
MX记录: 建立电子邮箱服务,将指向邮件服务器地址,需要设置MX记录。
> set type=mx
> bilibili.com
Server: 172.27.144.1
Address: 172.27.144.1#53
Non-authoritative answer:
bilibili.com mail exchanger = 10 n89-xyz.mail.protection.partner.outlook.cn.
bilibili.com mail exchanger = 5 bilibili-com.mail.protection.partner.outlook.cn.
NS记录: 域名解析服务器记录,如果要将子域名指定某个域名服务器来解析,需要设置NS记录。
> set type=ns
> bilibili.com
Server: 172.27.144.1
Address: 172.27.144.1#53
Non-authoritative answer:
bilibili.com nameserver = ns3.dnsv5.com.
bilibili.com nameserver = ns4.dnsv5.com.
SOA记录: SOA叫做起始授权机构记录,NS用于标识多台域名解析服务器,SOA记录用于在众多NS记录中那一台是主服务器。
> set type=soa
> bilibili.com
Server: 172.27.144.1
Address: 172.27.144.1#53
Non-authoritative answer:
bilibili.com
origin = ns3.dnsv5.com
mail addr = enterprise3dnsadmin.dnspod.com
serial = 1608537087
refresh = 3600
retry = 180
expire = 1209600
minimum = 180
TXT记录: 可任意填写,可为空。一般做一些验证记录时会使用此项,如:做SPF(反垃圾邮件)记录。
> set type=txt
> bilibili.com
Server: 172.27.144.1
Address: 172.27.144.1#53
Non-authoritative answer:
bilibili.com text = "_globalsign-domain-verification=baENwyv8P3IQLNu3dxv6CAanZhJGB69c6roctP5IuU"
bilibili.com text = "MS=ms11191212"
bilibili.com text = "v=spf1 include:spf.protection.partner.outlook.cn -all"
bilibili.com text = "_globalsign-domain-verification=OVQk3PcIE6mkbxwu4lQq2lEaKCYqqgdS975XBzVzcT"
bilibili.com text = "_globalsign-domain-verification=z5h5c7fLq8os37XOa-cIieNBbqrMIjyBUFRCPQH4Sc"
bilibili.com text = "_globalsign-domain-verification=pne8f0i69G2FQeduwZxQndmuAekivh8PeOCG36xQj0"
利用DNS数据集收集子域 :
★https://searchdns.netcraft.com/
https://hackertarget.com/find-dns-host-records/
https://dns.bufferover.run/dns?q={domain}
https://dnsdb.io/zh-cn/search?q={domain}
证书透明度:
证书透明度(英语:Certificate Transparency,简称CT)也称证书透明、证书透明化,它是一个实验性的IETF开源标准和开源框架,目的是监测和审计数字证书。通过证书日志、监控和审计系统,证书透明度使网站用户和域名持有者可以识别不当或恶意签发的证书,以及识别数字证书认证机构(CA)的作为。
https://crt.sh/
https://developers.facebook.com/tools/ct
https://sslmate.com/certspotter/api/
https://spyse.com/search/certificate
https://censys.io/certificates
https://google.com/transparencyreport/https/ct/
威胁情报数据平台:
fofa:
domain="xxx.com"
cert="xxx.com"
https://otx.alienvault.com/api/v1/indicators/domain/{domain}/{section}
{section}指其他指令动作,可参考Docs关于API的使用说明。
https://otx.alienvault.com/api/v1/indicators/domain/qq.com/url_list
https://www.threatminer.org/domain.php?q={domain}
https://pentest-tools.com/information-gathering/find-subdomains-of-domain
https://x.threatbook.cn/
2. 相关域名
旁站与C段:
旁站:旁站是和目标网站在同一台服务器上的其它的网站。
C段:C段是和目标服务器ip处在同一个C段的其它服务器。
旁站:
https://chapangzhan.com/
http://stool.chinaz.com/same
https://ipchaxun.com/
https://www.webscan.cc/
http://www.bug8.me/bing/bing.php
C段:
https://chapangzhan.com/
Google:site:211.69.130.*
FOFA、Shodan 语法:ip:"47.97.211.0/24"
nmap -p 22,21,443,8080 -Pn 192.168.10.0/24
masscan -p 22,21,443,8080 -Pn --rate=1000 192.168.10.0/24
3. CDN 获取真实IP
4. 指纹识别
常见指纹检测的对象:
-
CMS信息:比如大汉CMS、织梦、帝国CMS、phpcms、ecshop等;
-
前端技术:比如HTML5、jquery、bootstrap、pure、ace等;
-
Web服务器:比如Apache、lighttpd, Nginx, IIS等;
-
应用服务器:比如Tomcat、Jboss、weblogic、websphere等;
-
开发语言:比如PHP、Java、Ruby、Python、C#等;
-
操作系统信息:比如linux、win2k8、win7、kali、centos等;
-
CDN信息:是否使用CDN,如cloudflare、360cdn、365cyd、yunjiasu等;
-
WAF信息:是否使用waf,如Topsec、Jiasule、Yundun等;
-
IP及域名信息:IP和域名注册信息、服务商信息等;
-
端口信息:有些软件或平台还会探测服务器开放的常见端口。
常见的指纹识别方式:
-
特定文件的MD5
一些网站的特定图片文件、js文件、CSS等静态文件md5值。
-
正常页面或错误网页中包含的关键字
先访问首页或特定页面如robots.txt等,通过正则的方式去匹配某些关键字,如Powered by Discuz、dedecms等。
-
请求头信息的关键字匹配
根据response header一般有以下几种识别方式:
- 查看http响应报头的X-Powered-By字段来识别;
- 根据Cookies来进行判断,比如一些waf会在返回头中包含一些信息,如360wzws、Safedog、yunsuo等;
- 根据header中的Server信息来判断,如DVRDVS-Webs、yunjiasu-nginx、Mod_Security、nginx-wallarm等;
- 根据WWW-Authenticate进行判断,一些路由交换设备可能存在这个字段,如NETCORE、huawei、h3c等设备。
-
部分URL中包含的关键字,比如wp-includes、dede等URL关键特征
工具:
whatweb
Wapplyzer
Whatruns
御剑web指纹识别
Test404轻量WEB指纹识别
w11scan分布式WEB指纹识别平台: https://github.com/w-digital-scanner/w11scan
http://www.yunsee.cn/
http://whatweb.bugscaner.com/look/
TideFinger: https://github.com/TideSec/TideFinger