前言
在网络安全攻防对抗中,"知己知彼,百战不殆"这句话被诠释得淋漓尽致。无论是渗透测试前的攻击面梳理,还是红队评估中的目标画像,亦或是威胁情报团队追踪APT组织,OSINT(Open Source Intelligence,开源情报)都是第一步,也是最关键的一步。据统计,一次完整的红队评估中,约70%的有效漏洞和入侵路径都来源于前期OSINT阶段发现的暴露面与泄露信息。
本文将从OSINT方法论出发,系统讲解搜索引擎情报、网络空间测绘、域名侦察、IP资产发现、人员情报、代码泄露、Web指纹识别、暗网情报、自动化框架、情报可视化,直至渗透测试实战应用与防御反制,涵盖100+工具与大量实战命令,力求让读者看完即可上手。所有技术仅用于授权测试与安全学习,切勿用于非法用途。
【提示】 本文所有OSINT技术与工具仅用于授权安全测试、CTF竞赛、学术研究与防御建设。未经授权对他人系统进行信息收集与探测可能违反《网络安全法》《数据安全法》《个人信息保护法》及相关刑法条款。读者需自行承担一切法律风险,作者不对任何滥用行为负责。
一、OSINT方法论
1.1 情报周期
OSINT并非简单地"搜一搜",而是遵循结构化的情报周期(Intelligence Cycle)。美国军方与情报界提出的五阶段模型同样适用于网络安全领域:
| 阶段 | 中文名称 | 核心任务 | 安全场景示例 |
|---|---|---|---|
| Planning | 计划与方向 | 明确情报需求、目标范围、优先级、时间窗口 | 确定测试目标域名、IP段、关键人员、业务系统 |
| Collection | 收集 | 从公开/半公开源获取原始信息 | 搜索引擎、网络空间测绘、社交媒体、代码仓库 |
| Processing | 处理 | 清洗、去重、格式化、结构化原始数据 | 子域名去重、IP归属整理、泄露数据提取 |
| Analysis | 分析 | 关联、推断、建模、形成情报结论 | 资产画像、人员关系图、攻击面评估 |
| Dissemination | 传递 | 输出报告、图表、指标,反馈需求方 | 渗透测试侦察报告、威胁情报简报 |
每个周期结束后需评估是否满足需求,未满足则重新进入计划阶段调整方向,形成闭环。
1.2 信息源分类
OSINT的信息源按可访问性与隐蔽性可分为三大类:
| 类别 | 信息源示例 | 特点 | 获取难度 |
|---|---|---|---|
| 公开源 | 搜索引擎、企业官网、新闻、公开财报、招聘网站、GitHub公开仓库 | 合规、易获取、数据量大 | 低 |
| 半公开源 | 社交媒体、论坛、Pastebin、技术博客、Whois、证书透明度日志 | 需账号或特定查询方式 | 中 |
| 暗网/深网 | Tor隐藏服务、暗网市场、泄露数据库、Telegram频道 | 需特殊工具、法律风险高 | 高 |
1.3 OSINT工具分类
按功能域划分,OSINT工具可分为如下几类:
| 类别 | 代表工具 | 主要用途 |
|---|---|---|
| 搜索引擎 | Google/Bing/Baidu/Yandex/DuckDuckGo | 通用信息检索、Google Hacking |
| 网络空间测绘 | Shodan/Censys/FOFA/ZoomEye/Quake/Hunter | IP资产、端口、服务、Banner测绘 |
| 域名/子域名 | subfinder/amass/oneforall/sublist3r | 子域名发现、DNS枚举 |
| 代码泄露 | GitDorker/gitleaks/trufflehog/gitrob | GitHub敏感信息泄露检测 |
| 社交媒体 | Sherlock/Maltego/Hunter | 人员追踪、邮箱/电话情报 |
| 暗网 | Ahmia/HIBP/dehashed | 暗网搜索、泄露数据查询 |
| 自动化框架 | Maltego/SpiderFoot/theHarvester/Recon-ng | 多源情报自动化收集与分析 |
1.4 OSINT伦理与法律边界
【提示】 OSINT采集的是"公开信息",但"公开"不等于"可自由使用"。以下行为即使数据公开也可能违法:批量抓取个人信息违反《个人信息保护法》;贩卖企业内部泄露数据可能构成侵犯商业秘密罪;对目标系统进行主动扫描需取得书面授权。建议始终遵循最小必要、授权范围内、可追溯原则。
二、搜索引擎情报(Google Hacking)
2.1 Google搜索语法大全
Google Hacking是OSINT最基础也最强大的技能,掌握高级搜索语法可在海量信息中精准定位目标:
| 语法 | 含义 | 示例 |
|---|---|---|
| site: | 限定域名 | site:example.com |
| inurl: | URL中包含关键词 | inurl:admin |
| intext: | 正文包含关键词 | intext:"index of /backup" |
| intitle: | 标题包含关键词 | intitle:"login" |
| filetype: | 限定文件类型 | filetype:pdf "annual report" |
| cache: | 查看缓存快照 | cache:example.com |
| - | 排除关键词 | site:example.com -www |
| "..." | 精确匹配 | "internal use only" |
| * | 通配符 | site:example.com admin * |
| OR | 或逻辑 | site:example.com OR site:test.com |
| ... | 数字范围 | report 2020..2025 |
2.2 Google Hacking Database(GHDB)
GHDB由Exploit-DB维护,收录了数千条经过验证的Google Dork,是OSINT人员必备的参考库。地址:https://www.exploit-db.com/google-hacking-database
常用分类包括:
- Footholds(入口点):暴露的后台、登录页
- Files Containing Usernames(用户名文件)
- Sensitive Directories(敏感目录)
- Web Server Detection(Web服务器探测)
- Vulnerable Files(漏洞文件)
- Error Messages(错误信息)
2.3 其他搜索引擎
| 搜索引擎 | 特点 | 适用场景 |
|---|---|---|
| Bing | 微软系,索引国内站点较好 | 国内目标补充检索 |
| Baidu | 中文资源最丰富 | 中文企业、政府单位 |
| Yandex | 俄系,反向图片搜索强 | 东欧目标、图片溯源 |
| DuckDuckGo | 不追踪用户 | 隐私敏感查询 |
| Shodan | 设备/Banner搜索 | 物联网、服务测绘 |
2.4 高级搜索技巧
| 技巧 | 说明 | 示例 |
|---|---|---|
| 多语法组合 | 缩小范围 | site:example.com intitle:"dashboard" -inurl:login |
| 文件类型组合 | 定位文档 | filetype:pdf OR filetype:doc site:example.com |
| 数字范围 | 时间过滤 | site:example.com "report" 2023..2025 |
| 通配符 | 模糊匹配 | site:example.com * |
| 排除干扰 | 去噪 | intext:"confidential" -site:gov |
| 缓存对比 | 看历史 | cache:example.com/page |
2.5 Google Dork实战案例集
以下是10+个实战Dork,可用于授权测试中的信息搜集:
text
# 1. 查找暴露的后台登录页
site:example.com inurl:admin OR inurl:login OR inurl:administrator
# 2. 查找目录列表(敏感文件泄露)
intitle:"index of" "parent directory"
# 3. 查找暴露的配置文件
filetype:env OR filetype:ini OR filetype:conf site:example.com
# 4. 查找SQL错误信息(可能存在注入)
intext:"SQL syntax" OR intext:"mysql_fetch" site:example.com
# 5. 查找暴露的phpinfo页面
intitle:"phpinfo" "PHP Version" site:example.com
# 6. 查找暴露的备份文件
filetype:bak OR filetype:old OR filetype:backup site:example.com
# 7. 查找包含密码的文件
filetype:txt "password" OR "passwd" site:example.com
# 8. 查找暴露的Git仓库
intext:"index of" ".git" site:example.com
# 9. 查找敏感文档
filetype:pdf "confidential" OR "internal" OR "do not distribute" site:example.com
# 10. 查找暴露的Webshell
inurl:shell.php OR inurl:c99.php OR inurl:r57.php
# 11. 查找暴露的phpMyAdmin
intitle:"phpMyAdmin" "Welcome to phpMyAdmin" site:example.com
# 12. 查找Jenkins暴露
intitle:"Dashboard [Jenkins]" site:example.com
2.6 搜索引擎API使用
Google Custom Search API(CSE)可编程化搜索:
python
import requests
API_KEY = "YOUR_GOOGLE_API_KEY"
CSE_ID = "YOUR_CSE_ID"
query = "site:example.com filetype:pdf"
url = "https://www.googleapis.com/customsearch/v1"
params = {
"key": API_KEY,
"cx": CSE_ID,
"q": query,
"num": 10,
"start": 1
}
resp = requests.get(url, params=params)
results = resp.json()
for item in results.get("items", []):
print(item["title"], item["link"])
Bing Search API(已迁移到Azure Marketplace):
python
import requests
headers = {"Ocp-Apim-Subscription-Key": "YOUR_BING_KEY"}
params = {"q": "site:example.com admin", "count": 50}
resp = requests.get("https://api.bing.microsoft.com/v7.0/search",
headers=headers, params=params)
print(resp.json())
三、网络空间测绘
网络空间测绘平台是OSINT中"资产发现"的核心利器,通过扫描全球IPv4地址并解析Banner,可快速定位目标暴露的服务与漏洞。
3.1 Shodan
3.1.1 Shodan搜索语法与过滤器
| 过滤器 | 含义 | 示例 |
|---|---|---|
| country: | 国家代码 | country:CN |
| city: | 城市 | city:"Beijing" |
| port: | 端口 | port:22 |
| org: | 组织 | org:"China Telecom" |
| hostname: | 主机名 | hostname:example.com |
| os: | 操作系统 | os:"Windows Server" |
| product: | 产品 | product:"nginx" |
| version: | 版本 | product:apache version:2.4.50 |
| net: | CIDR网段 | net:192.168.1.0/24 |
| vuln: | 漏洞 | vuln:CVE-2021-44228 |
| title: | 页面标题 | title:"dashboard" |
| http.component: | Web组件 | http.component:"wordpress" |
常用搜索示例:
text
# 查找中国的Apache服务器
apache country:CN
# 查找暴露的Redis未授权
product:"redis" port:6379 -auth
# 查找暴露的Jenkins
http.title:"Dashboard [Jenkins]"
# 查找存在Log4Shell的目标
vuln:CVE-2021-44228
# 查找某组织的所有资产
org:"target org" port:80,443
3.1.2 Shodan CLI使用
bash
# 安装
pip install shodan
# 配置API Key
shodan init YOUR_API_KEY
# 搜索
shodan search "apache country:CN"
shodan search "port:22 country:US"
# 查看主机详情
shodan host 8.8.8.8
# 统计顶部端口
shodan stats --facets port:10 "country:CN"
# 下载扫描结果
shodan download results.json "nginx country:CN"
# 转换为CSV
shodan parse --fields ip_str,port,org --separator , results.json.gz > results.csv
# 监控域名资产(需企业版)
shodan alert create "My Network" 1.2.3.0/24
shodan alert triggers
3.1.3 Shodan API调用示例
python
from shodan import Shodan
api = Shodan("YOUR_API_KEY")
# 搜索
results = api.search("nginx country:CN")
for service in results["matches"]:
print(service["ip_str"], service["port"], service.get("hostnames"))
# 查看主机详情
host = api.host("8.8.8.8")
print(host["org"], host["os"])
for item in host["data"]:
print(item["port"], item["product"])
3.2 Censys
3.2.1 Censys搜索语法
text
# 按服务搜索
services.service_name: HTTP AND services.port: 443
# 按证书搜索
parsed.subject_dn: "example.com"
# 按自治系统
autonomous_system.asn: 4134
# 按位置
location.country_code: CN
# 组合查询
services.port: 22 AND services.software.product: "OpenSSH" AND location.country_code: CN
3.2.2 Censys证书搜索
证书透明度日志(CT Log)是发现子域名的金矿:
text
# 查找example.com签发的所有证书
parsed.names: example.com
# 查找使用Let's Encrypt的证书
parsed.issuer_dn: "Let's Encrypt"
# 查找过期证书
parsed.validity.end: < 2026/01/01
3.3 FOFA
FOFA是国内最常用的网络空间测绘平台,语法丰富且对国内资产覆盖度极高:
| 语法 | 含义 | 示例 |
|---|---|---|
| ip: | IP地址 | ip="1.1.1.1" |
| port: | 端口 | port="80" |
| protocol: | 协议 | protocol="ssh" |
| title: | 页面标题 | title="后台管理" |
| domain: | 根域名 | domain="example.com" |
| host: | 主机名 | host=".example.com" |
| body: | 响应正文 | body="Powered by WordPress" |
| header: | 响应头 | header="Server: nginx" |
| icon_hash: | 网站图标hash | icon_hash="-247388890" |
| cert: | 证书内容 | cert="example.com" |
| server: | 服务器类型 | server="Apache/2.4" |
| status_code: | 状态码 | status_code="200" |
| app: | 应用名 | app="Apache-shenqinglog" |
常用FOFA查询示例:
text
# 查找某组织的所有资产
domain="example.com"
# 查找使用特定CMS的站点
app="WordPress" && country="CN"
# 查找暴露的后台
title="管理后台" && country="CN"
# 查找特定图标hash(可定位同一套系统)
icon_hash="-247388890"
# 查找暴露的数据库
port="3306" && protocol="mysql"
获取icon_hash的Python脚本:
python
import mmh3
import requests
import codecs
url = "https://example.com/favicon.ico"
response = requests.get(url)
favicon = codecs.encode(response.content, "base64")
icon_hash = mmh3.hash(favicon)
print(icon_hash)
3.4 ZoomEye
ZoomEye(钟馗之眼)支持Web搜索与主机搜索:
text
# Web搜索(页面内容)
app:"WordPress" country:CN
# 主机搜索(服务Banner)
port:22 service:ssh country:CN
# 设备搜索
device:router country:CN
# 组合查询
port:3389 country:CN after:"2025-01-01"
API使用:
python
import requests
API_KEY = "YOUR_ZOOMEYE_KEY"
headers = {"API-KEY": API_KEY}
params = {"query": "port:22 country:CN", "page": 1}
resp = requests.get("https://api.zoomeye.org/host/search",
headers=headers, params=params)
print(resp.json())
3.5 Quake / Hunter / Space
3.5.1 Quake(360)
text
# 基础语法
domain:"example.com"
ip:"1.1.1.1"
port:"80"
app:"Apache" country:"CN"
# 组合查询
app:"WordPress" AND country:"CN" AND title:"登录"
3.5.2 Hunter(奇安信)
text
# 语法
domain="example.com"
ip.port="6379"
web.title="管理后台"
app.product="Apache"
3.5.3 Space(安信)
text
domain="example.com"
ip="1.1.1.1"
port="443"
title="登录"
3.6 网络空间测绘平台对比
| 平台 | 厂商 | 国内覆盖 | 特色 | 免费额度 |
|---|---|---|---|---|
| Shodan | 美国MIT | 一般 | 全球设备、IoT、漏洞标识 | 有限免费 |
| Censys | 美国密歇根大学 | 一般 | 证书、扫描数据强 | 有限免费 |
| FOFA | 华顺信安 | 极强 | 国内资产最全、icon_hash | 注册免费 |
| ZoomEye | 知道创宇 | 强 | Web与设备双维度 | 注册免费 |
| Quake | 360 | 强 | 360大数据支撑 | 注册免费 |
| Hunter | 奇安信 | 强 | 资产分组、API友好 | 注册免费 |
| Space | 安信 | 中 | 新兴平台 | 注册免费 |
3.7 完整资产发现流程
text
1. 域名解析 -> 确认根域名
2. 证书透明度 -> 发现子域名(crt.sh)
3. 搜索引擎 -> site: 查子域名与页面
4. 网络空间测绘 -> FOFA/Shodan 查资产
5. 端口扫描 -> nmap/masscan 探开放端口
6. 服务识别 -> httpx/whatweb 探Web指纹
7. 资产分组 -> 按业务/网段/IP归档
8. 漏洞关联 -> 结合CVE库评估暴露面
四、域名与子域名收集
子域名是攻击面的核心扩展,掌握子域名意味着掌握目标的全部Web入口。
4.1 子域名发现方法分类
| 方法 | 原理 | 代表工具 | 速度 | 准确率 |
|---|---|---|---|---|
| 被动收集 | 查询第三方数据库 | Amass被动模式/crt.sh | 快 | 高 |
| 主动枚举 | DNS爆破字典 | amass主动/sublist3r | 慢 | 中 |
| 证书透明度 | CT日志查询 | crt.sh/Censys | 快 | 极高 |
| 搜索引擎 | Google site: | Google/Bing | 中 | 中 |
| 第三方API | 聚合数据源 | SecurityTrails/Virustotal | 快 | 高 |
| DNS置换 | 字典+DNS查询 | knockpy/dnsmasq | 中 | 中 |
| 置换变异 | 算法生成 | altDNS | 中 | 中 |
4.2 子域名发现工具使用
4.2.1 subfinder
bash
# 安装
go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest
# 基础使用
subfinder -d example.com
# 多数据源配置(~/.config/subfinder/config.yaml)
# 需配置各平台API Key
# 输出到文件
subfinder -d example.com -o subs.txt
# 递归查询
subfinder -d example.com -recursive
# 多域名
subfinder -dL domains.txt -o all_subs.txt
# 指定数据源
subfinder -d example.com -sources virustotal,crtsh,securitytrails
# 静默模式(适合管道)
subfinder -d example.com -silent | sort -u
4.2.2 amass
bash
# 安装
go install -v github.com/owasp-amass/amass/v4/cmd/amass@latest
# 被动模式(最快,合规)
amass enum -passive -d example.com -o passive.txt
# 主动模式(DNS爆破,需授权)
amass enum -active -d example.com -o active.txt
# 使用字典
amass enum -active -d example.com -w wordlist.txt
# 暴力枚举
amass enum -brute -d example.com -w subdomains.txt
# 数据库可视化
amass viz -d3 -o amass.html
amass viz -maltego -d example.com
4.2.3 OneForAll
bash
# 安装
git clone https://github.com/shmilylty/OneForAll.git
pip3 install -r requirements.txt
# 运行
python3 oneforall.py --target example.com run
# 输出CSV与JSON
python3 oneforall.py --target example.com --format csv,json run
# 批量
python3 oneforall.py --targets domains.txt run
4.2.4 sublist3r / knockpy
bash
# sublist3r
pip install sublist3r
sublist3r -d example.com -o subs.txt
# knockpy
git clone https://github.com/guelfoweb/knock.git
python knockpy.py example.com
4.3 DNS枚举
4.3.1 dig 基础查询
bash
# A记录
dig example.com A
# MX记录(邮件服务器,CDN绕过常用)
dig example.com MX
# TXT记录(SPF、DKIM、验证信息)
dig example.com TXT
# NS记录(权威DNS)
dig example.com NS
# CNAME记录
dig www.example.com CNAME
# 反向查询
dig -x 1.2.3.4
# 指定DNS服务器
dig @8.8.8.8 example.com
4.3.2 其他DNS工具
bash
# nslookup
nslookup example.com
nslookup -type=mx example.com
# fierce(综合DNS枚举)
fierce -dns example.com
fierce -dns example.com -wordlist sub.txt
# dnsenum
dnsenum example.com
dnsenum --enum example.com
# dnsrecon
dnsrecon -d example.com -t std
dnsrecon -d example.com -t brt -D subdomains.txt
4.4 证书透明度日志
4.4.1 crt.sh
crt.sh是Sectigo维护的CT日志查询服务,是子域名发现的金标准:
bash
# Web查询
https://crt.sh/?q=example.com
# JSON输出(脚本友好)
https://crt.sh/?q=%25.example.com&output=json
# 命令行使用
curl -s "https://crt.sh/?q=%25.example.com&output=json" | jq -r '.[].name_value' | sort -u
4.4.2 Censys证书搜索
text
parsed.names: example.com
4.5 子域名接管检测
子域名接管(Subdomain Takeover)是高危漏洞,当子域名CNAME指向已被释放的外部服务时,攻击者可注册该外部服务并接管子域名。
4.5.1 subjack
bash
# 安装
go install -v github.com/haccer/subjack@latest
# 使用
subjack -w subs.txt -t 100 -timeout 30 -o results.txt -ssl
# 指纹库
subjack -w subs.txt -t 100 -c fingerprints.yaml
4.5.2 SubOver
bash
# 安装
go install -v github.com/Ice3man543/subover@latest
# 使用
SubOver -l subs.txt -t 100
# Verbose模式
SubOver -l subs.txt -v
4.6 完整域名侦察流程
bash
#!/bin/bash
# domain_recon.sh - 完整域名侦察流程
DOMAIN=$1
echo "[*] Step 1: 被动子域名收集"
subfinder -d $DOMAIN -silent -o passive.txt
echo "[*] Step 2: 证书透明度"
curl -s "https://crt.sh/?q=%25.$DOMAIN&output=json" | jq -r '.[].name_value' | sort -u > crt.txt
echo "[*] Step 3: Amass被动"
amass enum -passive -d $DOMAIN -o amass.txt
echo "[*] Step 4: 合并去重"
cat passive.txt crt.txt amass.txt | sort -u > all_subs.txt
echo "[*] Step 5: 存活检测"
cat all_subs.txt | httpx -silent -o live_subs.txt
echo "[*] Step 6: 接管检测"
subjack -w all_subs.txt -t 100 -o takeover.txt
echo "[*] Done! Total subdomains: $(wc -l < all_subs.txt)"
五、IP与网络资产发现
5.1 IP段扫描
5.1.1 nmap
bash
# 常用扫描
nmap -sS -p- 192.168.1.0/24
# 服务与版本探测
nmap -sV -sC -p 1-1000 192.168.1.10
# 快速扫描Top1000端口
nmap -F 192.168.1.10
# 操作系统探测
nmap -O 192.168.1.10
# 脚本扫描
nmap --script=vuln 192.168.1.10
nmap --script=http-enum 192.168.1.10
# 输出格式
nmap -sV -oA scan_results 192.168.1.0/24
# UDP扫描
nmap -sU --top-ports 100 192.168.1.10
# 防火墙绕过
nmap -f -D RND:10 192.168.1.10
nmap -sS -Pn -T4 192.168.1.10
5.1.2 masscan(极速扫描)
bash
# 全端口扫描
masscan 192.168.1.0/24 -p1-65535 --rate=10000
# 常用端口
masscan 192.168.1.0/24 -p80,443,22,3306,6379 --rate=10000
# 输出JSON
masscan 192.168.1.0/24 -p80 --rate=10000 -oJ results.json
# 指定源IP(需路由配置)
masscan 10.0.0.0/8 -p80 --rate=100000 --adapter-ip 10.0.0.1
5.1.3 zmap(学术级扫描)
bash
# 安装
apt install zmap
# 扫描80端口
zmap -p 80 -o results.txt 192.168.1.0/24
# 带带宽限制
zmap -p 80 -B 10M -o results.txt 192.168.1.0/24
5.2 CDN绕过技巧
CDN(内容分发网络)会隐藏源站真实IP,绕过CDN找到真实IP是渗透测试的关键一步。
5.2.1 CDN检测方法
bash
# 多地ping检测
# 使用 https://www.cdnplanet.com/tools/cdnfinder/
# 或 https://www.itdog.cn/ping/example.com
# dig 检查CNAME
dig example.com | grep -i cname
# 检查响应头中的CDN标识
curl -I https://example.com | grep -i "server\|cdn\|cloudflare\|akamai"
# 使用IP库查询
curl -s "https://ipinfo.io/$(dig +short example.com | tail -1)"
5.2.2 真实IP获取策略
| 策略 | 原理 | 工具/方法 |
|---|---|---|
| 历史DNS记录 | CDN启用前的解析 | 微步在线/IPRI/history DNS |
| 子域名 | 子站可能未挂CDN | subfinder+ping |
| 邮件服务器 | 邮件头含源站IP | 收发邮件查看header |
| SSL证书 | 证书含源站IP | Censys证书搜索 |
| FOFA/Shodan | 空间测绘反查 | host="example.com" |
| 网站泄露 | 错误页/调试信息 | Google Hacking |
| 国外访问 | 部分CDN只覆盖国内 | 国外VPS ping |
| APP抓包 | APP直连源站 | 抓包分析 |
bash
# 策略1:历史DNS记录查询
# 使用SecurityTrails、DNSDB、ViewDNS
curl -s "https://viewdns.info/iphistory/?domain=example.com"
# 策略2:子域名逐一ping
cat all_subs.txt | while read sub; do
ip=$(dig +short $sub | tail -1)
echo "$sub -> $ip"
done | grep -v "CDN\|cloudflare"
# 策略3:邮件头分析
# 收到目标邮件后查看邮件原文的Received头
# Received: from mail.example.com ([1.2.3.4])
# 策略4:Censys证书反查
# parsed.names: example.com 然后看IP
# 策略5:FOFA反查
# host="example.com" && country="CN" 排除已知CDN段
5.3 ASN信息查询
ASN(自治系统号)可定位组织拥有的IP段:
bash
# 使用BGP查询工具
# https://bgp.he.net/
# 命令行查询ASN
whois -h whois.cymru.com " -v 8.8.8.8"
# 使用pyasn库
pip install pyasn
# 下载BGP数据
pyasn_util_download.py --latest
pyasn_util_convert.py --to-table ipasn.dat ipasn.csv
# Python查询ASN
from pyasn import asndb
db = asndb("ipasn.dat")
asn, prefix = db.lookup("8.8.8.8")
print(f"ASN: {asn}, Prefix: {prefix}")
5.4 IP地理定位
bash
# 在线查询
# https://www.ipip.net/
# https://www.maxmind.com/
# 命令行
curl -s "https://ipinfo.io/8.8.8.8/json" | jq
# 本地数据库(MaxMind GeoLite2)
# 下载GeoLite2-City.mmdb
# 使用geoip2库查询
python
import geoip2.database
reader = geoip2.database.Reader("GeoLite2-City.mmdb")
response = reader.city("8.8.8.8")
print(response.country.name, response.city.name)
print(response.location.latitude, response.location.longitude)
六、人员与社会工程情报
人员情报是红队评估与定向钓鱼的关键输入。
6.1 社交媒体情报
| 平台 | 可获取信息 | 技巧 |
|---|---|---|
| 职位、邮箱格式、组织架构 | site:linkedin.com "company" | |
| 观点、位置、时间习惯 | 高级搜索、时间线分析 | |
| 家庭、朋友、行程 | Graph搜索(已收紧) | |
| 照片、位置、生活方式 | EXIF、地理标签 | |
| GitHub | 技术栈、邮箱、泄露 | 邮箱搜索、commit分析 |
| WeChat/微博 | 国内动态、社交圈 | 关键词搜索 |
LinkedIn搜索示例:
text
# Google搜索
site:linkedin.com/in "example.com"
# 查找某公司员工
site:linkedin.com "Example Inc" "engineer"
# 查找邮箱格式
site:linkedin.com "Example Inc" "@example.com"
6.2 用户名追踪
同一用户名常在多个平台复用,追踪用户名可扩大信息面。
6.2.1 Sherlock
bash
# 安装
git clone https://github.com/sherlock-project/sherlock.git
pip install -r requirements.txt
# 单用户名查询
python3 sherlock.py targetuser
# 多用户名
python3 sherlock.py user1 user2 user3
# 输出文件
python3 sherlock.py targetuser --print-found --timeout 5
# 指定站点
python3 sherlock.py targetuser --site GitHub,Twitter,Instagram
6.2.2 Namechk / WhatsMyName
bash
# WhatsMyName(支持300+站点)
git clone https://github.com/WebBreacher/WhatsMyName.git
python3 whats_my_name.py -u targetuser
# Web版
# https://namechk.com/
6.3 邮箱情报
6.3.1 theHarvester
bash
# 安装
pip install theharvester
# 查询邮箱与子域名
theHarvester -d example.com -b all
# 指定数据源
theHarvester -d example.com -b google,linkedin,virustotal
# 输出文件
theHarvester -d example.com -b all -f results.xml
6.3.2 Hunter / EmailRep
python
# Hunter API(查询邮箱格式与人员)
import requests
api_key = "YOUR_HUNTER_KEY"
domain = "example.com"
url = f"https://api.hunter.io/v2/email-finder?domain={domain}&api_key={api_key}"
resp = requests.get(url)
print(resp.json())
# EmailRep(邮箱信誉查询)
resp = requests.post(
"https://emailrep.io/test@example.com"
)
print(resp.json())
6.4 电话号码情报
bash
# 电话号码解析
pip install phonenumbers
# 查询号码归属与运营商
python -c "import phonenumbers; from phonenumbers import carrier, geocoder; n = phonenumbers.parse('+8613800000000', None); print(carrier.name_for_number(n, 'en'), geocoder.description_for_number(n, 'en'))"
6.5 人员关联分析(Maltego)
Maltego是图形化情报分析利器,通过Transforms可将人员、邮箱、域名、IP、公司等实体关联成关系网。
核心概念:
- Entities(实体):Person、Email、Domain、IP等节点类型
- Transforms(变换):从实体扩展新实体的查询逻辑
- Machines(机器):批量执行多个Transform的工作流
使用流程:
text
1. 新建Graph,拖入Person实体
2. 右键 -> Run Transform -> Search public records
3. 关联出Email、Phone、Social Account
4. 继续展开Email -> 关联Domain、泄露事件
5. 最终生成完整人员关系图
6.6 完整人员侦察流程
text
1. LinkedIn搜索 -> 确认目标公司员工姓名
2. Google "site:linkedin.com 公司名" -> 收集员工列表
3. Hunter -> 查询邮箱格式(如 first.last@example.com)
4. theHarvester -> 验证邮箱存在性
5. Sherlock -> 追踪用户名跨平台账号
6. EmailRep -> 查询邮箱信誉与泄露记录
7. Maltego -> 图形化关联人员、邮箱、域名
8. 输出人员画像(职位、邮箱、社交账号、技术栈)
七、代码与泄露情报
代码仓库与文档泄露是高危但极易被忽视的OSINT方向。
7.1 GitHub代码搜索
7.1.1 GitHub高级搜索语法
| 语法 | 含义 | 示例 |
|---|---|---|
| filename: | 文件名 | filename:.env |
| path: | 路径 | path:/.github |
| extension: | 扩展名 | extension:py |
| user: | 用户 | user:targetuser |
| org: | 组织 | org:targetorg |
| language: | 语言 | language:python |
| size: | 文件大小 | size:>10000 |
| pushed: | 推送时间 | pushed:>2025-01-01 |
7.1.2 GitDorker
bash
# 安装
git clone https://github.com/obheda12/GitDorker.git
pip install -r requirements.txt
# 配置GitHub Token
echo "YOUR_GITHUB_TOKEN" > GitDorker/Source/tokens.txt
# 使用默认字典
python3 GitDorker.py -t tokens.txt -d example.com -dq keywords.txt
# 使用内置dorks
python3 GitDorker.py -t tokens.txt -d example.com
7.1.3 gitleaks(仓库扫描)
bash
# 安装
# https://github.com/gitleaks/gitleaks/releases
# 扫描仓库历史
gitleaks detect --repo=https://github.com/user/repo
# 扫描本地目录
gitleaks detect --source=./project --report-path=results.json
# 扫描commit范围
gitleaks detect --source=./project --log-opts="--all"
# 自定义规则
gitleaks detect --source=./project --config=gitleaks.toml
自定义规则示例:
toml
[[rules]]
id = "aws-access-key"
description = "AWS Access Key"
regex = '''AKIA[0-9A-Z]{16}'''
tags = ["aws", "key"]
[[rules]]
id = "private-key"
description = "Private Key"
regex = '''-----BEGIN (RSA|EC|DSA|OPENSSH) PRIVATE KEY-----'''
tags = ["key", "private"]
[[rules]]
id = "database-url"
description = "Database URL"
regex = '''(postgres|mysql|mongodb)://[^\s]+:[^\s]+@[^\s]+'''
tags = ["db", "credentials"]
7.1.4 trufflehog / gitrob
bash
# trufflehog(支持200+检测器)
# https://github.com/trufflesecurity/trufflehog
# 扫描仓库
trufflehog github --repo=https://github.com/user/repo
# 扫描组织
trufflehog github --org=targetorg
# 扫描文件系统
trufflehog filesystem --directory=./project
# gitrob(旧版工具)
gitrob targetuser
gitrob --organization targetorg
7.2 代码仓库泄露检测重点
text
# 高危泄露类型
1. API密钥(AWS、Google、Stripe、Azure)
2. 数据库连接字符串
3. 私钥/证书(.pem/.key/.p12)
4. OAuth Token / JWT Secret
5. 配置文件(.env、config.yml、settings.py)
6. 硬编码密码(password = "xxx")
7. 内部IP与域名
8. 备份文件(.bak、.sql)
9. CI/CD配置泄露(.gitlab-ci.yml、Jenkinsfile)
10. 云存储凭证(S3、OSS、COS)
7.3 Pastebin泄露监控
bash
# psbdmp(Pastebin dump监控)
# https://psbdmp.ws/
# 查询目标相关泄露
curl -s "https://psbdmp.ws/api/search/example.com" | jq
# 自动化监控
while true; do
curl -s "https://psbdmp.ws/api/search/example.com" >> pastebin.log
sleep 3600
done
# Google搜索Pastebin
site:pastebin.com "example.com" "password"
site:pastebin.com "example.com" "@example.com"
7.4 网盘泄露检测
text
# Google搜索网盘泄露
site:pan.baidu.com "example.com"
site:drive.google.com "confidential" "example.com"
site:trello.com "example.com"
# 百度网盘关键词搜索(第三方工具)
# 盘搜搜、盘多多等
7.5 文档泄露搜索
text
# Google搜索敏感文档
filetype:pdf "confidential" site:example.com
filetype:doc "internal" site:example.com
filetype:xls "员工" site:example.com
filetype:ppt "roadmap" site:example.com
# 搜索暴露的财务文档
filetype:xls "balance sheet" site:example.com
filetype:pdf "annual report" site:example.com
7.6 泄露情报自动化监控
python
# leak_monitor.py - 泄露情报自动化监控
import requests
import json
from datetime import datetime
TARGET_DOMAIN = "example.com"
ALERT_KEYWORDS = ["password", "secret", "api_key", "token", "private key"]
def check_pastebin(domain):
url = f"https://psbdmp.ws/api/search/{domain}"
resp = requests.get(url)
return resp.json().get("data", [])
def check_github(domain):
headers = {"Authorization": "token YOUR_GITHUB_TOKEN"}
url = "https://api.github.com/search/code"
params = {"q": f"{domain} password"}
resp = requests.get(url, headers=headers, params=params)
return resp.json().get("items", [])
def alert(item, source):
print(f"[ALERT][{source}] {datetime.now()}: {item}")
if __name__ == "__main__":
pastes = check_pastebin(TARGET_DOMAIN)
for p in pastes:
content = p.get("content", "").lower()
if any(k in content for k in ALERT_KEYWORDS):
alert(p, "pastebin")
codes = check_github(TARGET_DOMAIN)
for c in codes:
alert(c.get("html_url"), "github")
八、Web应用指纹识别
Web指纹识别是判断目标技术栈、定位已知漏洞的基础。
8.1 Wappalyzer
bash
# 命令行版
npm install -g wappalyzer
wappalyzer https://example.com
# 浏览器插件版(最常用)
# 直接在Chrome/Firefox安装Wappalyzer扩展
# 批量扫描
wappalyzer https://site1.com https://site2.com
8.2 whatweb
bash
# 安装
gem install whatweb
# 单目标
whatweb https://example.com
# 批量扫描
whatweb -i urls.txt
# 详细模式
whatweb -v https://example.com
# 聚合输出
whatweb --aggressive https://example.com
# 自定义插件
whatweb --color=never https://example.com
8.3 httpx批量探测
bash
# 安装
go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest
# 基础探测
cat subs.txt | httpx
# 指纹识别(集成Wappalyzer指纹库)
cat subs.txt | httpx -title -tech-detect -status-code
# 截图
cat subs.txt | httpx -screenshot
# 输出JSON
cat subs.txt | httpx -json -o results.json
# 指定线程与超时
cat subs.txt | httpx -t 50 -timeout 10
# 跟随跳转
cat subs.txt | httpx -follow-redirects
8.4 指纹库对比
| 指纹库 | 维护方 | 特点 | 集成方式 |
|---|---|---|---|
| Wappalyzer | Wappalyzer | 覆盖最广 | 浏览器/CLI |
| FingerprintHub | 项目 | 国内应用友好 | httpx集成 |
| fingerprintx | ProjectDiscovery | 快速TCP识别 | 独立工具 |
| httpx内置 | ProjectDiscovery | 一体化 | httpx参数 |
8.5 CMS识别
bash
# WordPress识别与枚举
wpscan --url https://example.com --enumerate u,p,t
# Drupal识别
droopescan scan drupal -u https://example.com
# Joomla识别
joomscan -u https://example.com
# 通用CMS识别
whatweb https://example.com | grep -i "cms\|wordpress\|drupal\|joomla"
8.6 Web中间件与框架识别
| 中间件/框架 | 指纹特征 | 识别方法 |
|---|---|---|
| Nginx | Server: nginx/版本 |
响应头 |
| Apache | Server: Apache/版本 |
响应头 |
| Tomcat | 默认页/Server: Apache-Coyote |
响应头+页面 |
| IIS | Server: Microsoft-IIS/版本 |
响应头 |
| Spring | /actuator端点、X-Application-Context |
路径+头 |
| Django | csrfmiddlewaretoken、X-Frame-Options |
页面+头 |
| Flask | Debug页、Server: Werkzeug |
错误页 |
| Express | X-Powered-By: Express |
响应头 |
| Laravel | laravel_session Cookie |
Cookie |
| ThinkPHP | 报错页含ThinkPHP字样 | 错误页 |
bash
# 框架识别实战
curl -sI https://example.com | grep -i "server\|x-powered-by\|x-frame"
# Spring Actuator探测
for path in /actuator /env /heapdump /metrics /trace; do
curl -s -o /dev/null -w "%{http_code} https://example.com$path\n" https://example.com$path
done
# Flask Debug模式探测
curl -s https://example.com/nonexistent_page | grep -i "werkzeug\|debugger"
九、暗网情报
暗网(Dark Web)是OSINT的高风险但高价值领域。
9.1 Tor网络基础
bash
# 安装Tor
apt install tor
# 启动Tor服务
service tor start
# 配置SOCKS5代理(默认9050端口)
# 浏览器配置Tor Browser
# 命令行通过Tor代理
curl --socks5-hostname 127.0.0.1:9050 https://check.torproject.org/
9.2 暗网搜索引擎
| 搜索引擎 | 地址 | 特点 |
|---|---|---|
| Ahmia | ahmia.fi |
Clearnet可访问,索引.onion |
| Tor66 | tor66sewebt...onion |
综合搜索 |
| OnionLand | onionlandsearch.com |
Clearnet前端 |
| Haystak | haystak...onion |
付费索引 |
| Reeddit | reedd...onion |
暗网论坛 |
bash
# Ahmia搜索
curl --socks5-hostname 127.0.0.1:9050 "https://ahmia.fi/search/?q=example.com"
# 通过Clearnet使用Ahmia
curl -s "https://ahmia.fi/search/?q=example+leak"
9.3 暗网市场监控
text
# 监控重点
1. 数据泄露市场(如RaidForums替代品)
2. 勒索软件泄露站(LockBit等)
3. 凭证交易论坛
4. 目标品牌提及监控
# 自动化监控思路
- 暗网市场爬虫(需遵守法律)
- 关键词订阅(品牌名、域名、员工邮箱)
- Telegram暗网频道监控
9.4 泄露数据查询
9.4.1 Have I Been Pwned(HIBP)
python
import requests
# 查询邮箱是否泄露
email = "test@example.com"
url = f"https://haveibeenpwned.com/api/v3/breachedaccount/{email}"
headers = {"hibp-api-key": "YOUR_HIBP_KEY"}
resp = requests.get(url, headers=headers)
print(resp.json())
# 查询密码是否泄露(k-anonymity)
import hashlib
password = "Password123"
sha1 = hashlib.sha1(password.encode()).hexdigest().upper()
prefix = sha1[:5]
suffix = sha1[5:]
url = f"https://api.pwnedpasswords.com/range/{prefix}"
resp = requests.get(url)
for line in resp.text.splitlines():
s, count = line.split(":")
if s == suffix:
print(f"Password leaked {count} times")
9.4.2 dehashed / leakcheck
python
# dehashed API
import requests
api_key = "YOUR_DEHASHED_KEY"
email = "test@example.com"
headers = {"Authorization": f"Bearer {api_key}"}
url = f"https://api.dehashed.com/search?query=email:{email}"
resp = requests.get(url, headers=headers)
print(resp.json())
9.5 暗网情报自动化收集
python
# darkweb_monitor.py - 暗网情报自动化收集
import requests
import json
SOCKS_PROXY = {"https": "socks5h://127.0.0.1:9050"}
def search_ahmia(keyword):
url = f"https://ahmia.fi/search/?q={keyword}"
try:
resp = requests.get(url, proxies=SOCKS_PROXY, timeout=30)
return resp.text
except Exception as e:
print(f"Error: {e}")
return ""
def check_hibp(email, api_key):
url = f"https://haveibeenpwned.com/api/v3/breachedaccount/{email}"
headers = {"hibp-api-key": api_key}
try:
resp = requests.get(url, headers=headers)
if resp.status_code == 200:
return resp.json()
return []
except Exception as e:
print(f"Error: {e}")
return []
if __name__ == "__main__":
TARGET = "example.com"
print("[*] Searching Ahmia...")
search_ahmia(TARGET)
print("[*] Checking HIBP...")
breaches = check_hibp(f"admin@{TARGET}", "YOUR_KEY")
for b in breaches:
print(f" - Breach: {b['Name']}, Date: {b['BreachDate']}")
十、OSINT自动化框架
10.1 Maltego
Maltego是图形化情报分析平台,核心三要素:
- Entities:节点类型(Person、Email、Domain、IP、Phone等)
- Transforms:从一个节点扩展到相关节点的查询逻辑
- Machines:自动化执行多Transform的工作流
使用流程:
text
1. 创建新Graph
2. 从左侧Palette拖入实体(如Domain: example.com)
3. 右键实体 -> Run Transform
4. 选择Transform(如DNS Lookup、Email from Domain)
5. 结果生成新节点,继续扩展
6. 保存Graph,导出为图片或PDF
社区版免费,商业版(Maltego CE/Pro/Enterprise)提供更多Transform与API Hub。
10.2 SpiderFoot
SpiderFoot是开源的自动化OSINT平台,支持200+模块。
bash
# 安装
git clone https://github.com/smicallef/spiderfoot.git
cd spiderfoot
pip install -r requirements.txt
# 启动Web界面
python3 spiderfoot.py -l 127.0.0.1:5001
# 命令行扫描
python3 spiderfoot.py -s example.com -t "email,ip,domain" -q
# 使用预设模块
python3 spiderfoot.py -s example.com -t ALL
模块配置(spiderfoot.conf):
ini
# 各数据源API Key
[hunter]
api_key = YOUR_KEY
[shodan]
api_key = YOUR_KEY
[censys]
api_id = YOUR_ID
api_secret = YOUR_SECRET
[github]
api_key = YOUR_KEY
10.3 theHarvester
bash
# 多源聚合收集
theHarvester -d example.com -b all
# 指定数据源
theHarvester -d example.com -b google,bing,linkedin,virustotal,crtsh
# 输出格式
theHarvester -d example.com -b all -f results.xml
theHarvester -d example.com -b all -f results.json
10.4 Recon-ng
Recon-ng是模块化OSINT框架,类似Metasploit的操作方式。
bash
# 安装
pip install recon-ng
recon-ng
# 基础操作
[recon-ng] > marketplace install all
[recon-ng] > modules search
[recon-ng] > modules load recon/domains-hosts/hackertarget
[recon-ng][hackertarget] > options set SOURCE example.com
[recon-ng][hackertarget] > run
# 创建工作区
[recon-ng] > workspaces create example
[recon-ng] > db insert domains domain=example.com
# 仪表盘
[recon-ng] > dashboard
10.5 OSINT自动化脚本编写
python
# osint_pipeline.py - OSINT全流程自动化
import subprocess
import json
from pathlib import Path
class OSINTPipeline:
def __init__(self, domain):
self.domain = domain
self.results = {"domain": domain, "subdomains": [], "emails": [], "ips": []}
def collect_subdomains(self):
# subfinder被动收集
out = subprocess.run(
["subfinder", "-d", self.domain, "-silent"],
capture_output=True, text=True
)
subs = [s.strip() for s in out.stdout.splitlines() if s.strip()]
self.results["subdomains"] = sorted(set(subs))
return self.results["subdomains"]
def collect_emails(self):
out = subprocess.run(
["theHarvester", "-d", self.domain, "-b", "google,linkedin", "-f", "tmp.xml"],
capture_output=True, text=True
)
# 解析结果
return self.results["emails"]
def check_live(self):
subs_file = "subs_tmp.txt"
with open(subs_file, "w") as f:
f.write("\n".join(self.results["subdomains"]))
out = subprocess.run(
["httpx", "-l", subs_file, "-silent", "-json"],
capture_output=True, text=True
)
live = []
for line in out.stdout.splitlines():
try:
live.append(json.loads(line))
except json.JSONDecodeError:
continue
return live
def run(self):
print(f"[*] Collecting subdomains for {self.domain}")
self.collect_subdomains()
print(f" Found {len(self.results['subdomains'])} subdomains")
print(f"[*] Checking live hosts")
live = self.check_live()
print(f" {len(live)} live hosts")
return self.results
if __name__ == "__main__":
p = OSINTPipeline("example.com")
results = p.run()
with open("osint_results.json", "w") as f:
json.dump(results, f, indent=2)
10.6 框架对比表
| 框架 | 类型 | 优势 | 劣势 | 适用场景 |
|---|---|---|---|---|
| Maltego | 图形化 | 关系分析直观 | 免费版限制多 | 人员关联、关系网 |
| SpiderFoot | Web+CLI | 模块多、自动化 | 结果需过滤 | 大规模自动化 |
| theHarvester | CLI | 简单快速 | 数据源有限 | 邮箱与子域名快速收集 |
| Recon-ng | CLI | 模块化、可扩展 | 需手动配置API | 深度侦察 |
| 自定义脚本 | 灵活 | 完全可控 | 开发成本高 | 定制化需求 |
十一、情报分析与可视化
11.1 情报关联分析方法
- 实体关联:将域名、IP、邮箱、人员等实体建立关联关系
- 时间序列分析:按时间戳排序事件,发现行为规律
- 地理分析:结合IP地理定位,绘制空间分布
- 交叉验证:多源数据互相印证,提高可信度
11.2 时间线分析
python
# timeline.py - 情报时间线分析
from datetime import datetime
events = [
{"time": "2025-01-15", "event": "Domain registered", "source": "whois"},
{"time": "2025-03-20", "event": "Subdomain added", "source": "crt.sh"},
{"time": "2025-06-10", "event": "Email leaked", "source": "HIBP"},
{"time": "2025-09-01", "event": "CVE-2025-XXXX disclosed", "source": "NVD"},
]
events.sort(key=lambda x: x["time"])
for e in events:
print(f"{e['time']} | {e['event']} | {e['source']}")
11.3 地理可视化
python
# geo_map.py - IP地理可视化(生成HTML地图)
import folium
from geoip2 import database
reader = database.Reader("GeoLite2-City.mmdb")
ips = ["8.8.8.8", "1.1.1.1", "114.114.114.114"]
m = folium.Map(location=[20, 0], zoom_start=2)
for ip in ips:
resp = reader.city(ip)
if resp.location.latitude:
folium.Marker(
[resp.location.latitude, resp.location.longitude],
popup=f"{ip} - {resp.city.name}"
).add_to(m)
m.save("ip_map.html")
11.4 网络关系图
11.4.1 Gephi(可视化软件)
Gephi适合大规模关系图可视化:
- 导出OSINT数据为GEXF/CSV格式
- 导入Gephi
- 使用Layout算法(ForceAtlas 2)自动布局
- 根据节点属性着色与调整大小
- 导出图片或交互式Web
11.4.2 Neo4j(图数据库)
cypher
// 创建实体
CREATE (d:Domain {name: "example.com"})
CREATE (s:Subdomain {name: "www.example.com"})
CREATE (i:IP {address: "1.2.3.4"})
CREATE (e:Email {address: "admin@example.com"})
CREATE (p:Person {name: "John Doe"})
// 创建关系
CREATE (s)-[:RESOLVES_TO]->(i)
CREATE (d)-[:HAS_SUBDOMAIN]->(s)
CREATE (p)-[:OWNS_EMAIL]->(e)
CREATE (e)-[:BELONGS_TO]->(d)
// 查询关联
MATCH (d:Domain {name: "example.com"})-[:HAS_SUBDOMAIN]->(s)-[:RESOLVES_TO]->(i)
RETURN d, s, i
11.5 威胁画像构建
威胁画像是对目标资产与风险的全面描述:
text
# 威胁画像模板
## 目标概览
- 组织名称:Example Inc
- 主要域名:example.com
- 子域名数量:123
- 关键IP段:1.2.3.0/24
- 技术栈:Nginx + Spring + MySQL + Redis
## 人员画像
- 员工数量(LinkedIn):约500人
- 邮箱格式:first.last@example.com
- 关键人员:CTO/运维负责人
- 社交账号:GitHub/Twitter活跃
## 暴露面
- 开放端口:22, 80, 443, 3306, 6379, 8080
- 后台入口:/admin、/manage
- 暴露服务:Jenkins(无认证)、Redis(无密码)
- 已知CVE:CVE-2025-XXXX(Spring相关)
## 泄露情报
- HIBP:3起数据泄露
- GitHub:发现2个泄露的API Key
- Pastebin:1份内部配置
## 风险评级
- 高危:Jenkins无认证、Redis无密码
- 中危:多个过期证书、弱密码策略
- 低危:信息泄露可被社会工程利用
11.6 情报报告模板
text
# OSINT情报报告
## 1. 执行摘要
[一段话总结目标OSINT发现与风险]
## 2. 目标范围
- 授权范围:example.com 及子域名
- 测试时间:2026-08-01 至 2026-08-10
- 测试人员:[姓名]
## 3. 资产清单
[表格:域名、IP、端口、服务、技术栈]
## 4. 人员情报
[表格:关键人员、职位、邮箱、社交账号]
## 5. 泄露情报
[列表:泄露来源、类型、内容、风险]
## 6. 漏洞与暴露面
[表格:漏洞描述、CVSS、修复建议]
## 7. 风险评级与优先级
[高/中/低分级]
## 8. 修复建议
[针对每类风险的加固方案]
## 9. 附录
[工具列表、原始数据、截图]
11.7 完整分析流程
text
1. 数据收集 -> 多源OSINT采集
2. 数据清洗 -> 去重、格式化、去噪
3. 实体建模 -> 提取Domain/IP/Person/Email节点
4. 关联分析 -> 建立实体间关系
5. 时间线 -> 按时间排序关键事件
6. 空间分析 -> 地理分布可视化
7. 关系图 -> Maltego/Gephi/Neo4j可视化
8. 威胁画像 -> 综合输出目标画像
9. 报告生成 -> 按模板输出文档
十二、OSINT在渗透测试中的应用
12.1 攻击面发现
攻击面 = 资产 + 技术栈 + 人员 + 业务
| 维度 | OSINT发现 | 攻击利用 |
|---|---|---|
| 资产 | 子域名、IP、端口 | 找到未被监控的系统 |
| 技术栈 | CMS、框架、版本 | 定位已知CVE |
| 人员 | 邮箱、职位、习惯 | 钓鱼、社会工程 |
| 业务 | 业务流程、API、功能 | 业务逻辑漏洞 |
12.2 钓鱼目标画像
text
# 钓鱼目标画像构建
1. LinkedIn查询 -> 确定关键岗位人员
- 运维工程师、财务、HR(高点击率)
2. Hunter -> 获取邮箱格式
3. 社交媒体 -> 了解兴趣、习惯
4. GitHub -> 技术栈与常用工具
5. 构造针对性钓鱼邮件:
- 主题:与业务/技术相关
- 发件人:冒充内部或供应商
- 附件:含恶意宏的文档
- 落地页:仿冒登录页
12.3 社会工程信息收集
text
# 社会工程OSINT清单
- 目标姓名、职位、工号
- 邮箱、手机、座机
- 上级、下属、同事
- 入职时间、离职时间
- 常用技术、工具
- 兴趣爱好(钓鱼话题)
- 行程安排(出差/会议)
- 社交圈(信任关系)
- 紧急联系人(伪造场景)
12.4 漏洞情报关联
python
# vuln_correlation.py - 漏洞情报关联
import requests
# 从NVD查询CVE
def query_cve(keyword):
url = f"https://services.nvd.nist.gov/rest/json/cves/2.0"
params = {"keywordSearch": keyword}
resp = requests.get(url, params=params, timeout=30)
return resp.json().get("vulnerabilities", [])
# 关联指纹与CVE
fingerprint = {"product": "Apache", "version": "2.4.49"}
cves = query_cve(f"{fingerprint['product']} {fingerprint['version']}")
for cve in cves:
cve_id = cve["cve"]["id"]
description = cve["cve"]["descriptions"][0]["value"]
print(f"[!] {cve_id}: {description[:100]}")
12.5 红队侦察流程
text
# 红队OSINT侦察标准流程(参考PTES)
## Phase 1: 资产测绘(0-3天)
- 域名与子域名收集
- IP段扫描
- 网络空间测绘查询
- 资产分组与优先级
## Phase 2: 技术栈识别(3-5天)
- Web指纹识别
- 中间件与框架识别
- CVE关联
- 漏洞验证PoC
## Phase 3: 人员情报(5-7天)
- LinkedIn员工收集
- 邮箱格式推断
- 社交媒体行为分析
- 钓鱼目标画像
## Phase 4: 泄露情报(7-10天)
- GitHub代码扫描
- Pastebin监控
- HIBP查询
- 文档泄露搜索
## Phase 5: 报告输出(10-14天)
- 攻击面报告
- 钓鱼方案
- 漏洞清单
- 行动建议
12.6 完整实战案例
【提示】 以下案例为模拟场景,所有目标与数据均为虚构,仅用于演示OSINT在授权渗透测试中的应用流程。
text
# 模拟目标:example-corp.com(虚构企业)
## Step 1: 子域名收集
subfinder -d example-corp.com -> 156个子域名
crt.sh查询 -> 新增23个子域名
amass被动 -> 新增5个子域名
合计:184个子域名
## Step 2: 存活探测
httpx -l subs.txt -> 89个存活Web服务
## Step 3: 指纹识别
whatweb批量 -> 发现:
- 60个Nginx
- 15个Apache
- 10个Spring Boot(含Actuator暴露)
- 4个WordPress
## Step 4: 高危发现
- jenkins.example-corp.com: Jenkins无认证,可执行命令
- git.example-corp.com: GitLab注册开放
- old.example-corp.com: 旧站Spring Boot Actuator /env泄露
## Step 5: 人员情报
LinkedIn查询 -> CTO: John Doe, email: john.doe@example-corp.com
Hunter验证邮箱格式 -> first.last@example-corp.com
## Step 6: 泄露情报
GitHub搜索 -> 发现运维工程师提交了AWS Key
HIBP -> 30个员工邮箱在5起泄露中
## Step 7: 报告输出
生成攻击面报告,建议优先修复Jenkins、GitLab、Actuator,并对员工进行安全意识培训。
十三、防御与反制
13.1 信息泄露防护
| 防护措施 | 说明 | 实施方法 |
|---|---|---|
| DLP系统 | 数据泄露防护 | 部署终端/网络DLP |
| 数据脱敏 | 敏感信息处理 | 日志脱敏、API响应脱敏 |
| 文档水印 | 追踪泄露源 | 隐性水印(数字水印) |
| 代码审查 | 防止提交敏感信息 | pre-commit hook + gitleaks |
| 访问控制 | 最小权限原则 | RBAC、MFA |
gitleaks pre-commit hook配置:
yaml
# .pre-commit-config.yaml
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.0
hooks:
- id: gitleaks
13.2 搜索引擎索引控制
text
# robots.txt(仅防合规爬虫,非安全手段)
User-agent: *
Disallow: /admin/
Disallow: /internal/
Disallow: /backup/
# 防止索引的meta标签(HTML头)
<meta name="robots" content="noindex, nofollow">
# HTTP头 X-Robots-Tag
X-Robots-Tag: noindex, noarchive
# 敏感目录配置(Nginx)
location /admin/ {
add_header X-Robots-Tag "noindex, nofollow";
# 加访问控制
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
}
【提示】 robots.txt本身是公开可读的,反而会暴露敏感目录路径。不要将敏感目录写进robots.txt作为"隐藏"手段。敏感目录应通过认证与授权保护,而非依赖爬虫协议。
13.3 子域名安全
| 风险 | 防护措施 |
|---|---|
| 子域名接管 | 释放外部服务后及时删除CNAME;定期扫描接管 |
| 子域名暴露 | 内部子域名不解析公网;使用VPN访问 |
| DNS劫持 | DNSSEC、多DNS服务商 |
| 子域名枚举 | DNS泛解析(但影响被动收集) |
子域名监控脚本:
bash
# subdomain_monitor.sh - 子域名变更监控
DOMAIN=example.com
KNOWN_FILE=known_subs.txt
# 获取当前子域名
subfinder -d $DOMAIN -silent > current_subs.txt
# 对比新增
if [ -f "$KNOWN_FILE" ]; then
NEW=$(comm -13 <(sort $KNOWN_FILE) <(sort current_subs.txt))
if [ -n "$NEW" ]; then
echo "[!] New subdomains detected:"
echo "$NEW"
# 发送告警(邮件/钉钉/Slack)
fi
fi
# 更新已知列表
mv current_subs.txt $KNOWN_FILE
13.4 社交媒体隐私设置
| 平台 | 建议设置 |
|---|---|
| 隐藏员工列表(需企业版)、限制连接可见 | |
| 关闭位置、保护推文 | |
| 朋友仅可见、关闭时间线标记 | |
| 私密账号、关闭活动状态 | |
| GitHub | 邮箱设为私密、不泄露公司域名邮箱 |
13.5 暗网泄露监控
text
# 企业暗网监控方案
1. 订阅商业暗网监控服务(如ZeroFox、Recorded Future)
2. 自建HIBP API监控员工邮箱
3. 监控Pastebin与暗网市场关键词
4. Telegram暗网频道监控机器人
5. 定期审计已泄露凭证并强制改密
13.6 反OSINT策略表
| OSINT方向 | 反制策略 |
|---|---|
| 搜索引擎 | noindex、敏感内容登录可见 |
| 网络空间测绘 | 关闭不必要端口、修改默认Banner、WAF |
| 子域名 | 内部子域名不公网解析、接管监控 |
| 人员情报 | 社交媒体隐私设置、员工安全意识培训 |
| 代码泄露 | pre-commit hook、代码仓库权限管控 |
| 文档泄露 | 文档水印、DLP、访问审计 |
| 暗网泄露 | 凭证监控、MFA、密码策略 |
十四、总结与参考资源
14.1 OSINT工具速查表
| 类别 | 工具 | 用途 |
|---|---|---|
| 搜索引擎 | Google/Bing/Baidu/Yandex/DuckDuckGo | 通用搜索 |
| Google Hacking | GHDB | Dork库 |
| 网络空间测绘 | Shodan/Censys/FOFA/ZoomEye/Quake/Hunter/Space | 资产测绘 |
| 子域名 | subfinder/amass/oneforall/sublist3r/knockpy | 子域名发现 |
| DNS枚举 | dig/nslookup/fierce/dnsenum/dnsrecon | DNS查询 |
| 证书透明度 | crt.sh/Censys | 子域名与证书 |
| 接管检测 | subjack/SubOver/nihilist | 子域名接管 |
| 端口扫描 | nmap/masscan/zmap | 端口与服务 |
| CDN绕过 | 历史DNS/FOFA/邮件头/SSL | 真实IP |
| ASN查询 | BGP/whois/pyasn | IP段归属 |
| IP地理 | MaxMind/ipip | 地理定位 |
| 社交媒体 | LinkedIn/Twitter/GitHub | 人员情报 |
| 用户名追踪 | Sherlock/Namechk/WhatsMyName | 跨平台追踪 |
| 邮箱情报 | Hunter/EmailRep/theHarvester | 邮箱发现 |
| 电话情报 | phonenumbers | 号码解析 |
| 人员关联 | Maltego | 关系图 |
| 代码泄露 | GitDorker/gitleaks/trufflehog/gitrob | 代码扫描 |
| Pastebin | psbdmp | 泄露监控 |
| Web指纹 | Wappalyzer/whatweb/httpx | 技术栈识别 |
| CMS识别 | wpscan/droopescan/joomscan | CMS枚举 |
| 暗网搜索 | Ahmia/Tor66/OnionLand | 暗网检索 |
| 泄露查询 | HIBP/dehashed/leakcheck | 凭证泄露 |
| 自动化框架 | SpiderFoot/theHarvester/Recon-ng | 多源聚合 |
| 可视化 | Maltego/Gephi/Neo4j/folium | 关系与地图 |
| 漏洞情报 | NVD/Exploit-DB | CVE关联 |
| 文档泄露 | Google filetype | 文档搜索 |
| 网盘泄露 | Google site | 网盘搜索 |
| 历史DNS | SecurityTrails/ViewDNS | DNS历史 |
| 反查 | FOFA host/Shodan hostname | 资产反查 |
14.2 搜索语法速查表
| 平台 | 语法示例 |
|---|---|
site:inurl:intext:intitle:filetype:cache:-OR:"":*.. |
|
| Shodan | country:city:port:org:hostname:os:product:version:net:vuln:title: |
| Censys | services.service_name:parsed.names:autonomous_system.asn:location.country_code: |
| FOFA | ip=port=protocol=title=domain=host=body=header=icon_hash=cert=app= |
| ZoomEye | app:country:port:service:device:after: |
| Quake | domain:ip:port:app:country:title: |
| Hunter | domain=ip.port=web.title=app.product= |
| GitHub | filename:path:extension:user:org:language:size:pushed: |
14.3 学习资源列表
| 资源 | 类型 | 地址 |
|---|---|---|
| OSINT Framework | 目录 | osintframework.com |
| Trace Labs | 实战 | traelabs.com |
| OSINT Dojo | 培训 | osintdojo.com |
| SANS SEC587 | 课程 | OSINT课程 |
| Maltego Academy | 培训 | maltego.com/academy |
| SpiderFoot Docs | 文档 | spiderfoot.net/docs |
| Shodan Docs | 文档 | help.shodan.io |
| FOFA Docs | 文档 | fofa.info/static_pages/ |
| John Kim 100+ OSINT | 书籍 | 《Open Source Intelligence Techniques》 |
| Bellingcat | 案例 | bellingcat.com |
14.4 参考资源列表
| 资源 | 用途 |
|---|---|
| Exploit-DB GHDB | Google Dork库 |
| NVD | CVE数据库 |
| crt.sh | 证书透明度 |
| SecurityTrails | DNS与资产历史 |
| ViewDNS | DNS历史与反查 |
| bgp.he.net | ASN查询 |
| ipinfo.io | IP信息 |
| ipip.net | 国内IP库 |
| HIBP | 邮箱泄露 |
| dehashed | 综合泄露查询 |
| Ahmia | 暗网搜索 |
| PasteBin | 文本泄露 |
| Hunter | 邮箱发现 |
| theHarvester | 多源聚合 |
| Maltego Graph | 关系可视化 |
14.5 合规声明
【提示】 本文所有OSINT技术、工具、命令与案例仅用于授权安全测试、CTF竞赛、学术研究与防御建设。在实际操作中,请务必:
- 取得目标书面授权,明确测试范围与时间窗口;
- 遵守《中华人民共和国网络安全法》《数据安全法》《个人信息保护法》及相关法律法规;
- 不采集、存储、传输未授权的个人信息;
- 不对目标系统进行超出授权的主动扫描与探测;
- 发现的漏洞与泄露信息应及时通报给责任方并协助修复,不得公开传播或牟利;
- 保留所有操作日志以备审计。
作者不对任何滥用本文技术造成的法律后果承担责任。安全研究的最终目的是让互联网更安全,而非相反。
结语
OSINT是网络安全攻防的"第一公里",也是最具性价比的情报来源。一名优秀的渗透测试工程师或威胁情报分析师,往往不是工具用得最多的,而是对信息源的敏感度最高、关联分析能力最强的。本文从方法论到工具,从被动收集到主动测绘,从人员情报到暗网监控,力求构建一个完整的OSINT知识体系。
记住三句话:
- OSINT不是"搜一搜",而是结构化的情报周期;
- 工具是手段,关联分析才是核心竞争力;
- 合规是底线,技术能力越大,责任越大。
希望本文能成为你OSINT学习路上的实用参考。持续学习,持续实践,让每一次信息收集都为安全建设添砖加瓦。

