Nyansaa/Cyber-Threat-Agent
GitHub: Nyansaa/Cyber-Threat-Agent
一个基于Claude和LangChain的Agentic AI系统,能够自主搜索网络威胁情报并生成结构化威胁简报,帮助防御和情报分析师快速完成调研工作。
Stars: 0 | Forks: 0
# 🛡️ 网络威胁情报 (CTI) Agent
一个能够自主研究网络威胁并为防御和情报应用生成结构化、可供分析师直接使用的威胁简报的 Agentic AI 系统。
该项目旨在模拟国防承包商和政府机构使用的真实 CTI 工作流程。
## 📌 概述
CTI Agent 接收一个网络威胁主题,自主搜索网络以获取当前的威胁情报,并返回一份结构化的威胁简报——包括威胁行为者、目标行业、攻击向量、失陷指标 和建议的缓解措施。
该项目展示了在国防和情报背景下的应用型 Agentic AI,结合了大语言模型推理与实时网络检索,以实现分析师工作流程的自动化。
## 🎯 用例
国防承包商、政府机构和情报界分析师花费大量时间手动研究威胁并撰写简报。该 Agent 自动化了这一研究流程——让分析师在几秒钟而不是几小时内获得一个结构化的起始点。
**提示词示例:** `APT29 针对政府网络的钓鱼活动`
**输出示例:**
```
{
"threat_name": "APT29 (Cozy Bear) Spearphishing Campaign",
"threat_type": "Advanced Persistent Threat (APT) / Spearphishing",
"summary": "APT29, a Russian SVR-affiliated threat actor, has conducted sustained
spearphishing campaigns targeting government networks, think tanks, and
defense contractors using malicious OAuth applications and credential
harvesting techniques.",
"threat_actors": ["APT29", "Cozy Bear", "Midnight Blizzard"],
"targeted_sectors": ["Government", "Defense", "Think Tanks", "NGOs"],
"attack_vectors": [
"Spearphishing emails with malicious links",
"OAuth application abuse for persistent access",
"Password spray attacks against cloud services"
],
"indicators_of_compromise": [
"Suspicious OAuth app consent requests",
"Unusual authentication from foreign IPs",
"Unexpected MFA prompts"
],
"mitigations": [
"Enable phishing-resistant MFA across all accounts",
"Audit and restrict OAuth application permissions",
"Monitor for anomalous login activity and credential stuffing"
],
"severity": "Critical",
"confidence": "High"
}
```
## 🤖 工作原理
该 Agent 使用一个 **Agentic Loop(代理循环)** —— 即 AI 与外部工具之间的来回交互,直到任务完成。当你输入一个威胁主题时,会发生以下情况:
```
1. You enter a threat topic
↓
2. Claude (via Anthropic API) reads the system prompt and decides to search
↓
3. Agent calls DuckDuckGo web search tool with a targeted query
↓
4. Search results are returned to Claude
↓
5. Claude decides if it needs more information → searches again if needed
↓
6. Claude synthesizes findings into a structured JSON threat brief
↓
7. Brief is displayed in the terminal and saved to briefs/ folder
```
核心洞见:**Claude 自主决定何时搜索、搜索什么内容以及何时获取了足够的信息** —— 这正是该系统具备“Agentic”特性的原因。
## 🧰 技术栈
| 工具 | 用途 |
|------|---------|
| Python 3.10+ | 核心编程语言 |
| Anthropic Claude API | Agent 的 LLM 核心 (`claude-sonnet-4-6`) |
| LangChain | Agent 框架和工具集成 |
| DuckDuckGo Search | 实时网络检索(无需 API key) |
| python-dotenv | 安全的 API key 管理 |
| ChromaDB *(即将推出)* | 用于 RAG 集成的向量数据库 |
| FastAPI *(即将推出)* | 用于部署的 REST API 接口 |
## 📁 项目结构
```
cyber-threat-agent/
├── agent/
│ ├── __init__.py # Package entry point
│ ├── core.py # Main agentic loop and orchestration
│ ├── tools.py # Web search tool definition and router
│ └── prompts.py # System prompt and threat brief schema
├── rag/ # RAG integration (Part 3 — in progress)
├── api/ # FastAPI interface (Part 4 — coming soon)
├── data/
│ └── sample_reports/ # Threat intelligence PDFs for RAG
├── briefs/ # Saved JSON threat brief outputs
├── .env # API keys (not committed)
├── .gitignore
├── main.py # Entry point — run this to start the agent
├── requirements.txt # All dependencies
└── README.md
```
## ⚙️ 设置与安装
### 前置条件
- Python 3.10+
- Anthropic API key ([在此获取](https://console.anthropic.com))
### 1. 克隆仓库
```
git clone git clone https://github.com/Nyansaa/cyber-threat-agent.git
cd cyber-threat-agent
```
### 2. 创建并激活虚拟环境
```
python -m venv venv
# Windows
venv\Scripts\activate
# Mac/Linux
source venv/bin/activate
```
### 3. 安装依赖
```
pip install -r requirements.txt
```
### 4. 设置 API key
在根目录下创建一个 `.env` 文件:
```
ANTHROPIC_API_KEY=your-api-key-here
```
### 5. 运行 Agent
```
python main.py
```
### 6. 根据提示输入威胁主题
```
Enter threat topic (or 'quit' to exit):
> LockBit ransomware targeting critical infrastructure
```
## 📋 依赖要求
通过运行以下命令创建 `requirements.txt`:
```
pip freeze > requirements.txt
```
或手动安装:
```
anthropic
langchain
langchain-community
duckduckgo-search
ddgs
python-dotenv
```
## 🗺️ 路线图
- [x] **第 1 部分** — 基于 Claude API 和网络搜索的核心 Agentic Loop
- [x] **第 2 部分** — 结构化 JSON 威胁简报输出
- [ ] **第 3 部分** — 集成 ChromaDB 的 RAG 用于威胁情报文档检索
- [ ] **第 4 部分** — FastAPI REST 端点和 Streamlit 前端
- [ ] **第 5 部分** — 部署、演示 GIF 和完整文档
## 🎯 与国防和情报领域的相关性
该项目直接反映了国防承包商和政府机构 CTI 团队所使用的工作流程:
- **结构化威胁简报** 遵循真实 SOC 和情报环境中使用的格式
- **与 MITRE ATT&CK 对齐** 的术语
- **Agentic 架构** 反映了现代 AI 在国防 AI 项目中的部署方式
- **专为可扩展性设计** — RAG 层将支持摄取分类格式的报告
## 👩🏾💻 作者
**Anita Amofah**
计算机科学与网络安全 (双学位) | 费耶特维尔州立大学 | 2027年5月
AI 研究 | NASA 合作 | 专注国防与情报
[LinkedIn](https://www.linkedin.com/in/anita-amofah/) • [作品集](https://anita-amofah.netlify.app/) • [GitHub](https://github.com/Nyansaa)
## ⚠️ 免责声明
该工具仅用于教育和作品集展示目的。所有检索到的威胁情报均来自公开来源。请勿用于进攻性安全用途。
标签:APT, APT29, DLL 劫持, HTTP/HTTPS抓包, IoC, OAuth滥用, RuleLab, SaaS, SecOps, 云安全架构, 国防承包商, 大语言模型, 失陷指标, 威胁情报, 威胁搜寻, 安全运营, 开发者工具, 态势感知, 情报分析, 扫描框架, 攻击向量, 政府机构, 智能安全, 结构化数据, 网络安全, 网络检索, 网络诊断, 自主代理, 自动化报告, 逆向工具, 防御分析师, 隐私保护, 风险分析, 鱼叉攻击