isaacinthecloud/stix-taxii-threat-ingestion

GitHub: isaacinthecloud/stix-taxii-threat-ingestion

基于Python的STIX/TAXII威胁情报采集器,通过TAXII 2.1 API自动摄取MITRE ATT&CK数据并提供CLI搜索功能。

Stars: 0 | Forks: 0

# 🛡️ STIX/TAXII 威胁情报采集器 一个基于 Python 的威胁情报采集器,通过 TAXII 2.1 API 自动摄取和分析 STIX 对象。本项目展示了企业威胁情报平台 (TIP) 和安全运营中心 (SOC) 中使用的工作流程。 ![Python](https://img.shields.io/badge/Python-3.11-blue?logo=python) ![STIX](https://img.shields.io/badge/STIX-2.1-green) ![TAXII](https://img.shields.io/badge/TAXII-2.1-green) ![License](https://img.shields.io/badge/License-MIT-yellow) ![Author](https://img.shields.io/badge/Author-isaacinthecloud-purple?logo=github) ## 📋 概述 本项目连接到公共 TAXII 服务器,检索 STIX 威胁情报对象,将其解析到本地数据库,并为安全分析师提供基于 CLI 的搜索功能。 ### 🔐 什么是 STIX? **STIX (Structured Threat Information Expression)** 是一种用于描述网络威胁信息的标准化语言。它使组织能够以一致的、机器可读的格式共享威胁情报。 主要的 STIX 对象类型包括: - **Attack Patterns (攻击模式)**:对手使用的技术(例如,网络钓鱼,凭证转储) - **Indicators (指标)**:可观察到的证据(IP,域名,文件哈希) - **Malware (恶意软件)**:恶意软件描述 - **Threat Actors (威胁行为体)**:已知的对手团体 - **Campaigns (攻击活动)**:协同攻击行动 ### 🔄 什么是 TAXII? **TAXII (Trusted Automated Exchange of Intelligence Information)** 是一种通过 HTTPS 交换威胁情报的协议。它定义了用于在系统之间共享 STIX 内容的 RESTful API。 TAXII 支持: - 自动化威胁情报分发 - 组织间的双向共享 - 与安全工具的集成 (SIEM, SOAR, TIP) ## 📸 截图 | 采集器输出 | 搜索结果 | 数据库统计 | |------------------|----------------|----------------| | ![Collector](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/0b726b817a093139.png) | ![Search](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/d90aeaa6a1093142.png) | ![Stats](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/be2d6a6c75093143.png) | ## ✨ 功能特性 - ✅ 与 MITRE ATT&CK 的 TAXII 2.1 API 集成 - ✅ 针对攻击模式、战术和技术的 STIX 对象解析 - ✅ 用于离线分析的 SQLite 数据库 - ✅ 支持关键词匹配的 CLI 搜索工具 - ✅ 数据库统计仪表板 - ✅ 用于每日自动更新的 Systemd 计时器 - ✅ 可扩展架构,支持添加更多来源 ## 📁 项目结构 ``` stix-taxii-threat-ingestion/ ├── collector.py # TAXII ingestion and STIX parsing ├── search.py # CLI search interface ├── indicators.db # SQLite database (auto-generated) ├── requirements.txt # Python dependencies ├── screenshots/ # Documentation images ├── LICENSE # MIT License └── README.md # This file ``` ## 🔧 前置条件 - Python 3.9+(使用 Python 3.11 测试) - pip (Python 包管理器) - 能够访问 `attack-taxii.mitre.org` 的互联网连接 ### Linux/Debian 用户 如果在最小化的 Debian/Ubuntu 系统(例如 LXC 容器)上部署,请先安装 sudo: ``` # 以 root 用户身份 apt update && apt install -y sudo ``` ## 🏗️ 安装 ``` # Clone the repository git clone https://github.com/isaacinthecloud/stix-taxii-threat-ingestion.git cd stix-taxii-threat-ingestion # Create virtual environment python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install dependencies pip install -r requirements.txt ``` ### 🐳 服务器部署 在 Linux 服务器或容器上部署: ``` # Install system dependencies (Debian/Ubuntu) sudo apt update && sudo apt install -y python3 python3-pip python3-venv git # Clone and setup git clone https://github.com/isaacinthecloud/stix-taxii-threat-ingestion.git cd stix-taxii-threat-ingestion # Create virtual environment python3 -m venv venv source venv/bin/activate # Install Python dependencies pip install --upgrade pip pip install -r requirements.txt ``` ## 🚀 使用方法 ### 1️⃣ 采集威胁情报 ``` python collector.py ``` 这将连接到 MITRE 的 TAXII 2.1 服务器,检索 STIX 攻击模式,并将其存储在本地。 **示例输出:** ``` ============================================================ STIX/TAXII Threat Intelligence Collector ============================================================ Database initialized: indicators.db Connecting to TAXII server: https://attack-taxii.mitre.org ✓ Successfully connected to TAXII server Fetching available collections... Found 3 collection(s): - Enterprise ATT&CK - ICS ATT&CK - Mobile ATT&CK Using collection: Enterprise ATT&CK Fetching STIX objects... Retrieved 24771 objects (total: 24771) Attack patterns found: 835 Processed 100/835 attack patterns... Processed 200/835 attack patterns... ============================================================ Ingestion Complete! ============================================================ ✓ Attack patterns stored: 835 Database file: indicators.db ✓ Collection complete! ``` ### 2️⃣ 搜索指标 ``` python search.py "phishing" ``` **示例输出:** ``` ====================================================================== Found 5 indicator(s) matching 'phishing' ====================================================================== 1. Phishing [STIX: a62a84c5] Tactics: initial-access Adversaries may send phishing messages to gain access to victim systems... 2. Spearphishing Attachment [STIX: f5d8eed6] Tactics: initial-access Adversaries may send spearphishing emails with a malicious attachment... ``` ### 3️⃣ 查看数据库统计 ``` python search.py --stats ``` ## ⚙️ 技术细节 ### 🌐 数据源 | 属性 | 值 | |----------|-------| | TAXII 服务器 | `https://attack-taxii.mitre.org` | | API Root | `/api/v21/` | | TAXII 版本 | 2.1 | | 数据集 | MITRE ATT&CK Enterprise | | 内容 | 835+ 攻击模式 | ### 🗄️ 数据库结构 ``` CREATE TABLE indicators ( id TEXT PRIMARY KEY, name TEXT, description TEXT, type TEXT, created TEXT, modified TEXT, tactics TEXT, platforms TEXT, detection TEXT, raw_stix TEXT, ingested_at TEXT ) ``` ### 📦 依赖项 | 包 | 用途 | |---------|---------| | `requests` | 用于 TAXII API 调用的 HTTP 客户端 | | `sqlite3` | 嵌入式数据库 (Python 内置) | ## 🔄 自动化 (Systemd) 在 Linux 服务器上实现每日自动摄取: ### 服务单元 ``` sudo tee /etc/systemd/system/stix-collector.service << 'EOF' [Unit] Description=STIX/TAXII Threat Intelligence Collector After=network-online.target [Service] Type=oneshot User=stix WorkingDirectory=/opt/stix-collector Environment="PATH=/opt/stix-collector/venv/bin" ExecStart=/opt/stix-collector/venv/bin/python /opt/stix-collector/collector.py [Install] WantedBy=multi-user.target EOF ``` ### 计时器(每天凌晨 2 点) ``` sudo tee /etc/systemd/system/stix-collector.timer << 'EOF' [Unit] Description=Daily STIX/TAXII Intelligence Collection [Timer] OnCalendar=*-*-* 02:00:00 Persistent=true [Install] WantedBy=timers.target EOF ``` ### 启用 ``` sudo systemctl daemon-reload sudo systemctl enable --now stix-collector.timer ``` ## 🏢 实际应用 此架构反映了生产安全平台中的工作流程: ### 威胁情报平台 (TIP) - MISP (开源 TIP) - ThreatConnect - Anomali ThreatStream - OpenCTI ### SIEM 集成 指标可以导出并输入到: - Splunk Enterprise Security - Microsoft Sentinel - Elastic Security - IBM QRadar ### 安全运营用例 1. **威胁搜寻**:搜索您环境中观察到的 TTP 2. **事件响应**:将活动与已知技术进行匹配 3. **红队规划**:了解对手模拟 TTP 4. **检测工程**:基于 ATT&CK 技术构建检测规则 ## 🚧 计划增强 ### 数据丰富 - 多源摄取 (AlienVault OTX, CIRCL) - 通过 VirusTotal, AbuseIPDB 进行 IOC 丰富 - 额外的指标类型 (IP, 域名, 哈希) ### 可视化 - ATT&CK 矩阵覆盖热力图 - 用于可视化的 Web 仪表板 - 导出为 JSON/CSV/STIX bundles ### 自动化 - 新指标的 Webhook 通知 - 去重和 TTL 管理 - REST API 端点 ## 📄 许可证 MIT 许可证。详情请见 [LICENSE](LICENSE)。 ## 👤 作者 **Isaac Suazo** [![GitHub](https://img.shields.io/badge/GitHub-isaacinthecloud-black?logo=github)](https://github.com/isaacinthecloud) [![LinkedIn](https://img.shields.io/badge/LinkedIn-isaacinthecloud-blue?logo=linkedin)](https://www.linkedin.com/in/isaac-suazo/)

我的网络安全家庭实验室作品集的一部分
github.com/isaacinthecloud

标签:DAST, HTTP/HTTPS抓包, IoC 提取, nuclei, Python, RESTful API, STIX, TAXII 2.1, TIP, 威胁情报, 威胁搜寻, 安全合规, 安全运营, 开发者工具, 开源安全工具, 态势感知, 恶意软件分析, 情报共享, 情报收集, 扫描框架, 提示词优化, 攻击模式识别, 无后门, 漏洞研究, 结构化数据, 网络代理, 逆向工具, 逆向工程平台