homeofe/ai-security-arena

GitHub: homeofe/ai-security-arena

基于Web的AI攻防对抗平台,支持多模型红蓝对抗、实时战斗日志、场景构建和赛后分析。

Stars: 0 | Forks: 0

# AI Security Arena ## 截图 ### 仪表板 ![Dashboard](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/fadf867152195435.jpg) ### 竞技场设置 (红队 vs 蓝队) ![Arena Setup](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/8fcf99f16e195445.jpg) ### 战斗报告 (赛后分析) ![Battle Report](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/a53422e1b0195454.jpg) ### 比赛历史 ![Match History](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/94c195d999195504.jpg) ### 排行榜 ![Leaderboard](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/0d538e4aab195513.jpg) ### 场景构建器 ![Scenario Builder](https://raw.githubusercontent.com/homeofe/ai-security-arena/main/docs/screenshots/scenario-builder.jpg) ## 概念 ``` ┌──────────────────────────────────────────────────────────────┐ │ AI SECURITY ARENA │ │ │ │ ┌──────────────┐ ┌──────────────┐ │ │ │ RED TEAM │ ← sandbox → │ BLUE TEAM │ │ │ │ (Attacker) │ │ (Defender) │ │ │ │ │ live battle │ │ │ │ │ Model: ... │ ←──────────────→ │ Model: ... │ │ │ └──────────────┘ └──────────────┘ │ │ │ │ ┌──────────────────────────────────────────────────────┐ │ │ │ WEB INTERFACE │ │ │ │ - Model selection per team │ │ │ │ - Custom prompts + example library │ │ │ │ - Live battle log (WebSocket) │ │ │ │ - Scoreboard + leaderboard │ │ │ │ - Scenario builder │ │ │ │ - Round-by-round replay │ │ │ │ - AAHP evolution tracker │ │ │ │ - Match export (JSON/PDF) │ │ │ └──────────────────────────────────────────────────────┘ │ └──────────────────────────────────────────────────────────────┘ ``` ## 功能 ### 核心 - **模型选择:** 为每支队伍选择任何 LLM(Claude, GPT, Gemini, Grok, 本地模型) - **自定义 Prompt:** 编写您自己的攻击/防御策略,或使用精选的示例 - **实时战斗日志:** 实时 WebSocket 流,红队(左)对抗 蓝队(右),每个动作均带有时间戳 - **场景构建器:** 选取环境(web-server, database, cloud-infra, IoT)或创建自定义环境 ### 评分与历史 - **记分板:** 每场比赛评分(攻击命中、攻击拦截、检测时间等) - **排行榜:** 哪个模型组合表现最好?所有比赛的历史排名 - **逐轮回放:** 以取证方式逐步查看已完成的比赛 ### 智能 - **AAHP 演化追踪器:** 两支队伍都通过 GitHub Issues 进行自我改进。追踪其演化过程。 - **比赛导出:** 将报告下载为 JSON 或 PDF 以便归档 ### 安全 - **沙箱隔离:** 所有战斗均在隔离的沙箱中运行。提供清晰的视觉指示。 - **预算限制器:** 设定每场比赛的 API 成本上限(双方同时进行 LLM 调用) - **Prompt 清理:** 对自定义 prompt 进行验证以防止沙箱逃逸 ## 技术栈 | 组件 | 技术 | |-----------|-----------| | 前端 | Next.js 15 (App Router, React Server Components) | | 样式 | Tailwind CSS | | 实时通信 | WebSocket (ws) + Server-Sent Events 回退 | | 后端 | Next.js API Routes + ai-red-team/ai-blue-team 作为库 | | 数据库 | SQLite (通过 better-sqlite3) 用于存储比赛历史 | | 测试 | Vitest | ## 快速开始 ### 前置条件 - Node.js 22+ - pnpm ### 安装 ``` git clone https://github.com/homeofe/ai-security-arena.git cd ai-security-arena pnpm install pnpm dev ``` 打开 http://localhost:3000 ### 环境变量 ``` # 至少需要一个 LLM provider key ANTHROPIC_API_KEY=sk-... OPENAI_API_KEY=sk-... GOOGLE_AI_API_KEY=... # 可选:每场比赛的预算限制 (USD) MATCH_BUDGET_LIMIT=1.00 ``` ## 项目结构 ``` ai-security-arena/ ├── src/ │ ├── app/ # Next.js App Router pages │ │ ├── page.tsx # Landing / dashboard │ │ ├── arena/ │ │ │ └── page.tsx # Battle setup + live view │ │ ├── history/ │ │ │ └── page.tsx # Match history + replays │ │ ├── leaderboard/ │ │ │ └── page.tsx # Model rankings │ │ └── api/ │ │ ├── battle/ # Start/stop battles │ │ ├── ws/ # WebSocket endpoint │ │ └── matches/ # Match CRUD │ ├── components/ │ │ ├── BattleLog.tsx # Split-screen live log │ │ ├── BattleHeader.tsx # Round counter, timer, cost │ │ ├── ModelPicker.tsx # Model selection per team │ │ ├── PromptEditor.tsx # Tabbed prompt editor (examples + custom) │ │ ├── ScenarioSelector.tsx # Horizontal scroll scenario cards │ │ ├── ScoreBar.tsx # Animated score comparison bar │ │ ├── PhaseIcon.tsx # Color-coded phase badges │ │ ├── ReportHeader.tsx # Classified intel briefing header │ │ ├── ScoreOverview.tsx # Large score display + stats │ │ ├── ScoreChart.tsx # Pure CSS/SVG bar + line charts │ │ ├── DecisionTimeline.tsx # Vertical alternating timeline │ │ ├── ReasoningViewer.tsx # Expandable LLM reasoning per round │ │ ├── StrategyBreakdown.tsx # Side-by-side strategy analysis │ │ ├── TurningPoints.tsx # Momentum shift highlights │ │ └── ExportButtons.tsx # JSON/PDF/share export │ ├── lib/ │ │ ├── arena.ts # Arena controller (mock/cli/api modes) │ │ ├── cli-provider.ts # CLI-based LLM provider (claude/gemini/codex) │ │ ├── prompt-builder.ts # Battle prompt construction per round │ │ ├── response-parser.ts # Parse LLM responses into BattleEvents │ │ ├── report-generator.ts # Post-match analysis and report generation │ │ ├── mock-battle.ts # Realistic mock battle events │ │ ├── models.ts # Available model registry │ │ ├── prompts.ts # Example prompt library │ │ ├── scenarios.ts # Built-in scenarios │ │ └── scoring.ts # Scoring engine │ └── types/ │ └── index.ts # Shared type definitions ├── .ai/handoff/ # AAHP protocol files ├── docs/screenshots/ # UI screenshots ├── package.json ├── next.config.ts ├── postcss.config.mjs ├── tsconfig.json └── vitest.config.ts ``` ## 路线图 | # | 功能 | 状态 | |---|---------|--------| | 1 | 项目搭建 (Next.js + Tailwind + 依赖项) | ✅ 已完成 | | 2 | 模型选择器 + 场景选择器 UI | ✅ 已完成 | | 3 | 竞技场控制器 (模拟 + CLI + API 模式) | ✅ 已完成 | | 4 | 分屏战斗视图 (红队 vs 蓝队) | ✅ 已完成 | | 5 | 评分引擎 | ✅ 已完成 | | 6 | 自定义 Prompt 编辑器 + 示例库 | ✅ 已完成 | | 7 | CLI 提供商集成 (claude/gemini/codex) | ✅ 已完成 | | 8 | 战斗报告页面 (时间线、推理、策略、导出) | ✅ 已完成 | | 9 | 导出 (JSON/PDF) | ✅ 已完成 | | 10 | SSE 实时战斗事件 | ✅ 已完成 | | 11 | ai-red-team SDK 集成 | ✅ 已完成 | | 12 | ai-blue-team SDK 集成 | ✅ 已完成 | | 13 | 比赛历史 + SQLite 持久化 | ✅ 已完成 | | 14 | 逐轮回放查看器 | ✅ 已完成 | | 15 | 包含模型排名的排行榜 | ✅ 已完成 | | 16 | 场景构建器 | ✅ 已完成 | | 17 | 部署 (Docker + Vercel) | ✅ 已完成 | ## 许可证 Apache-2.0. 版权所有 2026 Elvatis - Emre Kohler. ## 相关项目 - [ai-red-team](https://github.com/homeofe/ai-red-team) - 攻击性安全智能体 - [ai-blue-team](https://github.com/homeofe/ai-blue-team) - 防御性安全智能体 - [AAHP](https://github.com/homeofe/AAHP) - Agent Handoff Protocol (自我演化)
标签:AI安全, Blue Teaming, Chat Copilot, CISA项目, CSV导出, DLL 劫持, Go语言工具, Linux系统监控, MITM代理, Python, Red Teaming, WebSocket, Web报告查看器, Web界面, 依赖分析, 反取证, 场景构建, 大语言模型, 安全大模型, 安全测试, 安全竞技, 安全评估, 实时对战, 密码管理, 恶意样本开发, 搜索语句(dork), 攻击性安全, 攻防模拟, 无后门, 模型安全, 漏洞分析, 网络安全, 网络安全演练, 网络靶场, 自动化攻击, 自动化渗透测试, 路径探测, 配置错误, 防御系统, 隐私保护