bala0304/Threat-Intelligence-Tracker

GitHub: bala0304/Threat-Intelligence-Tracker

一个聚合多源威胁情报数据的综合追踪平台,支持实时 C2 基础设施监控、被动 DNS 与 WHOIS 历史查询,帮助安全团队全面掌握对手基础设施动态。

Stars: 0 | Forks: 0

# 威胁情报追踪器 **实时对手基础设施追踪,支持 C2 监控、被动 DNS 解析、WHOIS 历史记录以及结构化威胁情报源摄取。** ## 🎯 概述 **Threat Intelligence Tracker** 是一个综合性的威胁情报平台,结合了多个数据源来实时追踪对手基础设施。它汇集了来自以下来源的数据: ### 数据源 - **Shodan** - 互联网连接设备扫描 - **Censys** - 互联网数据收集与分析 - **Binary Edge** - 互联网侦察 - **Zoomeye** - 网络空间搜索引擎 - **ThreatFox** (abuse.ch) - 实时 C2 IOCs - **URLhaus** (abuse.ch) - 恶意软件分发 URL - **Passive DNS** - 历史 DNS 解析数据 - **WHOIS** - 域名注册信息 ### 核心功能 ✅ **实时 C2 基础设施追踪** - 监控活跃的命令与控制服务器 ✅ **Passive DNS 集成** - 历史 DNS 解析追踪 ✅ **WHOIS 历史记录** - 域名注册变更监控 ✅ **多源丰富化** - 整合 8 个以上威胁情报源的数据 ✅ **REST API** - 用于编程访问的全面 API ✅ **CLI 工具** - 用于快速查询的命令行界面 ✅ **交互式仪表板** - 使用 Streamlit 进行实时可视化 ✅ **自动化情报源摄取** - 结构化的威胁情报源 ## 🚀 快速开始 ### 前置条件 - Python 3.9+ - PostgreSQL 12+ - 来自威胁情报提供商的 API 密钥(演示可选) ### 安装 ``` # 克隆 repository cd threat-intel-tracker # 创建虚拟环境 python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # 安装依赖 pip install -r requirements.txt # 设置环境 cp .env.example .env # 编辑 .env 并添加你的 API keys # 启动 bundled 本地 PostgreSQL 数据库 docker compose up -d postgres ``` ### 初始化数据库 ``` python main.py cli << 'EOF' from src.database.db import db_manager db_manager.init_db() print("✓ Database initialized") EOF ``` ## 📖 使用说明 ### 1. REST API 服务器 ``` # 启动 API server (运行在 http://localhost:8000) python main.py api # API 将在以下地址可用: # - http://localhost:8000/docs (Swagger UI) # - http://localhost:8000/redoc (ReDoc) ``` ### 2. 交互式仪表板 ``` # 启动 Streamlit dashboard (运行在 http://localhost:8501) python main.py dashboard ``` ### 3. CLI 工具 ``` # Feed ingestion python main.py cli feeds ingest-all # Ingest all feeds python main.py cli feeds ingest threatfox # Ingest specific feed # C2 Infrastructure python main.py cli c2 list # List active C2 python main.py cli c2 lookup 192.168.1.1 # Get C2 details # Threat Indicators python main.py cli indicators search --severity critical python main.py cli indicators search --type ip --limit 50 # Malware URLs python main.py cli urlhaus list # List malware URLs python main.py cli urlhaus list --status online # Filter by status # 统计信息 python main.py cli stats overview ``` ## 🔌 API 端点 ### C2 基础设施 ``` GET /api/v1/c2/all # Get all C2 infrastructure POST /api/v1/c2/search # Search with filters GET /api/v1/c2/ip/{ip} # Get C2 by IP GET /api/v1/c2/ip/{ip}/domains # Get associated domains GET /api/v1/c2/ip/{ip}/dns-history # Get DNS history ``` ### 威胁指标 ``` GET /api/v1/indicators # Get all indicators POST /api/v1/indicators/search # Search indicators GET /api/v1/indicators/{indicator} # Get specific indicator ``` ### 域名情报 ``` GET /api/v1/domains # Get malicious domains GET /api/v1/domains/{domain} # Get domain details ``` ### 被动 DNS ``` GET /api/v1/pdns/{query} # Query pDNS (domain or IP) ``` ### URLhaus ``` GET /api/v1/urlhaus # Get malware URLs GET /api/v1/urlhaus/host/{host} # Get URLs by host ``` ### 情报源管理 ``` POST /api/v1/feeds/ingest/all # Ingest all feeds POST /api/v1/feeds/ingest/{feed_name} # Ingest specific feed GET /api/v1/feeds/available # Get available feeds ``` ### 分析 ``` GET /api/v1/stats/overview # Overview statistics GET /api/v1/stats/c2-by-country # C2 by country GET /api/v1/stats/threats-by-severity # Threats by severity ``` ## 🏗️ 架构 ### 项目结构 ``` threat-intel-tracker/ ├── src/ │ ├── api/ # REST API endpoints │ │ ├── main.py # FastAPI application │ │ ├── routes.py # Core API routes │ │ ├── feeds_routes.py # Feed ingestion routes │ │ └── schemas.py # Pydantic models │ ├── clients/ # Threat intelligence API clients │ │ ├── shodan_client.py │ │ ├── censys_client.py │ │ ├── binary_edge_client.py │ │ ├── zoomeye_client.py │ │ ├── passive_dns.py │ │ └── whois_client.py │ ├── feeds/ # Feed ingestors │ │ ├── threatfox_ingestor.py │ │ ├── urlhaus_ingestor.py │ │ └── orchestrator.py │ ├── database/ # Database models and management │ │ ├── models.py # SQLAlchemy ORM models │ │ └── db.py # Connection and session management │ ├── cli/ # Command-line interface │ │ └── cli.py # CLI commands │ └── utils/ # Utility functions │ └── helpers.py # Helper functions ├── dashboard/ # Streamlit dashboard │ └── app.py # Dashboard application ├── tests/ # Test suite ├── requirements.txt # Python dependencies ├── .env.example # Environment template ├── main.py # Entry point └── README.md # This file ``` ### 数据模型 #### C2Infrastructure - IP 地址、端口、协议 - 国家、ISP、ASN - 置信度得分、活跃状态 - 首次/最后一次出现的时间戳 - 关联的恶意软件标签 #### ThreatIndicator - 指标值与类型(IP、域名、URL、hash) - 威胁类型与严重程度 - 置信度得分 - 关联的恶意软件家族 - 多来源追踪 #### PassiveDNSRecord - 域名 → IP 映射 - 记录类型(A、AAAA、MX、NS、CNAME) - 首次/最后一次出现的时间戳 - 来源追踪 #### WHOISHistory - 域名注册详情 - 注册人信息 - 名称服务器 - 创建/过期日期 - 用于变更追踪的时间快照 #### URLhaus - 恶意软件分发 URL - URL 状态(在线/离线/暂停) - 托管域名 - 恶意软件家族分类 - Payload URL ## 🔑 配置 ### 环境变量 ``` # 数据库 DATABASE_URL=postgresql://threat_intel_user:threat_intel_password@localhost:5432/threat_intel_db # API Keys (演示可选) SHODAN_API_KEY=your_key CENSYS_PAT=your_censys_personal_access_token_here BINARY_EDGE_API_KEY=your_key ZOOMEYE_API_KEY=your_key PASSIVE_DNS_API_KEY=your_key # 应用程序 LOG_LEVEL=INFO API_HOST=0.0.0.0 API_PORT=8000 DASHBOARD_PORT=8501 ENABLE_REALTIME=false UPDATE_INTERVAL_MINUTES=60 ``` ## 🔄 情报源 ### ThreatFox (abuse.ch) - **类型**:实时 C2 IOCs - **更新**:实时 - **数据**:C2 基础设施使用的 IP、域名、URL - **无需 API 密钥**:✅ ### URLhaus (abuse.ch) - **类型**:恶意软件分发 URL - **更新**:每小时 - **数据**:托管恶意软件的 URL、恶意软件家族、Payload 追踪 - **无需 API 密钥**:✅ ## 📊 使用示例 ### 按国家获取活跃的 C2 基础设施 ``` curl "http://localhost:8000/api/v1/c2/search" \ -X POST \ -H "Content-Type: application/json" \ -d '{ "country": "US", "is_active": true, "min_confidence": 80.0, "limit": 50 }' ``` ### 按严重程度搜索威胁指标 ``` curl "http://localhost:8000/api/v1/indicators/search" \ -X POST \ -H "Content-Type: application/json" \ -d '{ "severity": "critical", "limit": 100 }' ``` ### 获取被动 DNS 历史 ``` curl "http://localhost:8000/api/v1/pdns/example.com" ``` ### 摄取所有情报源 ``` curl -X POST "http://localhost:8000/api/v1/feeds/ingest/all" ``` ## 🧪 测试 ``` # 运行测试 pytest tests/ # With coverage pytest --cov=src tests/ ``` ## 📈 性能 - **C2 基础设施**:支持 10K+ 条记录 - **威胁指标**:100K+ 个指标 - **DNS 记录**:1M+ 条被动 DNS 记录 - **查询时间**:标准查询 <100ms - **摄取速度**:1K 条记录/分钟 ## 🛡️ 安全注意事项 - API 密钥存储在环境变量中(绝不提交到代码库) - 数据库凭据应使用强密码 - 生产环境建议使用 HTTPS - 提供可用的 API 速率限制 - 针对可信域名配置了 CORS ## 📝 许可证 MIT 许可证 - 请参阅 LICENSE 文件 ## 🔗 引用 - **Shodan**: https://www.shodan.io/ - **Censys**: https://censys.io/ - **Binary Edge**: https://www.binaryedge.io/ - **Zoomeye**: https://www.zoomeye.org/ - **ThreatFox**: https://threatfox.abuse.ch/ - **URLhaus**: https://urlhaus.abuse.ch/ - **abuse.ch**: https://abuse.ch/ ## 📞 支持 如有问题和疑问: - 查看 `/docs` 文件夹中的文档 - 查看使用文档中的示例 API 调用 - 检查日志以获取调试信息 ## 🚀 路线图 - [ ] 实时流式更新 - [ ] 集成 Elasticsearch 以进行高级查询 - [ ] 图数据库支持(Neo4j)以进行关系映射 - [ ] 基于机器学习的威胁评分 - [ ] 用于告警的 Webhook 支持 - [ ] 多租户支持 - [ ] 高级搜索语法(类 Lucene) - [ ] 历史趋势分析
标签:C2监控, GitHub, IP 地址批量处理, Kubernetes, Python, RESTful API, 代码示例, 威胁情报, 安全运营, 开发者工具, 扫描框架, 提示词优化, 数据分析, 无后门, 测试用例, 请求拦截, 逆向工具