raghav-bansal13/OSINT-Threatlink
GitHub: raghav-bansal13/OSINT-Threatlink
一个自动化 OSINT 协调平台,通过编排多个开源情报工具实现从单点标识到组织数字足迹的全链路被动侦察与攻击面映射。
Stars: 0 | Forks: 0
# OSINT-ThreatLink 模块 1:OSINT 协调器
## 📋 概述
模块 1 通过协调多个 OSINT 工具来映射组织的数字足迹,从而自动化网络安全评估的侦察阶段。
## 🎯 功能
- **子域名发现**:使用 subfinder 自动查找所有子域名
- **DNS 情报**:提取 A、MX、NS 和 TXT 记录
- **WHOIS 查询**:收集域名注册信息
- **Web 探测**:异步探测端点并检测技术栈
- **邮件情报**:检查邮箱注册情况和数据泄露暴露
- **社交媒体 OSINT**:搜寻社交媒体资料
- **自动关联**:链接发现的资产(邮箱、用户名、域名)
## 📁 项目结构
```
osint-threatlink/
├── config.py # Configuration settings
├── orchestrator.py # Main orchestration engine
├── test_orchestrator.py # Test suite
├── requirements.txt # Python dependencies
├── output/ # Raw tool outputs
│ ├── subfinder_results.txt
│ ├── holehe_results.txt
│ └── sherlock/
├── data/ # Processed JSON results
│ └── osint_results_*.json
└── logs/ # Execution logs
└── orchestrator.log
```
## 🔧 安装说明
### 前置条件
- Python 3.9+
- Git
- Windows PowerShell / 命令提示符
### 步骤 1:克隆/设置项目
```
# 创建项目目录
mkdir osint-threatlink
cd osint-threatlink
# 创建虚拟环境
python -m venv osint-env
.\osint-env\Scripts\Activate.ps1
```
### 步骤 2:安装 Python 依赖
```
pip install -r requirements.txt
```
### 步骤 3:安装 Subfinder (二进制)
**选项 A:直接下载 (推荐)**
1. 访问:https://github.com/projectdiscovery/subfinder/releases
2. 下载:`subfinder_*_windows_amd64.zip`
3. 将 `subfinder.exe` 解压到 `C:\osint-tools\`
4. 添加到 PATH:
```
# 临时(当前会话)
$env:Path += ";C:\osint-tools"
# 永久(通过 System Properties > Environment Variables 添加)
# 将 C:\osint-tools 添加到 System PATH
```
**选项 B:通过 Go**
```
go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest
```
### 步骤 4:验证安装
```
python test_orchestrator.py
```
预期输出:
```
✅ All Python modules imported successfully
✅ All CLI tools available
✅ Configuration OK
✅ Orchestrator OK
Results: 4/4 tests passed
```
## 🚀 使用方法
### 基本用法
```
python orchestrator.py
```
### 示例
```
# 扫描单个域名
python orchestrator.py example.com
# 扫描公司域名
python orchestrator.py tesla.com
# 使用 verbose 输出扫描
python orchestrator.py github.com
```
### 输出
协调器将:
1. 在 `output/` 中创建带时间戳的输出文件
2. 在 `data/` 中保存结构化 JSON 结果
3. 将执行详情记录到 `logs/orchestrator.log`
**示例输出:**
```
============================================================
Starting OSINT reconnaissance on: example.com
============================================================
[INFO] Running subfinder on example.com...
[INFO] Found 15 subdomains via subfinder
[INFO] Performing DNS lookups for example.com...
[INFO] Found 2 A records
[INFO] Found 3 MX records
[INFO] Fetching WHOIS data for example.com...
[INFO] WHOIS data retrieved successfully
[INFO] Probing 16 endpoints with httpx...
[INFO] Probed https://example.com: 200 - Example Domain
[INFO] Successfully probed 14/16 endpoints
[INFO] Running holehe on admin@example.com...
[INFO] Found 8 registrations for admin@example.com
============================================================
OSINT reconnaissance completed in 127.45 seconds
============================================================
============================================================
OSINT SUMMARY FOR: example.com
============================================================
Subdomains Found: 15
Emails Found: 2
Social Profiles: 7
Web Endpoints Probed: 14
DNS Records: 8
============================================================
```
## 📊 输出数据结构
### JSON 输出格式
```
{
"target": "example.com",
"timestamp": "20250126_143022",
"subdomains": [
"www.example.com",
"mail.example.com",
"dev.example.com"
],
"emails": [
"admin@example.com",
"contact@example.com"
],
"social_profiles": [
"https://twitter.com/example",
"https://github.com/example"
],
"web_endpoints": [
{
"url": "https://example.com",
"status_code": 200,
"title": "Example Domain",
"server": "nginx",
"content_length": 1256,
"technologies": ["React", "jQuery"],
"headers": {...}
}
],
"whois_data": {
"domain_name": "EXAMPLE.COM",
"registrar": "MarkMonitor Inc.",
"creation_date": "1995-08-14",
"expiration_date": "2025-08-13",
"name_servers": ["a.iana-servers.net"],
"emails": ["admin@example.com"]
},
"dns_records": {
"A": ["93.184.216.34"],
"MX": ["mail.example.com"],
"NS": ["a.iana-servers.net", "b.iana-servers.net"],
"TXT": ["v=spf1 -all"]
}
}
```
## ⚙️ 配置
编辑 `config.py` 以自定义:
### 超时设置
```
SUBFINDER_CONFIG = {
"timeout": 300 # 5 minutes
}
SHERLOCK_CONFIG = {
"timeout": 60 # 1 minute
}
```
### 输出路径
```
OUTPUT_DIR = BASE_DIR / "output"
DATA_DIR = BASE_DIR / "data"
LOGS_DIR = BASE_DIR / "logs"
```
### 详细程度
```
VERBOSE = True # Print detailed logs to console
ENABLE_LOGGING = True # Save logs to file
```
## 🔍 逐工具详解
| 工具 | 用途 | 输入 | 输出 | 速度 |
|------|---------|-------|--------|-------|
| **Subfinder** | 子域名枚举 | 域名 | 子域名列表 | 快 (30-60s) |
| **DNS Python** | DNS 记录查询 | 域名 | A, MX, NS, TXT 记录 | 非常快 (5-10s) |
| **WHOIS** | 域名注册信息 | 域名 | 注册商, 日期, 邮箱 | 快 (5-10s) |
| **httpx** | Web 探测与技术检测 | URLs | 状态, 标题, 技术栈 | 中等 (异步) |
| **Holehe** | 邮箱注册检查 | 邮箱 | 已注册的网站 | 慢 (60-120s) |
| **Sherlock** | 社交媒体用户名搜索 | 用户名 | 社交资料 | 中等 (30-60s) |
## 🐛 故障排除
### 问题:“Subfinder not found”
**解决方案:**
```
# 检查 subfinder 是否在 PATH 中
subfinder -version
# 如果未找到,添加到 PATH
$env:Path += ";C:\path\to\subfinder"
```
### 问题:“Sherlock not found”
**解决方案:**
```
pip install sherlock-project
# 测试
sherlock --version
```
### 问题:“Holehe not found”
**解决方案:**
```
pip install holehe
# 测试
holehe --help
```
### 问题:“TimeoutError”
**解决方案:** 在 `config.py` 中增加超时时间:
```
SUBFINDER_CONFIG = {
"timeout": 600 # Increase to 10 minutes
}
```
### 问题:“No subdomains found”
**可能的原因:**
- 目标域名子域名非常少
- 达到 Subfinder API 速率限制
- 网络连接问题
**解决方案:** 尝试手动运行:
```
subfinder -d example.com -o test.txt
```
### 问题:“httpx errors”
**解决方案:** 检查域名是否可达:
```
# 使用 Python 测试
python -c "import httpx; print(httpx.get('https://example.com').status_code)"
```
## 📈 性能提示
### 速度优化
1. **限制端点探测:**
```
# 在 orchestrator.py 中,第 ~300 行
all_domains = [self.target] + subdomains[:10] # Reduce from 20 to 10
```
2. **跳过慢速工具:**
```
# 在 run_all() 方法中注释掉
# self.run_holehe(email) # Skip holehe (slow)
# self.run_sherlock(username) # Skip sherlock (medium)
```
3. **使用并行处理:**
httpx 探测已使用异步模式。其他工具根据设计按顺序运行。
### 内存优化
对于大规模扫描:
```
# 批量处理结果
BATCH_SIZE = 50
for i in range(0, len(subdomains), BATCH_SIZE):
batch = subdomains[i:i+BATCH_SIZE]
asyncio.run(self.run_httpx_probes(batch))
```
## 🔐 安全注意事项
### 道德使用
⚠️ **重要提示**:仅扫描您拥有或明确获得测试权限的域名。
- 激进扫描可能违反服务条款
- 某些工具查询第三方 API(适用速率限制)
- Web 探测会产生 HTTP 流量(可能被记录)
### 速率限制
内置保护措施:
- Subfinder:使用被动 DNS(无直接扫描)
- httpx:限制为 10 个并发连接
- Sherlock:每个站点的超时设置可防止泛洪
### 匿名性
此工具不提供匿名性:
- 您的 IP 地址会在 HTTP 请求中暴露
- DNS 查询会被解析器记录
- WHOIS 查询可能会被记录
对于敏感评估,请通过 VPN 或代理使用。
## 🎯 下一步是什么?
### 模块 2:数据解析器与关联器 (第 3 天)
- 解析原始工具输出
- 提取实体(IP、邮箱、域名)
- 构建图结构(节点和边)
- 关联关系
### 模块 3:ML 风险评分引擎 (第 4-5 天)
- 启发式基线评分
- 集成钓鱼 URL 分类器
- 对所有资产进行风险评分
### 模块 4:可视化仪表板 (第 6 天)
- Flask 后端 API
- 交互式网络图 (vis.js)
- 颜色编码的风险可视化
## 📝 测试清单
在进入模块 2 之前:
- [ ] 所有工具安装成功
- [ ] 测试套件通过 (4/4 测试)
- [ ] 可以无错误扫描 example.com
- [ ] JSON 输出文件已在 `data/` 中创建
- [ ] 所有 6 个工具执行(检查日志)
- [ ] 发现子域名(如果目标有)
- [ ] Web 端点探测成功
## 🤝 贡献
进入模块 2 时,请保留此结构:
- 保持 `orchestrator.py` 不变
- 模块 2 将使用 JSON 输出
- 模块 3 将向数据添加风险评分
- 模块 4 将可视化最终结果
## 📚 资源
- [Subfinder GitHub](https://github.com/projectdiscovery/subfinder)
- [Sherlock 文档](https://github.com/sherlock-project/sherlock)
- [Holehe GitHub](https://github.com/megadose/holehe)
- [httpx 文档](https://www.python-httpx.org/)
- [OSINT Framework](https://osintframework.com/)
## 📄 许可证
本项目仅用于教育和授权的安全测试。
**🎉 模块 1 完成!准备好进入模块 2:数据解析器与关联器**# OSINT-Threatlink
标签:DNS分析, ESC4, ESC8, FTP漏洞扫描, GitHub, OSINT, Python, Unix, WHOIS查询, 动态插桩, 协议探测, 威胁情报, 子域名挖掘, 安全编排, 实时处理, 密码管理, 开发者工具, 技术栈识别, 数字足迹, 无后门, 社会工程学, 系统监控, 网络安全, 自动化侦察, 资产测绘, 跨平台关联, 运行时操纵, 逆向工具, 邮件泄露检测, 防御态势感知, 隐私保护, 风险评分