avikengineer007/AI-Threat-hunting-threat-intelligence-agent
GitHub: avikengineer007/AI-Threat-hunting-threat-intelligence-agent
一款基于 Gemini LLM 的自主多 Agent 网络威胁情报系统,自动监控多源情报数据、丰富威胁指标并生成每日分析报告。
Stars: 0 | Forks: 0
# 自主 AI 威胁狩猎与威胁情报 Agent 🛡️🤖
一个自主的多 Agent 网络威胁情报系统,它会定期监控开源情报源,追踪最新披露的 CVE,标记被活跃利用的漏洞(CISA KEV),通过外部威胁 API 丰富威胁指标,并使用 Google Gemini LLM 推理层自动生成每日人类可读的 markdown 报告。
它还具有自然语言对话式命令行界面(CLI),可用于查询威胁数据库并按需进行失陷指标(IOC)分析。
## 🏗️ 系统架构
```
+-------------------+
| Scheduler |
| (APScheduler) |
+---------+---------+
| Trigger (Periodic)
v
+-------------------+ +-------------------+ +-------------------+
| NVD API (CVEs) |---------->| Collectors & |<==========| CISA KEV JSON |
+-------------------+ | Enrichers | +-------------------+
+-------------------+ | | +-------------------+
| VirusTotal API |---------->| (nvd, cisa, vt, |<==========| Shodan API |
+-------------------+ | shodan, ransom) | +-------------------+
+---------+---------+
| Normalize & Save
v
+-------------------+
| Database |<--------+
| (SQLite) | |
+---------+---------+ | Query
| |
v |
+-------------------+ |
| Gemini LLM |---------+
| Reasoning Layer |
+---------+---------+
|
+-----------------+-----------------+
| |
v v
+--------------------+ +--------------------+
| Report Generator | | CLI Interface |
| (Markdown Reports) | | (Natural Language)|
+--------------------+ +--------------------+
```
## 🌟 核心功能
1. **自主 Daemon(调度器)**:通过 `APScheduler` 在后台执行,以可自定义的时间间隔(例如每日/每周)获取威胁情报数据。
2. **漏洞情报**:与国家漏洞数据库(NVD)集成,用于追踪 CVE 以及 CISA 的已知被利用漏洞(KEV)目录。
3. **IOC 丰富工具**:
- **VirusTotal API**:获取域名、IP 和文件哈希的信誉详情。
- **Shodan API**:扫描并丰富资产配置及开放端口漏洞信息。
4. **Gemini LLM 推理**:通过 LangChain 利用 Google 的 `gemini-1.5-flash` 模型来解读原始数据、建立关联、确定关键问题的优先级,并提取可操作的洞察。
5. **交互式 CLI Shell**:启动本地对话式 Shell,询问有关威胁的问题(例如:*“本周发现的最危险的 CVE 是什么?”* 或 *“分析 IP 192.168.1.100”*)。
6. **自动报告**:在每次摄取周期后生成详细且格式精美的 markdown 报告。
## ⚙️ 设置与安装指南
### 前置条件
- 已安装 Python 3.10 或更高版本。
- 已安装 SQLite(通常随 Python 一起提供)。
### 1. 克隆仓库
```
git clone https://github.com/avikengineer007/AI-Threat-hunting-threat-intelligence-agent.git
cd AI-Threat-hunting-threat-intelligence-agent
```
### 2. 创建并激活虚拟环境
* **在 Windows 上**:
python -m venv .venv
.venv\Scripts\activate
* **在 macOS/Linux 上**:
python3 -m venv .venv
source .venv/bin/activate
### 3. 安装依赖项
```
pip install -r requirements.txt
```
### 4. 配置环境变量
将 `.env.example` 复制到 `.env`:
```
cp .env.example .env
```
在 `.env` 中填写配置参数:
```
# Gemini API Key(LLM reasoning 和 CLI 必需)
GEMINI_API_KEY=your_gemini_api_key_here
# NVD API Key(可选,建议提供以防止 request throttling)
NVD_API_KEY=your_nvd_api_key_here
# Shodan API Key(active host scans 必需)
SHODAN_API_KEY=your_shodan_api_key_here
# VirusTotal API Key(domain 和 file reputation checks 必需)
VIRUSTOTAL_API_KEY=your_virustotal_api_key_here
# Database URL
DATABASE_URL=sqlite:///threat_intel.db
# Periodic Ingestion Interval(以小时为单位)
COLLECTION_INTERVAL_HOURS=24
```
## 🚀 执行与使用
该 Agent 可以在三种不同的模式下运行:
### 1. 初始化数据库 Schema
在运行数据摄取之前配置 SQLite 表:
```
python main.py --init-db
```
### 2. 运行一次性数据摄取周期
运行收集器,丰富威胁指标,更新数据库,编写 markdown 报告,然后退出:
```
python main.py --run-once
```
### 3. 启动后台调度 Daemon
在后台持续运行,定期执行数据摄取检查:
```
python main.py
```
### 4. 运行对话式 Agent CLI
启动交互式自然语言 Shell:
```
python cli.py
```
或者直接将一次性查询字符串作为终端参数运行:
```
python cli.py "Show me today's threat intel summary"
python cli.py "Are there any newly flagged remote code execution (RCE) bugs?"
python cli.py "Enrich IP address 8.8.8.8 using Shodan and VT tools"
```
## 📁 仓库结构
```
├── collectors/ # Feed parser scripts (nvd, cisa, virustotal, shodan)
├── database/ # SQLAlchemy database connection and models schemas
├── reasoning/ # LangChain tool bindings and Gemini prompt templates
├── reporting/ # Markdown report formatting templates and output logs
├── scheduler/ # Periodic daemon job triggers logic
├── cli.py # Conversational query terminal entry point
├── config.py # Global logging configurations and env loader
├── main.py # Ingestion pipeline daemon entry point
├── requirements.txt # Python packages dependencies
└── .env.example # System variables templates configuration
```
标签:AI智能体, 威胁情报, 开发者工具, 漏洞追踪, 自动化报告, 逆向工具