AlexMatei1/honey-strike

GitHub: AlexMatei1/honey-strike

一款集多协议蜜罐捕获、威胁情报富化与游戏化攻防教学于一体的安全运营平台。

Stars: 0 | Forks: 0

# 🐝 HoneyStrike ### *一个内置学习游戏的多协议蜜罐平台。* 跨 **SSH / HTTP / FTP / RDP / TLS / Telnet / SMTP / Redis** 捕获真实攻击者,通过 **Geo-IP + 滥用信誉 + 工具指纹 + MITRE ATT&CK 归因 + 威胁评分** 富化每一个会话,发送警报,生成 PDF 报告,并让你的操作员**通过输入真实代码学习攻防** —— 所有这些只需一个 `docker compose up -d`。 [![在线演示](https://img.shields.io/badge/live%20demo-honeystrike.icelegends.cloud-f0c040?style=flat-square&logo=cloudflare&logoColor=white)](https://honeystrike.icelegends.cloud) [![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/39/39faa54be350a1dab8afd3b2fb8c1c83e4d9cff84abfef2374d19a18053687c4.svg)](https://github.com/AlexMatei1/honey-strike/actions/workflows/ci.yml) ![status](https://img.shields.io/badge/status-v1.0%20shipped-success?style=flat-square) ![python](https://img.shields.io/badge/python-3.13-blue?style=flat-square) ![fastapi](https://img.shields.io/badge/FastAPI-async-009688?style=flat-square&logo=fastapi) ![postgres](https://img.shields.io/badge/Postgres-16-336791?style=flat-square&logo=postgresql) ![redis](https://img.shields.io/badge/Redis-7%20streams-DC382D?style=flat-square&logo=redis) ![docker](https://img.shields.io/badge/Docker%20Compose-v2-2496ED?style=flat-square&logo=docker) ![tests](https://img.shields.io/badge/tests-201%20unit%20%2B%2034%20integration-success?style=flat-square) ![license](https://img.shields.io/badge/license-MIT-yellow?style=flat-square)
## 目录 - [开发初衷](#why) - [核心功能](#whats-inside) - [实时截图 —— 仪表盘导览](#live-screenshots--the-dashboard-tour) - [架构](#architecture) - [数据流 —— 当攻击者连接时会发生什么](#data-flow--what-happens-when-an-attacker-connects) - [技术栈](#tech-stack) - [快速开始(开发环境)](#quick-start-development) - [生产环境部署](#production-deploy) - [项目布局](#project-layout) - [API 接口概览](#api-surface) - [`honeystrike` CLI](#honeystrike-cli) - [学习平台(Phase 7)](#the-learning-platform-phase-7) - [多人对战(Phase 6)](#multiplayer-phase-6) - [测试](#testing) - [路线图与阶段](#roadmap--phases) - [安全](#security) - [致谢](#acknowledgements) ## 为什么 大多数蜜罐仅仅停留在“记录字节”的层面。HoneyStrike 基于一个不同的理念构建:**你捕获的数据只有在几秒钟内能够阅读、评分并采取行动时才有用。** 因此,该平台是端到端的: 1. **逼真的**伪造服务,其响应足以让真实的扫描器 + 暴力破解工具保持会话。 2. **情报富化流水线**,在 <2 秒内将原始事件转化为经过排名和归因的会话。 3. **操作级 UI**:实时攻击地图、带有回放进度条的会话详情、PDF 报告、用于 SIEM 的 STIX 2.1 / TAXII 2.1 数据流。 4. **游戏化层**:亲手*输入*过 Hydra 暴力破解循环的操作员,在仪表盘上一眼就能认出它。 最终成果是一个单一代码库,既可以作为生产级蜜罐、SOC 培训平台,也可以作为在运行各自实例的朋友之间进行的攻防竞技游戏。 ## 核心功能
### 🎣 捕获层 - **8 个蜜罐监听器** (SSH, HTTP, FTP, RDP, TLS-sniffer, Telnet, SMTP, Redis) - 逼真的预设响应 + **3 个 CTF 风格的 canary token** (虚假 AWS 密钥、虚假 /etc/passwd 条目、虚假管理员 token) - 基于 IP 的速率限制;SSH 上实行 N 次尝试后授权策略 ### 🔬 情报流水线 - **Geo-IP + AbuseIPDB** 查询,缓存在 Redis 中 - **7 条工具签名规则** (Hydra, sqlmap, Nikto, Masscan, …) - **7 条 MITRE ATT&CK 规则** (T1110.001 / T1110.004 / T1190 / T1083 / T1592 / T1595.001 / T1078) - **威胁评分公式** (滥用度 40% + 工具 30% + TTPs 50% + 特权加分) - **ML 异常评分** (Isolation Forest, sklearn),用于异常值检测 - **STIX 2.1 bundle** + **TAXII 2.1 root**,用于 SIEM 摄取 ### 📣 输出层 - **警报**发送至 Telegram、Slack、邮件、Discord,以及结构化日志 - 每个会话的 **PDF / HTML 报告** - **REST API + WebSocket 实时数据流** (`/api/ws/live`) ### 🖥 操作员仪表盘 - 实时世界攻击地图 采用严重程度颜色区分的标记 - 会话列表 + 筛选器(服务、严重程度、时间) - 单个会话详情页,包含时间线、payload 预览、TTPs、警报 - **🎬 回放影院** — 捕获会话的动画播放 - **📡 War Room** — 用于演示的全屏接管视图 - 👤 **个人资料** 包含排名、XP、**15 个徽章**、课程进度、活动日志 ### 🎮 学习平台 - **5 个以上的打字课程**,引导你编写真实的攻击运行器或检测规则 - 每次按键时的动画**吉祥物反应**(正确 / 错误 / 休眠) - 防御者课程针对固件运行参考规则,并**为你的猜测评分** - **实弹发射按钮**:将你刚刚输入的攻击发射到你自己的蜜罐 - **命令面板 (⌘K)**:可跳转到任意位置、触发任何场景、打开任何会话 - **Honey-warm + 网络终端主题**,带有悬浮程序坞、蜂巢六边形背景、实时威胁等级视口边框 ### 🤝 多人游戏与 PvP - **应用内决斗** — 向另一名成员发起限时的 1 对 1 挑战;攻击者发射 场景波次,防御者逐一标记以进行拦截,胜者获得 XP (`/play/duel`) - **开放 PvP 竞技场** — Lead 开启一个窗口;任何人发起攻击,所有人竞相 标记共享的数据流;实时记分板 (`/play/arena`) - **跨实例大厅** (FastAPI + SQLite) — 从一台 VPS 向另一台 VPS 发起 `honeystrike challenge bob`;正确的标记会拦截攻击者的 IP;Discord 汇总 - **账户与角色** — 自助注册,🛡 SOC Lead vs 🔍 Analyst,邮箱验证,管理员 + 自助密码重置
## 实时截图 —— 仪表盘导览 ### 实时攻击地图 Leaflet 世界地图、近期会话侧边栏、四个统计磁贴、悬浮程序坞、环境威胁等级边框。 ![实时地图](https://static.pigsec.cn/wp-content/uploads/repos/cas/f3/f3e902045aae7e91f6f94d21c0c48889b60ec30b8079c9bb104a35e4fbb0bf22.png) ### 攻击课程 — 密码输入中学习 左侧是简报 + MITRE 上下文,右侧是动画蜜蜂吉祥物,带有逐行注释的按块打字阶段。Tab 自动补全,Esc 显示答案。 ![攻击课程](https://static.pigsec.cn/wp-content/uploads/repos/cas/52/52ca7021b58a6611965eb7d589035ff36c7d41ed1a921afbe6bdab5cfd4d1ec5.png) ### 防御者课程 — 编写检测规则 输入真实的 TTP 规则主体;评分器针对固件运行参考规则,并显示结果 + 源码摘录。 ![防御者课程](https://static.pigsec.cn/wp-content/uploads/repos/cas/96/963d113728237ba7fe193661e4b3a02f7ea472828c6836e4657cc00ec064ea30.png) ### 个人资料 — 排名、XP、徽章 带有 XP 进度条的排名阶梯、历史统计以及随着游戏解锁的 15 个徽章网格。 ![个人资料](https://static.pigsec.cn/wp-content/uploads/repos/cas/6a/6a30d797e08ecda3d35a4a1f2eda3171f552ab4d56d94f0fb6a3aeffc8e16c41.png) ### 命令面板 (⌘K) 模糊跳转到任何页面、会话或课程 — 或者直接从提示符处触发任何攻击场景。 ![命令面板](https://static.pigsec.cn/wp-content/uploads/repos/cas/cb/cbcb3067bbee2413399f07578c2fab7bd3881168b1636b69fb92e7e761fcf538.png) ### War Room 用于墙显的全屏接管视图:巨大的统计数据、世界地图和滚动的攻击 ticker。 ![War Room](https://static.pigsec.cn/wp-content/uploads/repos/cas/ca/ca441f1b9f2873796acf2ad5f12f960eb0f7abd76b599623638f235baa67af53.png) ### 页面参考 | 页面 | 亮点 | |---|---| | `/` 实时地图 | Leaflet 世界地图,近期会话侧边栏,四个大统计磁贴,环境威胁边框。 | | `/sessions/` | 来源 + 指纹 + 工具签名 + MITRE TTPs + 事件预览 + 警报 + **🎬 回放** 按钮 + 🚫 拦截 按钮。 | | `/sessions//replay` | 进度条 + 播放/暂停 + 速度选择;随着事件展开,威胁评分条在合成帧中攀升。 | | `/play/attack/` | 打字课程:简报 + 带有光标的代码阶段 + 注释面板 + 动画蜜蜂吉祥物。 | | `/play/defend/` | 输入检测规则主体,针对固件运行它,获得绿/红反馈 + 参考摘录。 | | `/play/defend/arena` | 实时标记与拦截竞技场:传入的会话以卡片形式流入,带有 TTP 自动补全 + 拦截按钮 + 5 分钟倒计时侧边栏。 | | `/warroom` | 用于挂墙演示的全屏接管视图:巨大的统计数据、世界地图、滚动的攻击 ticker。 | | `/profile` | 用户名 + 排名进度条 + XP + 15 个徽章网格 + 课程进度 + 近期活动。 | 吉祥物会在每个页面跟随你 — 大多数页面在右上角,课程页面则是全尺寸 — 并对正确/错误的按键、升级时刻和空闲时间做出反应。 ## 架构 每个服务运行在独立容器中,并进行网络隔离。**任何蜜罐监听器都无法直接访问 Postgres 或 Redis** — 它们只与进程内的会话管理器通信,由后者写入 Redis Streams。`intel-net` 中的 worker 消费这些数据流,并写入 `internal-net` 中的 Postgres。 ``` flowchart LR classDef honeypot fill:#2a1c0c,stroke:#f0883e,color:#f5e9d4 classDef worker fill:#2a1c0c,stroke:#5ed27f,color:#f5e9d4 classDef api fill:#2a1c0c,stroke:#f0c040,color:#f5e9d4 classDef store fill:#1c1308,stroke:#9b8567,color:#f5e9d4,stroke-dasharray: 5 5 classDef ext fill:#1c1308,stroke:#ff4a3d,color:#f5e9d4 Attacker[/" Internet attacker "/]:::ext subgraph Honeypots["honeypot-net (DMZ)"] SSH["ssh-honeypot
Paramiko · :22"]:::honeypot HTTP["http-honeypot
FastAPI · :80"]:::honeypot FTP["ftp-honeypot
pyftpdlib · :21"]:::honeypot RDP["rdp-honeypot
asyncio · :3389"]:::honeypot TLS["tls-sniffer
JA3 · :443"]:::honeypot end subgraph Stores["internal-net (no egress)"] Redis[("Redis 7
streams + cache + blocklist")]:::store Postgres[("Postgres 16
events · fingerprints
ttp_matches · alerts · reports")]:::store end subgraph Workers["intel-net (egress to enrichment APIs)"] FP["FingerprintWorker
(consumer-group: intel)"]:::worker ALERT["AlertingWorker"]:::worker REPORT["ReportWorker"]:::worker end subgraph APIs["api-net"] API["dashboard-api
FastAPI · :8001"]:::api LOBBY["lobby-api
FastAPI · :8002"]:::api end subgraph EXT["External"] MM["MaxMind GeoLite2"]:::ext AB["AbuseIPDB"]:::ext TG["Telegram / Slack /
Email / Discord"]:::ext DASH["Browser / SIEM"]:::ext end Attacker --> SSH & HTTP & FTP & RDP & TLS SSH -.->|XADD events| Redis HTTP -.-> Redis FTP -.-> Redis RDP -.-> Redis TLS -.-> Redis Redis -->|XREADGROUP intel| FP FP -->|GeoLite2| MM FP -->|abuse score| AB FP -->|fingerprint+ttps| Postgres Postgres --> ALERT ALERT --> TG Postgres --> REPORT REPORT --> Postgres Postgres <--> API Redis <-->|blocklist| API LOBBY <-->|HTTPS| DASH API <-->|HTTPS + WS| DASH API -->|is_blocked?| Redis Redis -.->|drop connection| SSH & HTTP & FTP & RDP & TLS ``` 三个 Docker 网络隔离了各个关注点: | 网络 | 成员 | 是否允许出站? | |---|---|---| | `honeypot-net` | 5 个监听器 + Redis (仅可达 Redis,而非其数据 — 仅限 XADD) | ❌ | | `intel-net` | Workers + Redis + Postgres + MaxMind/AbuseIPDB 调用 | ✅ 仅限这两个 API | | `internal-net` | Postgres + Redis + workers + dashboard-api | ❌ | | `api-net` | dashboard-api, lobby-api, Caddy reverse proxy | ✅ (操作员通过 TLS 访问) | 查看 [`docs/architecture.md`](docs/architecture.md) 获取完整的 Mermaid 图表(组件 / 时序 / 网络隔离),以及 [`docs/11_Infrastructure_Topology.md`](docs/11_Infrastructure_Topology.md) 了解文字描述版本。 ## 数据流 —— 当攻击者连接时会发生什么 ``` attacker listener Redis FingerprintWorker Postgres AlertingWorker │ │ │ │ │ │ 1. TCP connect ───────────► │ │ │ │ │ │ is_blocked(ip)? ─►│ │ │ │ │ ◄── 0 (proceed) ── │ │ │ │ │ SESSION_OPEN event ─► XADD │ │ │ 2. SSH brute-force loop ───► │ │ │ │ │ │ 7× SSH_AUTH_ATTEMPT ─► XADD │ │ │ │ │ ── XREADGROUP ──────►│ │ │ │ │ │ + GeoLite2 lookup │ │ │ │ │ + AbuseIPDB call │ │ │ │ │ + 7 tool sigs │ │ │ │ │ + 7 MITRE rules │ │ │ │ │ + threat score │ │ │ │ │ INSERT fingerprint ──►│ │ │ │ │ INSERT ttp_matches ──►│ │ │ SSH_COMMAND (whoami)─► XADD │ │ │ │ │ │ │ trigger alert? │ │ │ │ │ ──── poll ────────────►│ │ │ │ │ │ │ SESSION_CLOSE │ │ │ │ POST Telegram/Slack │ │ │ │ │ POST Discord webhook │ │ │ │ ◄── dispatch_alert ────│ browser /api/ws/live ◄────┴─────────────────────┴─── new session msg ───┴────────────────────────┘ │ │ defender clicks 🚫 Block on /sessions/: │ browser ─ POST /api/defender/block ─► dashboard-api ─ SET blocklist: EX 300 ─► Redis ───────► every listener checks ────┘ on next accept(), drops the connection. ``` 在 2 vCPU 的 VPS 上,从“攻击者发送字节”到“会话完成富化 + 触发警报 + 更新 UI”的端到端延迟远低于 **2 秒**。 ## 技术栈
层级技术栈
蜜罐监听器Python 3.13 · asyncio · Paramiko (SSH) · FastAPI (HTTP) · pyftpdlib (FTP) · 原生 asyncio (RDP TPKT/X.224) · 自定义 TLS sniffer (JA3)
WorkersPython 3.13 · Redis-streams 消费组 · scikit-learn (Isolation Forest) · WeasyPrint (PDF) · structlog · prometheus-client
持久化PostgreSQL 16 (TIMESTAMPTZ, JSONB, inet) · Redis 7 (streams + + blocklist) · SQLite (仅大厅使用,单实例)
API + UIFastAPI (async, OpenAPI 3.1) · SQLAlchemy 2.0 async · Pydantic v2 · WebSocket · Jinja2 模板 · 原生 JS · Leaflet 地图 · Chart.js · Google Fonts (Space Grotesk + Inter + JetBrains Mono)
情报MaxMind GeoLite2 · AbuseIPDB · MITRE ATT&CK v15 STIX 2.1 bundle · JA3 client-hello 指纹 · 自定义工具签名规则引擎
输出STIX 2.1 bundles + TAXII 2.1 collections · Telegram / Slack / Discord / SMTP 警报通道 · PDF + HTML 报告
CLITyper + Rich · 单一 `honeystrike` 入口点,包含 `attack`, `defend`, `lobby`, `login` 子应用
基础设施Docker Compose v2 · Caddy 反向代理 (ACME) · Alembic 迁移 · GitHub Actions CI (质量 + 单元 + 集成 + 迁移 + 依赖审计 + 容器扫描)
可观测性structlog JSON 日志 · Prometheus metrics endpoint · 预置的 Grafana 仪表盘 JSON
## 免部署体验 **▶ 在线演示:https://honeystrike.icelegends.cloud** — 在登录页面**创建你自己的 账户**(你将成为一名 🔍 **Analyst**),或使用 `admin` / `change-me-strong-password`(一名 🛡 **SOC Lead**)。点击四处看看(合成数据; 实时捕获端口已关闭),做一下打字课程,赚取 XP + 徽章。Lead 还可以额外发射实时攻击、封锁 IP 并管理用户;Analyst 看到的这些操作会被 🔒 锁定并附带一行原因 — UI 在教授 SOC 角色模型。每个账户的 XP/徽章都会保存在服务器端,并随登录状态保留。 想要你自己的实例?只需一条命令即可搭建一个**只读演示**(仪表盘 + 合成数据,无 实时捕获端口)—— 或者点击在 Render/Fly 上部署。参见 [`DEMO_DEPLOY.md`](DEMO_DEPLOY.md)。 ``` cp .env.demo.example .env.demo # set ADMIN_PASSWORD + JWT_SECRET docker compose -f docker-compose.demo.yml up -d --build # → http://localhost:8001/login ``` ## 快速开始(开发环境) 你需要:**Docker Desktop** (Compose v2),或者如果你想在容器外运行部分组件,则需要 Python 3.13 + Poetry。 ``` git clone https://github.com/AlexMatei1/honey-strike.git cd honey-strike # 1. Environment cp .env.example .env # 编辑 .env 如果你需要非默认的端口 / 密码。默认配置适用于本地使用。 # 2. 启动整个 stack docker compose -f docker-compose.dev.yml up -d --build # 3. (仅首次运行)对容器中的 Postgres 运行 migrations docker exec honeystrike-api alembic upgrade head # 4. 打开 dashboard # http://localhost:8001/login # admin / change-me-strong-password (或你在 .env 中设置的任何内容) ``` 蜜罐端口(宿主机 → 容器): | 服务 | 宿主机端口 | 容器 | 试试看 | |---|---|---|---| | SSH | `2222` | `:22` | `ssh root@127.0.0.1 -p 2222` (任何密码在尝试 N 次后都会失败) | | HTTP | `18080` | `:80` | `curl -A 'sqlmap/1.0' 'http://127.0.0.1:18080/wp-admin/index.php?id=1+UNION+SELECT+1'` | | FTP | `2221` | `:21` | `ftp 127.0.0.1 2221` | | RDP | `33389` | `:3389` | `nmap -sV -p 33389 127.0.0.1` | | TLS sniffer | `8443` | `:443` | `openssl s_client -connect 127.0.0.1:8443 -servername example.com` | | Telnet | `2323` | `:23` | `telnet 127.0.0.1 2323` (登录循环,总是失败) | | SMTP | `2525` | `:25` | `nc 127.0.0.1 2525` 然后 `EHLO x` / `RCPT TO:` (拒绝中继) | | Redis | `16379` | `:6379` | `redis-cli -p 16379 INFO` (虚假的未授权 Redis;`CONFIG SET dir` 会被标记) | | Dashboard API | `8001` | `:8000` | http://localhost:8001 | | Lobby API | `8002` | `:8002` | http://localhost:8002/lobby/players | 想跳过 Docker?`poetry install && poetry run alembic upgrade head && poetry run uvicorn honeystrike.api:app --reload`。你需要在可访问的地方部署 Postgres + Redis。 ## 生产环境部署 单 VPS 部署。Caddy 在 `:443` 上代理一切(通过 ACME 获取免费的 Let's Encrypt 证书),蜜罐端口直接暴露。 ``` ssh root@ git clone https://github.com/AlexMatei1/honey-strike.git cd honey-strike cp .env.production.example .env.production # 填写:DOMAIN,真实的 ADMIN_PASSWORD,ABUSEIPDB_API_KEY,MAXMIND_LICENSE_KEY, # 可选的 TELEGRAM_BOT_TOKEN / SLACK_WEBHOOK_URL / DISCORD_WEBHOOK_URL docker compose -f docker-compose.prod.yml --env-file .env.production up -d ``` 完整的操作手册:[`DEPLOY.md`](DEPLOY.md)。灾难恢复演练步骤:[`docs/13_Disaster_Recovery_Playbook.md`](docs/13_Disaster_Recovery_Playbook.md)。上线前检查清单:[`docs/19_HONEYSTRIKE_Production_Readiness_Checklist.md`](docs/19_HONEYSTRIKE_Production_Readiness_Checklist.md)。 ## 项目布局 ``` honey-strike/ ├── alembic/ ▸ migrations (001 → 004) ├── docs/ ▸ 20 design docs (spec, schema, runbooks, DR, …) ├── infra/ ▸ Caddyfile, systemd unit, Grafana dashboard JSON ├── samples/ ▸ MaxMind & STIX sample blobs for tests ├── scripts/ ▸ ad-hoc probes (e.g. probe_ssh_hydra.py) ├── src/honeystrike/ │ ├── api/ ▸ FastAPI app │ │ ├── app.py ▸ factory + 14 HTML routes + router wiring │ │ ├── routers/ ▸ auth · sessions · stats · stix · taxii │ │ │ defender · play · replay · health · ws │ │ │ lessons · profile │ │ ├── templates/ ▸ 14 Jinja pages (dashboard, sessions, replay, │ │ │ warroom, profile, lesson, _mascot, _base, …) │ │ ├── static/ ▸ app.css + 13 JS modules (lesson engine, │ │ │ command palette, threat border, mascot, …) │ │ └── lessons/ ▸ TOML lesson content + JSON fixtures │ ├── cli/ ▸ typer app │ │ ├── attack/ ▸ runners.py · scenarios.py · campaigns.py │ │ │ canaries.py │ │ └── defend/ ▸ snapshot · tail · narrate · campaign_score │ │ flags · label │ ├── core/ ▸ models · db · events · logging · blocklist │ │ session_manager · config │ ├── lobby/ ▸ FastAPI service for multiplayer matchmaking │ ├── services/ ▸ the 8 honeypot listeners │ │ ├── ssh/ server.py · shell.py · attempt_counter.py · host_key.py │ │ ├── http/ server.py · detectors.py · ja3.py · templates.py │ │ ├── ftp/ handler.py · __main__.py │ │ ├── rdp/ pdu.py · __main__.py │ │ ├── tls_sniffer/ __main__.py │ │ ├── telnet/ protocol.py · __main__.py │ │ ├── smtp/ protocol.py · __main__.py │ │ └── redis_honeypot/ protocol.py · __main__.py │ └── workers/ │ ├── intel/ geo · abuseipdb · signatures · fingerprint · aggregator │ │ ttp_rules · threat_scoring · ml_anomaly │ ├── alerting/ channels.py · dispatch.py │ └── reports/ pdf_renderer.py · queue_consumer.py ├── tests/ │ ├── unit/ ▸ 248 unit tests (pytest, asyncio mode auto) │ ├── e2e/ ▸ Playwright smoke tests + screenshot capture │ └── integration/ ▸ 34 live tests against the running stack ├── docker-compose.dev.yml ▸ full stack for dev ├── docker-compose.prod.yml ▸ prod profile + Caddy reverse proxy ├── Dockerfile / Dockerfile.dev ├── pyproject.toml ▸ Poetry deps + `honeystrike` CLI script entry ├── DEMO.md ▸ guided walkthrough for first-time operators ├── DEPLOY.md ▸ production deploy ├── TESTING.md ▸ all test invocations + manual smoke └── docs/PRESENTATION.md ▸ deep technical walkthrough (this commit) ``` ## API 接口概览 OpenAPI 位于 **`/api/openapi.json`** · Swagger UI 位于 **`/api/docs`**。 | 分组 | Endpoints | |---|---| | **Auth** | `POST /api/auth/login` · `POST /api/auth/refresh` · `POST /api/auth/logout` | | **Sessions** | `GET /api/sessions` (分页 + 过滤) · `GET /api/sessions/{id}` · `GET /api/sessions/{id}/events` · `POST + GET /api/sessions/{id}/report` | | **Live** | `WS /api/ws/live?token=…&poll=2` | | **Stats** | `/api/stats/overview` · `/ttps` · `/geo` · `/timeline` | | **STIX / TAXII** | `GET /api/stix/bundle` · `GET /api/stix/identity` · `GET /api/stix/stats` · `GET /taxii2/{api_root}/collections/{id}/objects/` | | **Defender 游戏** | `POST /api/defender/label` · `POST /api/defender/block` · `GET / DELETE /api/defender/block/{ip}` | | **Play (REST → CLI 运行器)** | `GET /api/play/scenarios` · `POST /api/play/attack` · `GET /api/play/attack/{task_id}` · `POST /api/play/campaign` · `GET /api/play/tasks` | | **Replay** | `GET /api/replay/{session_id}` — 带有 `t_ms` 偏移量的事件 + 合成的评分时间线 | | **Lessons** | `GET /api/lessons` · `GET /api/lessons/{family}/{id}` · `GET /api/lessons/fixtures/{name}` · `POST /api/lessons/grade-defender` | | **Profile** | `GET /api/profile` — 用户名、角色、统计、成员资历 | | **Health** | `GET /api/health` (存活) + `GET /metrics` (Prometheus) | 认证使用 JWT bearer (HS256,1 小时访问 TTL,30 天刷新存储在 HttpOnly cookie 中)。WebSocket 将访问令牌作为查询字符串接收,因为浏览器无法在升级请求时设置 Header。 ## `honeystrike` CLI 一个带有子命令组的 Typer 入口点。Token 缓存在 `~/.honeystrike/token` (mode 0600)。 ``` # Auth honeystrike login # caches the JWT # 攻击者场景 honeystrike attack list # list all 10 scenarios + 4 campaigns honeystrike attack ssh-hydra --keep-shell # paramiko brute force + post-auth shell honeystrike attack http-recon # nikto-style path probes + canary detection honeystrike attack http-sqlmap # UNION-SELECT with the sqlmap UA honeystrike attack http-log4shell --callback ldap://… # CVE-2021-44228 payload honeystrike attack multi-service --target-host 1.2.3.4 # guaranteed T1595.001 honeystrike attack full-compromise --report # recon → SQLi → SSH → shell → FTP → TLS # Campaigns(命名的对手模拟) honeystrike attack campaign apt28 honeystrike attack campaign fin7 honeystrike attack campaign ransomware-deployer honeystrike attack campaign script-kiddie # Defender 快照 honeystrike defend recent --service ssh --min-score 50 honeystrike defend show # narrative incident-response writeup honeystrike defend top-attackers --days 7 honeystrike defend top-ttps --days 30 honeystrike defend alerts --severity high honeystrike defend tail --severity critical # live WebSocket honeystrike defend narrate --bell # natural-language live narration honeystrike defend campaign-score # TTP-attribution accuracy honeystrike defend flags-found # canary captures honeystrike defend report --open # generate + open PDF # Multiplayer honeystrike register --lobby https://lobby.example --handle alice honeystrike players # who's online honeystrike challenge bob --scenario apt28 --duration 300 honeystrike defend listen # accept incoming challenges honeystrike defend label T1110.001 # post-hoc label ``` 每个 CLI 流程在仪表盘中都有对应的按钮 — 参见 [学习平台](#the-learning-platform-phase-7)。 ## 学习平台 (Phase 7) 最大的差异化所在。仪表盘不仅仅是为了阅读;它是为了*通过输入来学习*。 ### 攻击课程 从 **`/play/attack`** 选择一个场景,你就会进入一个打字课程: ``` 🐝 SSH brute force (Hydra style) ⚡145 XP 👤 ╭──────────────────────────────────╮ ╭──────────────────────╮ │ Briefing │ │ 🐝 │ │ │ │ (animated bee) │ │ MITRE T1110.001 — Hydra tries │ │ idle wing flap │ │ password after password against │ │ │ │ a fixed username. Defender side: │ │ "Type the highlighted│ │ ≥6 SSH_AUTH_ATTEMPT in one │ │ line. Tab = autocompl│ │ session = T1110.001 fires. │ │ Esc = reveal." │ ╰───────────────────────────────────╯ ╰──────────────────────╯ Code stage (typing game) sock = socket.create_connection((host, port), timeout=10) ✓ done t = paramiko.Transport(sock) ✓ done t.▌start_client(timeout=10) ◄ typing for pw in passwords: … pending Annotation start_client() sends our SSH banner, receives the server's, performs KEX. After this we can attempt auth. ↻ Replay fixture 🚀 Fire live 6 / 15 blocks ``` - 对来自 [`src/honeystrike/cli/attack/runners.py`](src/honeystrike/cli/attack/runners.py) 的*真实*运行器进行**按块输入**。 - 按错键会闪现红光 + 让吉祥物摇晃。Tab 自动补全一行。Esc 显示答案。 - 混合模型:针对暴力破解 / 编排课程使用 **Python**,针对侦察 / sqlmap / canary 课程使用 **CLI 命令 (`curl …`)**。 - 结束时的 **🚀 Fire live** 会 POST 到 `/api/play/attack`,针对你的蜜罐运行真实攻击。**↻ Replay fixture** 则会播放一个确定性的事件序列。 ### 防御者课程 相同的引擎,镜像反转。输入来自 [`src/honeystrike/workers/intel/ttp_rules.py`](src/honeystrike/workers/intel/ttp_rules.py) 的真实 TTP 规则主体;评分器针对固件运行*参考*规则,告诉你它是否触发 + 并排显示参考摘录。**永远不会执行任何用户代码** — 打字游戏基于与参考字符的完美匹配进行拦截,因此运行的唯一 Python 代码就是仓库中已有的代码。 ### 吉祥物反应 | 状态 | 触发条件 | 动画 | |---|---|---| | `idle` | 等待输入 | 缓慢拍打翅膀,偶尔眨眼 | | `happy` | 正确按键 | 跳跃 + 脉冲发光 | | `shock` | 错误按键 | 水平摇晃,红色色调,头顶出现 ❗ | | `cheer` | 完成输入块 | 弹跳 + 闪光 | | `sleep` | 60 秒无输入 | 打呼噜 zzz | ### XP、排名、徽章 保存在 `localStorage` 中 — 单操作员平台,无服务端游戏化状态。 - **排名**:Apprentice (0 XP) → Sentry (25) → Defender (75) → Hunter (150) → Veteran (300) → Threat-OG (600) → **HoneyMaster (1000)**。 - **奖励**:+15 完成课程 · +10 正确标记 (+连胜) · −2 错误标记 (重置连胜) · +5 捕获 canary · +3 拦截攻击者。 - **15 个徽章** 通过达成里程碑解锁 — 查看你的 `/profile` 页面。 ### 命令面板 · ⌘K 从任意位置按下 Ctrl+K 即可跳转到某个会话、打开课程、触发攻击场景或进行导航。它将 `/api/lessons` + `/api/play/scenarios` + 最近的 25 个会话 + 每个导航目标聚合到一个模糊搜索列表中。 ## 多人游戏 (Phase 6) 两个朋友,两台 VPS。各自运行自己的 HoneyStrike 技术栈,并指向同一个共享的**大厅服务**。 ``` Alice's VPS Lobby (anyone hosts) Bob's VPS ┌──────────────┐ ┌──────────────────┐ ┌──────────────┐ │ honeystrike │ ── register ►│ POST /lobby/ │◄── register ─┤ honeystrike │ │ register │ │ register │ │ register │ │ │ │ + heartbeat 30s │ │ │ │ honeystrike │ ── invite ──►│ │ │ honeystrike │ │ challenge │ │ POST /lobby/ │ │ defend listen│ │ bob … │ │ accept ──────►│ ─── push ───►│ │ │ │ │ │ │ │ │ ──── attacks bob.example:2222, :18080, … ──────────────────► │ ssh-honeypot │ │ │ │ │ │ http-honeypot│ │ │ │ │ │ │ │ attack run │ ◄────────────│ │ │ narrate + lab│ │ │ │ POST /lobby/ │ │ + correct la │ │ │ │ match/{id}/finish│ │ blocks ip │ │ │ ◄── summary ─┤ ──── Discord ───►│ ─── summary ─┤ │ └──────────────┘ └──────────────────┘ └──────────────┘ ``` - 大厅 = 小型 FastAPI + SQLite (一个容器,端口 `8002`),无 Postgres 依赖。 - 邀请码、接受/拒绝流程,可通过 `/lobby/match/{id}` 获取当前比赛状态。 - 比赛总结会发送到每个玩家配置的共享 Discord webhook。 - **拦截机制**:防御者的正确标记会将攻击者的 `src_ip` 添加到基于 Redis 的 blocklist 中,TTL 为 5 分钟;每个监听器在接受连接时都会检查 `is_blocked()` 并断开连接。 ## 测试 ``` # 在正在运行的 api 容器内部(推荐 — 包含所有 deps): docker exec honeystrike-api pytest tests/unit -q docker exec honeystrike-api pytest tests/integration -q # 全部: docker exec honeystrike-api pytest -q ``` - **248 个单元测试** — 涵盖事件、模型、会话管理器、每个监听器(包括 Telnet/SMTP/Redis 协议解析器)、情报流水线(geo / abuse / signatures / fingerprint / ttp_rules / threat_scoring)、警报通道、报告、STIX/TAXII、大厅存储、课程路由器 + 漂移防护、play 速率限制器、实时数据流发布/订阅以及 CLI。 - **34 个集成测试** — 针对运行中的 compose 技术栈进行全栈测试(SSH 暴力破解、HTTP 侦察、sqlmap、log4shell、目录遍历、FTP 暴力破解、RDP 扫描、TLS JA3、回放、大厅注册/邀请/接受、防御者拦截、canary 捕获)。 - **8 个 Playwright e2e 冒烟测试** + 截图捕获位于 [`tests/e2e/`](tests/e2e/) 中 — 登录、每个页面、断验程序坞/地图/课程/徽章/命令面板正常渲染。运行方式:`cd tests/e2e && npm install && npm run install-browser && npm test`。 - **覆盖率门槛**:80%(低于此标准 CI 将会失败)。 - **默认可移植**:两个具有重依赖的测试(`test_ml_anomaly` 需要 scikit-learn,`test_report_renderer` 需要 WeasyPrint 本地库)在缺少依赖时会**干净地跳过**,因此 `pytest tests/unit` 在任何检出环境下都能通过。 查看 [`TESTING.md`](TESTING.md) 了解完整的测试矩阵 + 手动冒烟测试流程。 ## 路线图与阶段 90 天交付计划(见 [`docs/10_90_Day_Delivery_Plan.md`](docs/10_90_Day_Delivery_Plan.md))推动每个阶段达到了绿色的里程碑门槛: | 阶段 | 周数 | 主题 | 状态 | |---|---|---|---| | **1** | 1–4 | 基础:schema、迁移、CI、structlog、基础 API | ✅ | | **2** | 5–8 | 5 个蜜罐监听器 + 会话管理器 + Redis Streams | ✅ | | **3** | 9–12 | 情报:geo、abuse、工具签名、指纹、MITRE 规则、威胁评分 | ✅ | | **4** | 13–15 | 警报、PDF/HTML 报告、STIX/TAXII | ✅ | | **5** | 16–18 | 仪表盘 UI、分析、WebSocket 实时数据流 | ✅ | | **6** | 19–22 | `honeystrike` CLI + 大厅服务 + 拦截机制 + Discord 警报 | ✅ | | **7** | 23–25 | 学习平台:课程、吉祥物、XP/徽章、命令面板、程序坞 + 威胁边框 UI | ✅ | 未来可能的工作(尚未承诺):公开的比赛排行榜、操作员之间的威胁情报源联邦、原生移动伴侣应用、基于 LLM 的更深度的回放旁白。 ## 安全 - **仅限蜜罐。** 不要将真实服务指向此技术栈。 - **出站流量**:蜜罐容器无法直接访问互联网。Worker 可以,但仅限于访问 MaxMind + AbuseIPDB。 - **无原始 payload 回显**:每个警报/报告都会对攻击者输入进行过滤清理(HTML 转义、长度限制、去除控制字符)。 - **认证**:采用短访问 TTL + 刷新轮换的 JWT。管理员密码经过哈希处理。登录失败受速率限制。 - **合规性**:数据保留矩阵见 [`docs/06_Data_Retention_Matrix.md`](docs/06_Data_Retention_Matrix.md);法律/隐私说明见 [`docs/07_Compliance_and_Legal_Packet.md`](docs/07_Compliance_and_Legal_Packet.md) + [`docs/08_Capture_Flows_and_Privacy.md`](docs/08_Capture_Flows_and_Privacy.md)。 - **负责任的披露**:[`SECURITY.md`](SECURITY.md)。 ## 致谢 - **MITRE ATT&CK®** — © The MITRE Corporation。根据 [ATT&CK 使用条款](https://attack.mitre.org/resources/terms-of-use/) 使用。 - **MaxMind GeoLite2** — 免费的地理位置数据库。 - **AbuseIPDB** — IP 信誉评分。 - 蜜罐监听器库:**Paramiko**、**pyftpdlib**、**FastAPI**。 - 使用 [**Claude Code**](https://claude.com/claude-code) 构建。
**专为 SOC 培训、CTF、友谊赛以及捕获真实威胁而生。** `docker compose up -d` 然后打开 `http://localhost:8001/login`。
标签:AV绕过, CISA项目, Docker, FastAPI, PE 加载器, Python, TGT, 威胁情报, 安全运营, 安全防御评估, 开发者工具, 扫描框架, 搜索引擎查询, 攻防演练, 无后门, 测试用例, 蜜罐, 证书利用, 请求拦截, 逆向工具