Tagoletta/Fed0gaT

GitHub: Tagoletta/Fed0gaT

一个自动化、无状态的网络威胁情报聚合器,每小时从多个来源抓取并验证 IOC 指标,生成可直接供防火墙和 EDR 使用的纯文本黑名单。

Stars: 0 | Forks: 0

``` ███████╗███████╗██████╗ ██████╗ ██████╗ █████╗ ████████╗ ██╔════╝██╔════╝██╔══██╗██╔═████╗██╔════╝ ██╔══██╗╚══██╔══╝ █████╗ █████╗ ██║ ██║██║██╔██║██║ ███╗███████║ ██║ ██╔══╝ ██╔══╝ ██║ ██║████╔╝██║██║ ██║██╔══██║ ██║ ██║ ███████╗██████╔╝╚██████╔╝╚██████╔╝██║ ██║ ██║ ╚═╝ ╚══════╝╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ``` ### 自动化网络威胁情报平台 [![License: MIT](https://img.shields.io/badge/License-MIT-6366f1.svg?style=flat-square)](LICENSE) [![Python](https://img.shields.io/badge/Python-3.10%2B-3776AB?style=flat-square&logo=python&logoColor=white)](https://python.org) [![GitHub Actions](https://img.shields.io/badge/GitHub_Actions-Hourly-2088FF?style=flat-square&logo=github-actions&logoColor=white)](https://github.com/features/actions) [![Flask](https://img.shields.io/badge/Flask-3.0-000000?style=flat-square&logo=flask&logoColor=white)](https://flask.palletsprojects.com) [![Docker](https://img.shields.io/badge/Docker-Ready-2496ED?style=flat-square&logo=docker&logoColor=white)](https://docker.com) [![Feeds](https://img.shields.io/badge/Threat_Feeds-27_Active-10b981?style=flat-square)](#-data-sources) **Fed0gaT** 是一个完全自动化、无状态的网络威胁情报 (CTI) 聚合器。 它每小时抓取 **27 个公开和经过身份验证的威胁情报源**,生成干净的 IP、Hash 和 URL 黑名单 —— 可直接供防火墙和 EDR 导入。 [功能](#-features) · [架构](#-architecture) · [数据源](#-data-sources) · [快速开始](#-quick-start) · [仪表板](#-web-dashboard) · [配置](#-configuration)
## ✦ 概述 现代威胁情报需要来自多个来源的持续、最新的数据。Fed0gaT 通过以下方式解决此问题: - **聚合** 来自 9 个权威 CTI 提供商的 27 个情报源的指标 - **验证** 每个 IOC 都具有严格基于 regex 的类型强制 —— IP 绝不会进入 Hash 列表,Hash 绝不会进入 URL 列表 - **发布** 干净、无文件头的纯文本黑名单到 GitHub —— 可直接供防火墙、SIEM 和 EDR 平台使用 - **无状态运行** —— 无数据库,无服务器磁盘写入;GitHub 是唯一的持久化存储 - **归档** 每个列表的每日快照(每种类型每天一个文件),同时 `latest-*.txt` 始终反映最新的一小时抓取结果 ## ✦ 功能 | 类别 | 详情 | |---|---| | **自动化** | GitHub Actions cron 任务 —— 每小时 `XX:00` 运行一次,无需人工干预 | | **IOC 类型** | IPv4/IPv6 地址 · MD5 / SHA1 / SHA256 Hash · HTTP/HTTPS URL | | **情报源** | 27 个活跃源:abuse.ch 套件、AlienVault OTX、Spamhaus、EmergingThreats、Tor、Blocklist.de、CINS Score | | **API 认证** | 原生支持 header 认证 (OTX) 和 body 认证 (MalwareBazaar、ThreatFox、URLhaus) | | **去重** | 每次写入前按类型进行排序的唯一集合 | | **类型安全** | 双层污染防护 —— 解析时的 `_coerce()` + 写入前的 `_enforce_type()` | | **归档** | 每日快照:每个自然日创建一次 `YYYY-MM-DD-{type}.txt` | | **防火墙就绪** | 纯文本输出,无注释头,无格式转义 —— 兼容直接导入 | | **Web 仪表板** | 带有 KPI 卡片、24 小时趋势图、7 天柱状图、IOC 类型分布的 Flask 应用 | | **IOC 编辑器** | 基于浏览器的添加 / 删除 / 批量导入,直接提交到 GitHub | | **时区** | 所有时间戳均采用 UTC+3 (伊斯坦布尔) | | **无状态** | Docker 容器退出后在主机上不留下任何持久化数据 | ## ✦ 架构 ``` ┌─────────────────────────────────────────────────────────────────────┐ │ GitHub Actions (cron 0 * * * *) │ │ │ │ ┌──────────────┐ ┌──────────────────────────────────────────┐ │ │ │ fed0gat.py │ │ Threat Feed Sources │ │ │ │ │────▶│ abuse.ch │ OTX │ Spamhaus │ ... │ │ │ │ Orchestrator│ └──────────────────────────────────────────┘ │ │ └──────┬───────┘ │ │ │ validate · deduplicate · type-enforce │ │ ▼ │ │ ┌──────────────────────────────┐ │ │ │ feeds/ (GitHub Repo) │ │ │ │ │ │ │ │ latest-ip.txt ◀── hourly overwrite │ │ │ latest-hash.txt ◀── hourly overwrite │ │ │ latest-url.txt ◀── hourly overwrite │ │ │ │ │ │ │ 2026-05-28-ip.txt ◀── daily snapshot (once per day) │ │ │ 2026-05-28-hash.txt │ │ │ 2026-05-28-url.txt │ │ │ │ │ │ │ stats.json ◀── appended each run (dashboard data) │ │ └──────────────┬───────────────┘ │ └─────────────────┼───────────────────────────────────────────────────┘ │ GitHub API (read) ┌─────────▼────────┐ ┌─────────────────────┐ │ Web Dashboard │ │ Firewall / EDR │ │ Flask + Chart.js│ │ │ │ │ │ Reads latest-*.txt │ │ KPI Charts │ │ directly from repo │ │ IOC Editor │ │ (raw GitHub URL) │ └──────────────────┘ └─────────────────────┘ ``` ### 双层类型强制 ``` Raw feed data │ ▼ ① _coerce() — Per-entry validation at parse time │ IP source → IPv4/v6 regex only │ Hash source → MD5/SHA1/SHA256 hex only │ URL source → http/https scheme + host required │ ▼ (after all sources collected) ② _enforce_type() — Final gate before any disk write │ Re-validates every IOC against its declared type │ Logs and drops anything that slipped through ▼ latest-ip.txt → IPs only latest-hash.txt → Hashes only (MD5 / SHA1 / SHA256) latest-url.txt → URLs only (live http/https, firewall-ready) ``` ## ✦ 数据源 ### IP 情报源(12 个源,10 个活跃) | 源 | 提供商 | 内容 | |---|---|---| | Feodo Tracker IP Blocklist | abuse.ch | 僵尸网络 C2 服务器 IP (Emotet、TrickBot、QakBot…) | | Feodo Tracker CIDR | abuse.ch | 相同数据,采用子网表示法 | | SSLBL IP Blacklist | abuse.ch | 托管恶意 SSL 证书的 IP | | ThreatFox C2 IPs *(API)* | abuse.ch | 最近的僵尸网络 C2 IP:port IOC | | Blocklist.de | blocklist.de | SSH、邮件、Apache 暴力破解攻击者 IP | | Spamhaus DROP | Spamhaus | 永远不应被路由的网络 | | Spamhaus EDROP | Spamhaus | 扩展的 DROP —— 被劫持的网络块 | | EmergingThreats | Proofpoint | 受感染 / 活跃的攻击者 IP | | CINS Score | CriticalStack | 活跃的恶意 IP 列表 | | Tor Exit Nodes | Tor Project | 所有 Tor 出口节点地址 | | AlienVault OTX IPv4 *(API)* | AT&T Cybersecurity | 社区 pulse IPv4 指标 | ### Hash 情报源(9 个源,全部活跃) | 源 | 提供商 | 内容 | |---|---|---| | MalwareBazaar SHA256 | abuse.ch | 最近的恶意软件样本 SHA256 | | MalwareBazaar MD5 | abuse.ch | 最近的恶意软件样本 MD5 | | MalwareBazaar SHA1 | abuse.ch | 最近的恶意软件样本 SHA1 | | MalwareBazaar API *(API)* | abuse.ch | 扩展的近期样本 —— 所有 Hash 类型 | | ThreatFox SHA256 (CSV) | abuse.ch | ThreatFox 恶意软件 SHA256 IOC | | ThreatFox MD5 (CSV) | abuse.ch | ThreatFox 恶意软件 MD5 IOC | | ThreatFox API SHA256 *(API)* | abuse.ch | 已认证 —— 更高的速率限制 | | AlienVault OTX SHA256 *(API)* | AT&T Cybersecurity | 社区 pulse SHA256 指标 | | AlienVault OTX MD5 *(API)* | AT&T Cybersecurity | 社区 pulse MD5 指标 | ### URL 情报源(6 个源,全部活跃) | 源 | 提供商 | 内容 | |---|---|---| | URLhaus | abuse.ch | 活跃的恶意软件分发 URL | | URLhaus API *(API)* | abuse.ch | 已认证 —— 仅限在线子集 | | ThreatFox URLs (CSV) | abuse.ch | 恶意软件 URL IOC | | ThreatFox API URLs *(API)* | abuse.ch | 已认证 —— 最近 24 小时 | | OpenPhish | OpenPhish | 已验证的钓鱼网站 URL | | AlienVault OTX URLs *(API)* | AT&T Cybersecurity | 社区 pulse URL 指标 | ## ✦ 快速开始 ### 选项 1 —— GitHub Actions(推荐,完全自动化) ``` # 1. Fork 或 clone 此 repository 到你的 GitHub 账号 git clone https://github.com/Tagoletta/Fed0gaT.git cd Fed0gaT # 2. 添加以下 repository secrets: # Settings → Secrets and variables → Actions → New repository secret # Secret name Value # ───────────────────── ────────────────────────────── # OTX_API_KEY (你的 AlienVault OTX API key) # MALWAREBAZAAR_API_KEY (你的 abuse.ch API key) # THREATFOX_API_KEY (你的 abuse.ch API key) # URLHAUS_API_KEY (你的 abuse.ch API key) # # 注意:GITHUB_TOKEN 是自动提供的——请勿手动添加。 # 3. 触发首次运行: # Actions → "Fed0gaT – Hourly CTI Update" → Run workflow # (此后,它将每小时自动运行一次) ``` ### 选项 2 —— Docker(一次性,无状态) ``` # 构建 scraper image docker build -t fed0gat-scraper . # 运行一次(获取所有 feeds,推送到 GitHub,container 干净退出) docker run --rm \ -e GH_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxx \ -e GH_REPO=Tagoletta/Fed0gaT \ -e OTX_API_KEY=your_otx_key \ -e MALWAREBAZAAR_API_KEY=your_abuse_ch_key \ -e THREATFOX_API_KEY=your_abuse_ch_key \ -e URLHAUS_API_KEY=your_abuse_ch_key \ fed0gat-scraper ``` ### 选项 3 —— Docker Compose(抓取器 + 仪表板) ``` # 复制并配置环境 cp .env.example .env # → 编辑 .env:设置 GH_TOKEN, GH_REPO, WEB_SECRET, API keys # 启动 web dashboard docker compose up -d webapp # 手动运行 scraper(或通过主机 cron) docker compose run --rm scraper # 通过主机 cron 调度(每小时): # 0 * * * * docker compose -f /path/to/Fed0gaT/docker-compose.yml run --rm scraper ``` ### 选项 4 —— 本地 Python ``` python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate pip install -r requirements.txt export GH_TOKEN=ghp_xxxx export GH_REPO=Tagoletta/Fed0gaT export OTX_API_KEY=your_key # ... 其他 API keys python fed0gat.py # live run python fed0gat.py --dry-run # test without pushing ``` ## ✦ Web 仪表板 启动仪表板并导航至 `http://localhost:5000` ``` cd webapp pip install -r requirements.txt GH_TOKEN=ghp_xxxx GH_REPO=Tagoletta/Fed0gaT python app.py ``` ### 仪表板功能 ``` ┌──────────────────────────────────────────────────────────┐ │ ⬡ Fed0gaT Dashboard │ │ ──────────────── │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │ │ 12,456 │ │ 8,234 │ │ 3,421 │ │ 24,111 │ │ │ │ Zararlı │ │ Zararlı │ │ Zararlı │ │ Toplam │ │ │ │ IP │ │ Hash │ │ URL │ │ IOC │ │ │ │ +342 ↑ │ │ +89 ↑ │ │ -12 ↓ │ │ │ │ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │ │ │ Son 24 Saat – IOC Trendi Tür Dağılımı │ │ ┌──────────────────────────┐ ┌────────────────────┐ │ │ │ ∿∿∿ IP ∿∿∿ Hash │ │ ◉ │ │ │ │ ∿∿∿ URL │ │ IP 51% │ │ │ └──────────────────────────┘ │ Hash 34% │ │ │ │ URL 15% │ │ │ 7 Günlük Tarihsel Maksimum └────────────────────┘ │ │ ┌──────────────────────────────────────────────────┐ │ │ │ ██ ██ ██ ██ ██ ██ ██ IP / Hash / URL │ │ │ └──────────────────────────────────────────────────┘ │ └──────────────────────────────────────────────────────────┘ ``` ### IOC 编辑器功能 - **3 个标签页**:IP Adresleri / Hash'ler / URL'ler —— 每个标签页上都有实时条目计数 - **搜索和过滤**:即时过滤并带有匹配高亮显示 - **添加条目**:带有实时验证的单行输入 - **批量导入**:通过模态框一次粘贴数百个条目 - **删除**:逐行删除按钮或复选框多选 - **保存**:使用自定义消息直接提交到 GitHub ## ✦ 配置 ### 环境变量 | 变量 | 必需 | 默认值 | 描述 | |---|---|---|---| | `GH_TOKEN` | ✅ | — | GitHub PAT 或 Actions `GITHUB_TOKEN` | | `GH_REPO` | ✅* | auto | 目标仓库 `owner/name`(*在 Actions 中自动检测) | | `GIT_NAME` | — | `Fed0gaT Bot` | Git 提交者名称 | | `GIT_EMAIL` | — | `bot@fed0gat.local` | Git 提交者邮箱 | | `DATA_DIR` | — | `feeds` | 仓库中用于存放情报源文件的子目录 | | `DRY_RUN` | — | `0` | 设置为 `1` 以跳过 GitHub 推送(测试) | | `OTX_API_KEY` | — | — | AlienVault OTX API key | | `MALWAREBAZAAR_API_KEY` | — | — | abuse.ch API key | | `THREATFOX_API_KEY` | — | — | abuse.ch API key | | `URLHAUS_API_KEY` | — | — | abuse.ch API key | | `WEB_SECRET` | (web) | — | 用于仪表板的 Flask 会话密钥 | ### 添加新的情报源 编辑 `sources.json` 并在相应的类型键(`ip`、`hash` 或 `url`)下添加一个条目: ``` { "name": "My Custom Feed", "url": "https://example.com/ioc-feed.txt", "format": "plain", "comment_char": "#", "enabled": true } ``` 对于经过身份验证的情报源: ``` { "name": "My Authenticated Feed", "url": "https://api.example.com/iocs", "format": "json", "method": "POST", "post_body": { "query": "get_recent" }, "json_root": "data", "json_field": "indicator", "api_key_env": "MY_API_KEY", "api_key_body": "api_key", "enabled": true } ``` | 字段 | 值 | 描述 | |---|---|---| | `format` | `plain` / `csv` / `json` | 情报源响应格式 | | `method` | `GET` / `POST` | HTTP 方法 | | `json_root` | string | JSON 中列表的点号路径(例如 `"results"`) | | `json_field` | string | 每个项目内的字段名称 | | `json_filter` | `{"field": "type", "value": "ip"}` | 项目级别过滤器 | | `json_multi_fields` | `["sha256", "md5"]` | 提取每个项目的多个字段 | | `api_key_env` | string | 持有密钥的环境变量名称 | | `api_key_header` | string | HTTP header 名称 (GET header 认证) | | `api_key_body` | string | Body 字段名称 (POST body 认证) | | `strip_port` | `true`/`false` | 从 IP:port 值中移除 `:port` 后缀 | ## ✦ 项目结构 ``` Fed0gaT/ │ ├── fed0gat.py # Core scraper — OOP, modular, stateless ├── sources.json # Feed configuration (27 sources) ├── requirements.txt # Python dependencies │ ├── Dockerfile # Scraper container (python:3.10-alpine) ├── docker-compose.yml # Scraper + dashboard stack ├── .env.example # Environment variable template │ ├── .github/ │ └── workflows/ │ └── fed0gat.yml # GitHub Actions — cron every hour │ └── webapp/ ├── app.py # Flask application (7 API routes) ├── github_client.py # GitHub REST API v3 client ├── requirements.txt # Web app dependencies ├── Dockerfile # Dashboard container (python:3.11-slim) └── templates/ ├── layout.html # Glassmorphic sidebar layout ├── dashboard.html # KPI cards + Chart.js charts └── editor.html # Paginated IOC editor ``` ## ✦ 输出文件 所有文件都位于仓库的 `feeds/` 子目录中。 | 文件 | 更新频率 | 内容 | |---|---|---| | `latest-ip.txt` | 每小时 | 当前 IP 黑名单 —— 纯文本,每行一个条目 | | `latest-hash.txt` | 每小时 | 当前 Hash 列表 —— MD5 / SHA1 / SHA256 | | `latest-url.txt` | 每小时 | 当前 URL 黑名单 —— 实时 `http/https` 格式 | | `YYYY-MM-DD-ip.txt` | 每天 | IP 列表的每日快照 | | `YYYY-MM-DD-hash.txt` | 每天 | Hash 列表的每日快照 | | `YYYY-MM-DD-url.txt` | 每天 | URL 列表的每日快照 | | `stats.json` | 每小时 | 用于仪表板图表的运行历史记录(最近 168 次运行) | ### 直接情报源 URL(用于防火墙 / EDR 集成) ``` https://raw.githubusercontent.com/Tagoletta/Fed0gaT/main/feeds/latest-ip.txt https://raw.githubusercontent.com/Tagoletta/Fed0gaT/main/feeds/latest-hash.txt https://raw.githubusercontent.com/Tagoletta/Fed0gaT/main/feeds/latest-url.txt ``` 这些 URL 返回纯文本、无注释的 IOC 列表 —— 可直接在 Palo Alto、Fortinet、Cisco、CrowdStrike、Sentinel 及类似平台中用作外部威胁情报源。 ## ✦ 工作原理 —— 每小时周期 ``` :00 GitHub Actions runner starts │ ├─ Checkout repository ├─ Install Python dependencies │ ├─ Load sources.json (27 feeds) │ ├─ For each feed source: │ ├─ HTTP GET / POST (with API key if configured) │ ├─ Parse: plain text / CSV / JSON │ ├─ Validate type (Layer 1: _coerce) │ └─ Collect to ip[] / hash[] / url[] │ ├─ Cross-type contamination check (Layer 2: _enforce_type) │ └─ Log and drop any wrong-type entries │ ├─ Daily archive check: │ └─ If yesterday's archive missing → copy latest-*.txt → YYYY-MM-DD-*.txt │ ├─ Write latest-ip.txt / latest-hash.txt / latest-url.txt │ └─ Sorted · Deduplicated · Plain text · No headers │ ├─ Append to stats.json (for dashboard charts) │ ├─ git add -A ├─ git commit -m "Fed0gaT Hourly Update: YYYY-MM-DD HH:MM +03:00" └─ git push → GitHub ``` ## ✦ 安全考量 - **磁盘上无密钥** —— API 密钥仅存在于 GitHub Secrets 或运行时环境变量中;`.env` 已被 git 忽略 - **无持久化主机存储** —— Docker 容器不会向主机文件系统写入任何内容;临时的临时目录在退出时会被删除 - **私有 IP 过滤** —— RFC 1918、loopback、link-local 和广播范围被明确排除在 IP 情报源之外 - **严格的类型强制** —— 根据设计,SHA256 Hash 不可能出现在 `latest-ip.txt` 中;在两个独立的层级进行验证 - **Token 脱敏** —— GitHub token 在打印前会从所有日志输出中进行脱敏处理 ## ✦ 技术栈 | 层级 | 技术 | |---|---| | 抓取器 | Python 3.10+, `requests`, `urllib3` | | 调度 | GitHub Actions (cron) | | 存储 | GitHub 仓库(无状态) | | Web 后端 | Flask 3, Gunicorn | | Web 前端 | Tailwind CSS v3 (CDN), Chart.js v4, JetBrains Mono | | GitHub API | REST API v3(内容读写) | | 容器化 | Docker(抓取器使用 Alpine,Web 应用使用 Slim) | ## ✦ 许可证 MIT 许可证 —— 详情请参阅 [LICENSE]()。
由 Python 构建 · 由 GitHub Actions 驱动 · 威胁数据来自开放安全社区 **[github.com/Tagoletta/Fed0gaT](https://github.com/Tagoletta/Fed0gaT)**
标签:Docker, Flask, Python, 威胁情报, 安全防御评估, 开发者工具, 无后门, 网络安全, 网络调试, 自动化, 请求拦截, 逆向工具, 防火墙, 隐私保护