GlobalReconReport/opfor-intel

GitHub: GlobalReconReport/opfor-intel

一个终端化的地缘政治威胁情报工具包,实现 RSS 采集、OSINT 扫描与自动化报告。

Stars: 2 | Forks: 1

# OPFOR 情报 终端地缘政治威胁情报工具包。完全在终端中收集、处理和汇总网络威胁情报,集成 RSS 源、SpiderFoot OSINT 扫描和 Shodan IP 增强功能,无需图形界面。 ``` ██ ███ ████ ██ ███ ███ █ █ ████ ████ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ █ █ █ █ ███ ███ █ █ ███ █ █ ██ █ ███ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ ██ █ █ ███ █ █ █ ████ ████ ``` ## 功能特性 - **`intel collect`** — 获取 9+ 个威胁情报 RSS/Atom 源并自动处理为结构化 JSON - **`intel report`** — 从最新处理的数据生成 INTSUM 风格的威胁摘要 - **`intel scan --domain `** — 运行 SpiderFoot OSINT 扫描并提取高风险发现 - **`intel enrich --ip `** — 通过 Shodan 增强 IP(若不可用则回退到 ipinfo.io) - **Cron 兼容** — `scripts/run_intel.sh` 支持无人值守运行,带有每次运行的日志和历史追踪 - **无外部运行时依赖** — 仅需 `requirements.txt` 中的 Python 包 ## 系统要求 | 要求 | 版本 | |------|------| | Python | 3.9+ | | pip | 任意近期版本 | | 操作系统 | Linux(推荐 Ubuntu/Debian/Kali) | 可选依赖: - **Shodan API 密钥** — 用于 `intel enrich` 获取完整主机数据(无密钥时回退到 ipinfo.io) - **AlienVault OTX API 密钥** — 用于 OTX 脉冲源 - **SpiderFoot** — 用于 `intel scan`(可通过 `pip install spiderfoot` 或从 GitHub 克隆安装) ## 安装 ``` git clone https://github.com/GlobalReconReport/opfor-intel.git cd opfor-intel # 标准安装(安装到当前 Python 环境) bash install.sh # 或使用独立的 virtualenv bash install.sh --venv ``` `install.sh` 将执行以下操作: 1. 验证 Python 3.9+ 2. 从 `requirements.txt` 安装所有 pip 依赖 3. 创建运行时目录(`raw_intel/`、`processed_intel/`、`reports/`、`logs/`) 4. 可选安装 `intel` 命令到 `/usr/local/bin` ## 配置 所有设置位于 **`config.yaml`**。请在运行前编辑该文件。 ### RSS 源 默认启用所有源。要禁用某个源,请将其 `enabled` 设为 `false`。 ``` rss_feeds: - name: "thehackernews" url: "https://feeds.feedburner.com/TheHackersNews" type: "rss" auth_required: false enabled: true ``` ### AlienVault OTX(可选) ``` - name: "alienvault_otx" url: "https://otx.alienvault.com/api/v1/pulses/subscribed" type: "api" auth_required: true enabled: true # change to true api_key: "PASTE_KEY_HERE" ``` 免费密钥获取地址:[otx.alienvault.com](https://otx.alienvault.com)。 ### Shodan(可选) ``` shodan: api_key: "PASTE_KEY_HERE" ``` 密钥获取地址:[account.shodan.io](https://account.shodan.io)。若为空或缺失,`intel enrich` 将自动回退到 ipinfo.io。 ### SpiderFoot(可选) ``` spiderfoot: cli_path: "/usr/local/bin/sf" modules: "sfp_dnsresolve,sfp_threatminer,sfp_virustotal,sfp_shodan" ``` 通过 `pip install spiderfoot` 安装 SpiderFoot,或参考 [SpiderFoot 文档](https://github.com/smicallef/spiderfoot)。 ## 使用方法 ### 收集所有启用的威胁情报源 ``` python3 main.py collect ``` 获取所有启用的 RSS/API 源,将原始 JSON 保存到 `raw_intel/`,然后自动处理每个文件到 `processed_intel/`。 ### 生成 INTSUM 报告 ``` python3 main.py report ``` 读取最新的处理情报文件,生成 INTSUM 风格摘要,输出到终端并保存 `.txt` 副本到 `reports/`。 ### 增强 IP 地址 ``` python3 main.py enrich --ip 1.2.3.4 ``` 查询 Shodan(或回退到 ipinfo.io)获取组织、操作系统、开放端口和风险标记。 ### 扫描域名 ``` python3 main.py scan --domain example.com ``` 使用配置的模块对域名运行 SpiderFoot。需先安装 SpiderFoot。 ### 调试模式 对任意命令添加 `--debug` 参数以获取完整堆栈跟踪和详细日志输出: ``` python3 main.py --debug collect ``` ## 针对特定区域或主题的目标定位 OPFOR Intel 是基于源的采集工具——采集内容完全取决于你配置的数据源。以下步骤可在 5 分钟内将工具聚焦到任意区域、国家或主题。 ### 第一步 — 找到目标的 RSS 源 大多数新闻网站和威胁博客提供免费的 RSS 源。查找方式如下: - 访问目标网站 - 寻找标有 “RSS”、“Feed” 或橙色无线电波图标的链接 - 或尝试在网址后添加 `/feed` 或 `/rss`: ``` https://example-site.com/feed https://example-site.com/rss https://example-site.com/rss.xml ``` 如果上述方法无效,可使用 Google 搜索: ``` site:example-site.com RSS feed ``` **按区域/主题的源示例:** | 目标 | 来源 | 源 URL | |------|------|--------| | 中东与北非综合 | Al Jazeera English | https://www.aljazeera.com/xml/rss/all.xml | | 非洲安全 | Institute for Security Studies | https://issafrica.org/feed | | 网络/中东 | CyberScoop | https://cyberscoop.com/feed | | 伊朗 | Radio Farda | https://www.radiofarda.com/api/ztrqiuol_ot | | 以色列/巴勒斯坦 | Times of Israel | https://www.timesofisrael.com/feed | | 非洲 | AllAfrica | https://allafrica.com/tools/headlines/rdf/latest/headlines.rdf | | 北约/欧洲 | Bellingcat | https://www.bellingcat.com/feed | | 威胁情报 | Recorded Future | https://www.recordedfuture.com/feed | ### 第二步 — 将源添加到配置 用任意文本编辑器打开 `config.yaml`: ``` nano config.yaml ``` 滚动到 `rss_feeds:` 部分,按以下格式在列表末尾添加你的源: ``` - name: "aljazeera" url: "https://www.aljazeera.com/xml/rss/all.xml" type: "rss" auth_required: false enabled: true ``` **规则:** - `name` — 一个单词,无空格,小写,作为输出文件名前缀 - `url` — 完整的 RSS 源 URL - `type` — 始终为 `"rss"`,除非是 JSON API - `auth_required` — 公共源一律设为 `false` - `enabled` — 设为 `true` 启用,`false` 暂停但不删除 保存并关闭文件(若使用 nano:`Ctrl+X` → `Y` → `Enter`)。 ### 第三步 — 执行采集 ``` python3 main.py collect ``` 输出示例如下: ``` [INFO] Starting RSS collection (11 feed(s) configured)... [INFO] Collected 38 items from aljazeera Collected 38 items (0 failed, 0 skipped) [status: ok] → /path/to/raw_intel/rss_aljazeera_20260412T120000Z.json Processed 1 file(s) → processed_intel/ ``` 每个源会保存为独立的带时间戳的 JSON 文件。工具会自动处理原始数据并提取 IP 地址和域名指标。 ### 第四步 — 生成情报摘要 ``` python3 main.py report ``` 报告将显示: - 最新情报来源 - 从内容中提取的 IP 地址 - 文本中发现的域名指标 - 纯文本评估 - 置信度评级(低/中/高) 报告也会自动保存为 `reports/` 目录下的 `.txt` 文件,便于归档或分享。 ### 第五步 — 增强出现的 IP 地址 如果报告中出现 IP 地址,运行: ``` python3 main.py enrich --ip ``` 示例: ``` python3 main.py enrich --ip 185.220.101.45 ``` 这将查询 ipinfo.io(无需账户,免费)并返回: - IP 所属组织 - 地理位置 - 主机名(如可用) 若配置了 Shodan API 密钥,还会返回开放端口和风险标记。 ### 第六步 — 扫描暴露的域名 若某域名在报告中反复出现并需要更深入信息: ``` python3 main.py scan --domain example.com ``` 这需要安装 SpiderFoot。返回结果包括开放端口、服务及与该域名相关的泄露数据。 ### 整合示例 — 中东与北非(MENA)工作流 ``` # 1. 将 MENA feeds 添加到 config.yaml(一次性设置) nano config.yaml # 2. 收集最新情报 python3 main.py collect # 3. 生成你的 INTSUM python3 main.py report # 4. 丰富出现的任意 IP python3 main.py enrich --ip # 5. 扫描任意感兴趣的域名 python3 main.py scan --domain ``` 可每日执行步骤 2 和 3,或通过 cron 自动化,每 6 小时自动获取最新情报,无需人工干预。 ## 自动化采集(Cron) `scripts/run_intel.sh` 执行采集后生成报告,写入 `logs/` 中的每次运行日志,并将单行摘要追加到 `logs/run_history.txt`。 **在 crontab 中设置每 6 小时运行一次:** ``` crontab -e ``` 添加: ``` 0 */6 * * * /bin/bash /path/to/opfor-intel/scripts/run_intel.sh >> /path/to/opfor-intel/logs/cron.log 2>&1 ``` 将 `/path/to/opfor-intel` 替换为克隆仓库的绝对路径。 **手动运行:** ``` bash scripts/run_intel.sh bash scripts/run_intel.sh --debug # verbose output ``` **检查运行历史:** ``` cat logs/run_history.txt ``` ## 项目结构 ``` opfor-intel/ ├── main.py # CLI entry point (Typer) ├── config.yaml # All settings and feed configuration ├── requirements.txt # Python dependencies ├── install.sh # Setup script ├── findings/ # Documented operational findings (IOCs, threat briefs) │ ├── collectors/ │ └── rss_collector.py # RSS/Atom and API feed fetching │ ├── connectors/ │ ├── shodan_connector.py # Shodan IP enrichment + ipinfo.io fallback │ └── spiderfoot_connector.py # SpiderFoot OSINT scan runner │ ├── analysis/ │ └── processor.py # Extracts IPs and domains from raw JSON │ ├── output/ │ └── report_generator.py # INTSUM report formatting │ ├── utils/ │ ├── banner.py # ASCII banner │ ├── errors.py # Custom exception hierarchy │ └── logger.py # Module-level logging singleton │ ├── scripts/ │ └── run_intel.sh # Cron automation script │ ├── raw_intel/ # Raw feed JSON (gitignored) ├── processed_intel/ # Structured indicator JSON (gitignored) ├── reports/ # INTSUM text reports (gitignored) └── logs/ # Run logs and history (gitignored) ``` ## 数据流程 ``` config.yaml │ ▼ [collect] rss_collector ──► raw_intel/*.json │ ▼ (auto-process) processor.py ──► processed_intel/*.json │ ▼ [report] report_generator ──► reports/intsum_*.txt + terminal [scan] spiderfoot_connector ──► processed_intel/*.json ──► terminal [enrich] shodan_connector ──► terminal ``` ## 包含的 | 源 | 类型 | 是否需要认证 | |----|------|--------------| | The Hacker News | RSS | 否 | | BleepingComputer | RSS | 否 | | Krebs on Security | RSS | 否 | | Dark Reading | RSS | 否 | | Threatpost | RSS | 否 | | SANS ISC | RSS | 否 | | CISA | RSS | 否 | | SecurityWeek | RSS | 否 | | ESET Blog | RSS | 否 | | RFI English | RSS | 否 | | Radio Dabanga | RSS | 否 | | Libya Herald | RSS | 否 | | Wardheernews | RSS | 否 | | Al Monitor | RSS | 否 | | AlienVault OTX | API | 是(需免费密钥) | ## 安全注意事项 - **切勿提交真实的 API 密钥** — `config.yaml` 包含占位值。若需本地使用真实密钥,建议将 `config.yaml` 加入 `.gitignore` 或使用独立的 `config.local.yaml`。 - 所有运行时数据(`raw_intel/`、`processed_intel/`、`reports/`、`logs/`)默认已被 `.gitignore` 忽略。 - 数据仅发送至配置的源 URL 和 API 端点。 ## 许可证 MIT
标签:Cron定时任务, ESC4, INTTUM, IP地理定位, Linux工具, OSINT, PB级数据处理, RSS聚合, SpiderFoot, XSS, 关键词提取, 威胁情报, 安全分析, 安全运维, 开发者工具, 情报分析, 情报报告, 情报摘要, 情报收集, 技术侦察, 数字取证, 数字取证, 漏洞情报, 漏洞研究, 端口探测, 终端工具, 网络威胁, 网络诊断, 自动化脚本, 自动化脚本, 逆向工具