不触发告警的情报收集:whois、DNS、Shodan与搜索引擎
信息收集是渗透测试最关键的一步——"信息决定攻击"。被动侦察不与目标系统直接交互,不会触发任何告警。据统计,一次成功的渗透测试,70%的时间花在信息收集上。
Whois是域名和IP注册信息的数据库,包含注册人、联系邮箱、DNS服务器等关键信息。
# 安装whois工具
apt install whois
# 查询域名注册信息
whois example.com
# 查询IP注册信息
whois 93.184.216.34
# 提取关键字段
whois example.com | grep -E "Registrant|Admin|Name Server|Creation|Expiry"
# 批量查询
for domain in $(cat targets.txt); do
echo "=== $domain ==="
whois $domain | grep -E "Registrant|Name Server|Creation"
done
# 通过注册邮箱反查域名
# 在 whois.domaintools.com 或 viewdns.info 上搜索
# 常见whois信息价值
# Registrant Organization → 目标公司名称
# Registrant Email → 可能的邮箱格式
# Name Server → DNS服务商,可能关联其他域名
# Creation Date → 域名年龄
# Registrar → 注册商信息
DNS记录是信息收集的金矿——子域名暴露内部架构,MX记录暴露邮件系统,TXT记录可能泄露SPF/DKIM配置。
# 基础DNS查询
dig example.com A # IPv4地址
dig example.com AAAA # IPv6地址
dig example.com MX # 邮件服务器
dig example.com NS # DNS服务器
dig example.com TXT # TXT记录(SPF/DKIM/DMARC)
dig example.com SOA # 起始授权记录
dig example.com CNAME # 别名记录
dig example.com ANY # 所有记录(很多服务器已禁用)
# 使用指定DNS服务器
dig @8.8.8.8 example.com A # Google DNS
dig @1.1.1.1 example.com A # Cloudflare DNS
dig @8.8.8.8 example.com AXFR # 区域传输尝试
# DNS区域传输(信息泄露漏洞)
# 如果DNS服务器配置错误,可以获取所有记录
dig @ns1.example.com example.com AXFR
host -t AXFR example.com ns1.example.com
# 反向DNS查询
dig -x 93.184.216.34
host 93.184.216.34
# DNS缓存探测
# 查询特定DNS服务器缓存
dig @target-dns example.com +dnssec
# 子域名枚举(字典方式)
# 使用dnscan
pip install dnscan
dnscan -d example.com -w subdomains.txt
# 使用subfinder(被动枚举,不接触目标)
# https://github.com/projectdiscovery/subfinder
subfinder -d example.com -o subdomains.txt
# 使用amass(综合枚举工具)
# https://github.com/owasp-amass/amass
amass enum -passive -d example.com -o amass_results.txt
# 证书透明度(CT)日志记录了所有SSL/TLS证书
# 通过查询CT日志可以发现子域名
# 使用crt.sh查询
curl -s "https://crt.sh/?q=%25.example.com&output=json" | \
jq -r '.[].name_value' | sort -u
# 使用censys查询证书
# https://search.censys.io/
# 手动查询
curl -s "https://crt.sh/?q=example.com" | \
grep -oP '[\w.-]+\.example\.com' | sort -u
Shodan和Censys是物联网搜索引擎,可以搜索全球联网设备、开放端口和运行服务。
# Shodan (https://www.shodan.io/)
# 需要注册获取API Key
# 安装Shodan CLI
pip install shodan
shodan init YOUR_API_KEY
# 搜索特定设备
shodan search "apache" # 运行Apache的主机
shodan search "port:22 os:linux" # Linux SSH服务器
shodan search "port:3389 os:windows" # Windows RDP
# 查看主机信息
shodan host 93.184.216.34
# 搜索特定漏洞
shodan search "vuln:CVE-2021-44228" # Log4j漏洞
shodan search "vuln:CVE-2017-0144" # EternalBlue
# 搜索特定产品
shodan search "product:nginx" # Nginx服务器
shodan search "product:mysql" # MySQL服务器
# 统计信息
shodan count "port:22 country:CN" # 中国SSH服务器数量
# Shodan过滤语法
# city:"Beijing" → 指定城市
# country:CN → 指定国家
# org:"China Telecom" → 指定ISP
# net:192.168.0.0/16 → 指定网段
# port:80,443 → 指定端口
# product:nginx → 指定产品
# vuln:CVE-XXXX-XXXX → 指定漏洞
# os:"Linux" → 指定操作系统
# has_screenshot:true → 有截图的设备
# Censys (https://search.censys.io/)
# 类似Shodan但侧重证书和主机
# 支持更精确的搜索语法
# services.tls.certificates.leaf.subject.organization="Target Inc"
Google搜索引擎支持高级操作符,可以精确搜索敏感信息泄露。
# Google高级操作符
site:example.com # 限定搜索范围
inurl:admin # URL中包含admin
intitle:"index of" # 页面标题包含"index of"
filetype:pdf # 搜索PDF文件
intext:"password" # 页面内容包含password
ext:log # 搜索日志文件
cache:example.com # Google缓存版本
# 常用Google Dork
# 发现管理后台
site:example.com inurl:admin
site:example.com inurl:login
site:example.com inurl:dashboard
# 发现目录列表
site:example.com intitle:"index of"
site:example.com intitle:"directory listing"
# 发现配置文件
site:example.com filetype:env OR filetype:yml OR filetype:conf
site:example.com filetype:xml "password"
# 发现数据库文件
site:example.com filetype:sql OR filetype:db OR filetype:mdb
# 发现日志文件
site:example.com filetype:log
site:example.com inurl:error.log
# 发现敏感文档
site:example.com filetype:pdf "confidential"
site:example.com filetype:xlsx "salary"
site:example.com filetype:docx "internal"
# Google Dork数据库
# https://www.exploit-db.com/google-hacking-database
# https://ghdb.google.com/
# 查看网站历史版本
# https://web.archive.org/
# 发现已删除的页面、旧版本漏洞
# 使用Wayback Machine API
curl -s "http://web.archive.org/cdx/search/cdx?url=example.com/*&output=json&limit=100"
# 使用waybackurls工具
go install github.com/tomnomnom/waybackurls@latest
echo "example.com" | waybackurls | sort -u
# 搜索目标组织的代码仓库
# 在GitHub搜索框中:
"example.com" password
"example.com" API_key
"example.com" secret
org:TargetCompany filename:.env
# 使用truffleHog自动扫描
pip install trufflehog
trufflehog https://github.com/target/repo
# 使用git-leaks
# https://github.com/gitleaks/gitleaks
gitleaks detect --repo-url https://github.com/target/repo
# LinkedIn → 员工信息、组织架构、邮箱格式
# Twitter → 技术栈泄露、员工动态
# GitHub → 代码泄露、技术栈
# 社交媒体OSINT工具
# - Sherlock: 查找用户名在多个平台的账号
# - Maltego: 关系分析
# - SpiderFoot: 自动化OSINT
# Sherlock
pip install sherlock-project
sherlock username
# 信息收集后整理成资产清单
# 1. 子域名列表 → 逐个探测存活
# 2. IP地址 → 关联物理位置、ISP
# 3. 开放端口 → 识别服务版本
# 4. 技术栈 → 搜索已知漏洞
# 5. 员工信息 → 社工攻击目标
# 6. 邮箱格式 → 钓鱼攻击
# 子域名存活探测
cat subdomains.txt | httpx -sc -cl -title -o alive.txt
# 端口快速扫描
cat alive_ips.txt | nmap -sS -T4 --top-ports 100 -iL -
# Web指纹识别
# 使用whatweb
whatweb https://target.com
# 使用wappalyzer(浏览器插件)
# 截图记录
# 使用aquatone
cat alive_urls.txt | aquatone -out screenshots/