Tarun110/Agentic-AI-SOC-Analyst-

GitHub: Tarun110/Agentic-AI-SOC-Analyst-

基于 LangChain 和 RAG 技术构建的智能 SOC 分析助手,通过自动化告警分诊、IOC 提取和 MITRE 映射来加速安全事件响应流程。

Stars: 0 | Forks: 0

# AI 驱动的 SOC 分析师助手 这是一个智能的安全运营中心(SOC)助手,它使用 **Python**、**OpenAI API**、**LangChain** 和 **MITRE ATT&CK** 框架来自动化 Tier-1 分析任务。 ![Python](https://img.shields.io/badge/Python-3.10+-blue) ![FastAPI](https://img.shields.io/badge/FastAPI-REST_API-green) ![LangChain](https://img.shields.io/badge/LangChain-RAG-orange) ![MITRE ATT&CK](https://img.shields.io/badge/MITRE-ATT%26CK-red) ## 功能特性 - **告警分析** — 利用 AI 驱动的分诊和执行摘要来分析 SIEM/EDR 告警 - **检索增强生成 (RAG)** — 查询 MITRE ATT&CK、NIST 指南和威胁情报 - **IOC 提取** — 自动提取 IP、域名、哈希值、电子邮件、CVE 等 - **攻击分类** — 将告警映射到 MITRE ATT&CK 技术,并提供置信度得分 - **事件报告生成** — 生成结构化的 Markdown 报告以便升级处理 - **修复建议** — 提供映射到 NIST 事件响应阶段的优先级行动建议 - **多种接口** — 支持 CLI、REST API (FastAPI) 和 Streamlit Web UI ## 架构 ``` ┌─────────────────┐ ┌──────────────────┐ ┌─────────────────────┐ │ Alert Input │────▶│ Alert Analyzer │────▶│ Incident Report │ │ (SIEM/EDR) │ │ (Orchestrator) │ │ (Markdown) │ └─────────────────┘ └────────┬─────────┘ └─────────────────────┘ │ ┌──────────────────┼──────────────────┐ ▼ ▼ ▼ ┌────────────────┐ ┌───────────────┐ ┌─────────────────┐ │ IOC Extractor │ │ Attack │ │ RAG Engine │ │ (Regex) │ │ Classifier │ │ (LangChain + │ │ │ │ (MITRE ATT&CK)│ │ ChromaDB) │ └────────────────┘ └───────────────┘ └────────┬────────┘ │ ┌──────────────┼──────────────┐ ▼ ▼ ▼ MITRE ATT&CK NIST CSF Threat Intel ``` ## 快速开始 ### 前置条件 - Python 3.10+ - OpenAI API 密钥(可选 — 针对 IOC/分类提供离线模式) ### 安装说明 ``` git clone https://github.com/YOUR_USERNAME/soc-analyst-assistant.git cd soc-analyst-assistant python -m venv venv # Windows venv\Scripts\activate # Linux/macOS source venv/bin/activate pip install -r requirements.txt cp .env.example .env # 编辑 .env 并添加你的 OPENAI_API_KEY ``` ### 摄取知识库(用于 RAG) ``` python scripts/ingest_knowledge_base.py # 或 python main.py ingest ``` ### 运行分析 **CLI:** ``` python main.py analyze data/sample_alerts/powershell_emotet_alert.txt python main.py list-samples ``` **REST API:** ``` python main.py serve # POST http://localhost:8000/analyze # Docs: http://localhost:8000/docs ``` **Web UI:** ``` streamlit run ui/streamlit_app.py ``` ## API 用法 ``` curl -X POST http://localhost:8000/analyze \ -H "Content-Type: application/json" \ -d '{ "alert_text": "[ALERT] PowerShell encoded command from WINWORD.EXE...", "alert_source": "CrowdStrike", "include_report": true }' ``` ### 响应 ``` { "summary": "Encoded PowerShell execution from Office application...", "severity": "high", "iocs": [{"type": "ip", "value": "185.234.72.19", "context": "..."}], "attack_classification": [{"technique_id": "T1059.001", "technique_name": "PowerShell", "tactic": "Execution", "confidence": 0.85}], "remediation_actions": [{"priority": "P1 - Immediate", "action": "Isolate affected host...", "rationale": "..."}], "incident_report": "# Security Incident Report\n..." } ``` ## 项目结构 ``` soc-analyst-assistant/ ├── app/ │ ├── api.py # FastAPI REST endpoints │ ├── config.py # Settings and configuration │ ├── models/schemas.py # Pydantic request/response models │ └── services/ │ ├── alert_analyzer.py # Main analysis orchestrator │ ├── attack_classifier.py# MITRE ATT&CK classification │ ├── ioc_extractor.py # IOC extraction (regex) │ ├── incident_reporter.py# Report generation │ └── rag_engine.py # LangChain RAG pipeline ├── data/ │ ├── knowledge_base/ # MITRE, NIST, threat intel docs │ └── sample_alerts/ # Sample alerts for testing ├── scripts/ingest_knowledge_base.py ├── ui/streamlit_app.py # Web interface ├── tests/ # Unit tests ├── main.py # CLI entry point └── requirements.txt ``` ## 知识库 RAG 知识库包含: | 来源 | 内容 | |--------|---------| | **MITRE ATT&CK** | T1566.001, T1059.001, T1071.001, T1486, T1110, T1021.001 | | **NIST** | SP 800-61 事件处理,CSF 响应功能 | | **威胁情报** | Emotet、LockBit、Cobalt Strike 活动 | 将您自己的 `.md` 文件添加到 `data/knowledge_base/` 目录中,然后重新运行摄取程序。 ## 测试 ``` pytest tests/ -v ``` ## 离线模式 如果没有 OpenAI API 密钥,助手仍然可以提供: - 基于正则表达式的 IOC 提取 - 基于关键词的 MITRE ATT&CK 分类 - 基于规则的严重性和修复建议 - 基于关键词匹配的知识库检索 配置 `OPENAI_API_KEY` 以获取完整的 AI 驱动分析和 RAG 嵌入。 ## 许可证 MIT 许可证 ## GitHub 上传 请参阅 [GITHUB_UPLOAD.md](GITHUB_UPLOAD.md) 获取发布此仓库的逐步指南。 ## 作者 本项目作为一个作品集项目构建,旨在展示如何使用 Python、OpenAI、LangChain 和 MITRE ATT&CK 实现 AI 驱动的 SOC 自动化。
标签:AI助手, AV绕过, FastAPI, Kubernetes, LangChain, RAG, 告警分诊, 威胁情报, 安全运营中心(SOC), 开发者工具, 自动化响应, 轻量级, 逆向工具