ahsan091/ThreatLens

GitHub: ahsan091/ThreatLens

基于本地大模型的安全日志分析工具,自动化完成威胁检测、ATT&CK 映射与事件报告生成。

Stars: 0 | Forks: 0

# 🛡️ ThreatLens — AI SOC Analyst Agent **智能安全日志调查系统** 一款由 AI 驱动的网络安全调查工具,可自动执行 Tier-1 SOC 分析。上传安全日志,检测威胁,映射至 MITRE ATT&CK,并生成专业的事件报告 —— 全程由本地 AI 提供支持。 ## ⚡ 快速开始 ### 1. 安装依赖 ``` cd ThreatLens pip install -r requirements.txt ``` ### 2. 安装 Ollama(用于 AI 增强分析) ``` # 安装 Ollama curl -fsSL https://ollama.com/install.sh | sh # 拉取 model ollama pull llama3.1:8b-instruct ``` ### 3. 运行应用程序 ``` streamlit run app.py ``` 在浏览器中打开 [http://localhost:8501](http://localhost:8501)。 ## 📂 支持的日志类型 | 日志类型 | 来源 | 检测事件 | |----------|--------|----------------| | **Linux Auth** | `auth.log`, `secure` | SSH 暴力破解、登录失败、sudo 滥用、账户创建 | | **Linux Syslog** | `syslog`, `messages` | 服务故障、可疑 cron 任务、OOM kills | | **防火墙** | `ufw.log` | 端口扫描、被阻止的连接 | | **Windows** | 导出的事件日志 | 事件 ID 4624/4625/4672/4688 | | **Web 服务器** | Apache/Nginx 访问日志 | SQL 注入、XSS、路径遍历、Web Shell | ## 🏗️ 架构 ``` Log Upload → Log Parser → Event Normalization → Threat Classifier → Event Correlation → IP Intelligence → MITRE ATT&CK Mapping → AI SOC Agent (Llama 3.1) → Incident Report Generator → Streamlit Dashboard ``` ## 📁 项目结构 ``` ThreatLens/ ├── app.py # Streamlit web interface ├── requirements.txt # Python dependencies ├── agent/ │ ├── soc_agent.py # AI SOC agent (Ollama/LangChain) │ ├── threat_classifier.py # Rule-based classifier + event correlation │ ├── ip_enrichment.py # IP geolocation via ipwhois │ └── tools.py # LangChain agent tools ├── parsers/ │ ├── __init__.py # Auto-detection + routing │ ├── linux_parser.py # Linux auth/syslog/firewall parser │ ├── windows_parser.py # Windows event log parser │ ├── web_parser.py # Apache/Nginx log parser │ └── normalizer.py # Unified event format ├── mitre/ │ └── mitre_mapper.py # MITRE ATT&CK technique mapping ├── reports/ │ └── report_generator.py # PDF/JSON/Markdown reports ├── data/ │ └── mitre_attack_dataset.json # MITRE ATT&CK knowledge base ├── logs/sample_logs/ # Sample logs for testing │ ├── linux_auth.log │ ├── linux_syslog.log │ ├── windows_security.log │ ├── apache_access.log │ └── firewall.log └── tests/ # Automated test suite ├── test_linux_parser.py ├── test_windows_parser.py ├── test_web_parser.py ├── test_threat_classifier.py ├── test_mitre_mapper.py └── test_report_generator.py ``` ## 🧪 运行测试 ``` python -m pytest tests/ -v ``` ## ✨ 主要特性 - **AI 增强,非 AI 依赖** — 完整的基于规则的检测在无 Ollama 的情况下亦可工作 - **事件关联** — 将相关事件归组为安全事故(例如:20 次 SSH 失败 → 1 次暴力破解事件) - **多阶段攻击检测** — 识别攻击链(暴力破解 → 登录 → 权限提升) - **IP 情报** — 通过 ipwhois 进行地理位置和 ASN 丰富化 - **MITRE ATT&CK 映射** — 将所有检测结果映射到框架技术 - **导出报告** — 支持 PDF、JSON 和 Markdown 格式 - **5,000 事件限制** — 防止处理过载 - **60s LLM 超时** — 防止 UI 冻结 ## 🛠️ 技术栈 | 组件 | 技术 | |-----------|-----------| | 语言 | Python | | AI Agent | LangChain + Ollama | | AI 模型 | Llama 3.1 (8B Instruct) | | Web UI | Streamlit | | 日志解析 | Python Regex | | PDF 导出 | fpdf2 | | IP 情报 | ipwhois | *由 ThreatLens — AI SOC Analyst Agent 用 ❤️ 构建*
标签:AI安全工具, AI风险缓解, AMSI绕过, CISA项目, CSV导出, DLL 劫持, FOFA, IP情报, Kubernetes, LangChain, Llama 3.1, LLM评估, MITRE ATT&CK映射, Ollama, PE 加载器, Python, SOC分析师, SQL注入检测, Streamlit, ThreatLens, Tier-1自动化, Web服务器安全, Windows事件日志, XSS检测, 人工智能, 大语言模型, 威胁检测, 安全运营中心, 开源安全工具, 异常检测, 攻击路径分析, 无后门, 本地AI, 用户模式Hook绕过, 网络安全, 网络安全审计, 网络映射, 自动化报告生成, 访问控制, 轻量级, 逆向工具, 逆向工程平台, 速率限制, 防火墙日志, 隐私保护