0xsamesh/idaps_red_blue_team_simulator

GitHub: 0xsamesh/idaps_red_blue_team_simulator

一个游戏化的红蓝队网络安全对抗模拟器,通过确定性引擎和实时 Web 仪表盘直观展示攻击与防御手段的博弈过程。

Stars: 0 | Forks: 0

# IDAPS — 入侵检测与防御模拟器 一个游戏化的**红队对抗蓝队**网络安全模拟器。红队发起攻击;蓝队部署能够**检测**和**防御**这些攻击的手段。计分引擎会跟踪整个对抗过程并决出胜负。 ## 功能 - **核心引擎** — 插件注册表、虚拟网络模型、tick 循环、解析器和计分系统 - **6 种攻击手段**(红队)和 **13 种防御手段**(蓝队) - 终端中的**机器人对战自动战斗** - **Web 仪表盘** — FastAPI + WebSocket 将实时比赛流式传输到浏览器(网络地图、攻击动画、记分牌、事件源) - **四种游戏模式** — AI 对 AI、玩家(红队)对 AI、玩家(蓝队)对 AI,以及玩家对玩家 - **确定性机制** — 每场比赛都有种子设定,因此特定的种子总是能完全复现(非常适合用于演示和测试) ## 快速开始 ``` # Terminal 版本(无依赖 — 纯标准库) python -m idaps.cli --seed 7 # Web 仪表板(可视化演示) python -m pip install -r requirements.txt python -m idaps.server # 然后打开 http://localhost:8000 # 测试 python tests/test_engine.py ``` 引擎和终端版本**不需要任何第三方包**。`fastapi` 和 `uvicorn` 仅在 Web 仪表盘中需要。 ## 攻击手段(红队) | 手段 | 类别 | 克星 | 严重程度 | |---|---|---|---| | DDoS | 可用性 | Rate Limiting, Firewall, Segmentation | 中 | | Brute Force | 凭据 | MFA, Rate Limiting, Account Lockout | 中 | | SQL 注入 | Web 注入 | WAF, Input Validation, Patching | 高 | | 网络钓鱼 | 社会工程学 | Email Filter, User Training | 高 | | MITM | 网络拦截 | TLS Encryption, Segmentation | 高 | | XSS | Web 注入 | WAF, Input Validation, CSP | 中 | ## 计分 ``` Attack success → +10 Red (×1.5 for high-severity vectors) Detection → +10 Blue Prevention → +20 Blue Stealth bonus → +5 Red (success with no detection) Survival bonus → +2 Blue (a tick with no new compromise) ``` ## 解析器如何决定结果 针对目标主机的活动防御,每次攻击的结果如下: 1. **防御** — 具备防御能力的手段(例如 WAF, TLS)可以直接将其拦截。这对蓝队最有利。 2. **成功** — 如果未被拦截,则根据该手段的基础成功率进行判定,实际成功率会受现有防御措施的削弱。 3. **检测** — IDS / 监控可能会触发警报,这与攻击是否成功无关。越难被检测的手段(MITM、网络钓鱼)更容易避开检测器。 所有的随机性都通过一个单一且带种子的 RNG 处理,因此结果是完全可复现的。 ## 架构 ``` idaps/ registry.py plugin registries for attacks & defenses network.py virtual network: hosts, services, categories base.py AttackVector / Defense base classes, Action, AttackResult vectors.py the six attack vectors (Red) defenses.py the defense library (Blue) scoring.py the scoring engine resolver.py prevention / success / detection logic — the core bots.py Red & Blue bot strategies game.py the tick loop / match engine cli.py terminal runner server.py FastAPI + WebSocket layer (all four game modes) serialize.py turns engine objects into JSON for the dashboard static/ browser dashboard (index.html, app.js, style.css) tests/ test_engine.py ``` 引擎从不关心是*谁*发起了操作 —— 它只负责处理 `Action` 对象。机器人、通过 Web UI 的人类玩家,或者 PvP 中的两名人类玩家,都会产生相同的 `Action`。正是这种单一的接口设计,让所有游戏模式都能复用完全相同的引擎。 ## 扩展指南 添加新的攻击手段无需更改引擎 —— 只需声明一个类并将其注册即可: ``` # 在 idaps/vectors.py 中 @register_attack class PrivilegeEscalation(AttackVector): name = "Privilege Escalation" targets = ["user", "auth"] base_success = 0.5 detection_difficulty = 0.5 countered_by = ["Patching", "IDS"] points = 15 severity = "high" description = "Climb from a user account to admin on a compromised host." ``` 防御机制的工作方式也相同,通过 `idaps/defenses.py` 中的 `@register_defense` 即可实现。 ## 技术栈 Python 3 · FastAPI · WebSockets · 原生 JS 仪表盘 · 零依赖核心引擎
标签:AV绕过, CISA项目, FastAPI, Python, WebSocket, 依赖分析, 入侵检测与防御, 安全, 无后门, 网络安全模拟, 超时处理