ali-hue-byte/Cyber-Escape-Room

GitHub: ali-hue-byte/Cyber-Escape-Room

基于AI的网络安全事件响应调查模拟游戏,为SOC分析师提供真实的应急响应训练场景。

Stars: 0 | Forks: 0

# 网络逃生室
### 🏆 为 Microsoft AI Skills Fest 2026 而构建 这是一个交互式游戏体验,结合了 React、TypeScript 和 Gemini AI,并采用了安全的后端架构。 [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![React](https://img.shields.io/badge/React-19-blue?logo=react)](https://react.dev) [![TypeScript](https://img.shields.io/badge/TypeScript-5-blue?logo=typescript)](https://www.typescriptlang.org) [![Node.js](https://img.shields.io/badge/Node.js-Express-green?logo=node.js)](https://nodejs.org) [![Gemini API](https://img.shields.io/badge/Gemini-API-purple)](https://ai.google.dev)
## 安全架构 ``` FRONTEND BACKEND GEMINI API (No API Keys) (API Key Protected) (Secure Connection) React App ─────────────► Express Server ────────────► Google Same-Origin 🔒 API Key: SAFE 🔒 Environment Vars 🔒 Rate Limited ``` ### 安全特性 - **API Key 隔离** - 仅存储在后端,绝不向客户端暴露 - **环境变量** - 所有密钥都在 `.env` 文件中受到保护(已被 gitignored) - **会话管理** - 答案在服务器端跟踪,不发送给客户端 - **速率限制** - 所有 `/api` 路由都有基于 IP 的请求上限 - **错误处理** - 错误消息中不包含任何敏感信息 ## 功能 - **AI 生成的事件** - Gemini 生成独特、逼真的网络安全场景 - **交互式调查** - 使用自然语言查询事件数据库 - **证据分析** - 检查电子邮件、日志、网络活动和员工访谈 - **渐进式提示** - 最多可获得 3 个逐渐具体的线索(会扣除分数) - **难度级别** - 分为初级、中级和专家模式 - **评分系统** - 对调查表现进行排名,并授予调查员头衔 - **赛博朋克 UI** - 带有终端绿色点缀和发光效果的暗黑主题 ## 架构 ``` ┌─────────────────────────────────────────────────────────────────┐ │ 🎮 Cyber Escape Room UI │ ├─────────────────────────────────────────────────────────────────┤ │ React + TypeScript + Tailwind (NO API KEYS) │ └──────────────────────┬──────────────────────────────────────────┘ │ Same-origin requests ▼ ┌──────────────────────────────┐ │ 🛡️ Secure Backend Server │ ├──────────────────────────────┤ │ Express.js + Vite │ │ ✓ API Key Protected │ │ ✓ Input Validated │ │ ✓ Rate Limited │ └──────────────┬───────────────┘ │ HTTPS (API_KEY protected) ▼ ┌──────────────────────────────┐ │ 🤖 Gemini AI API │ │ (gemini-3.5-flash) │ └──────────────────────────────┘ ``` ## 🚀 在线演示 立即体验 —— 无需设置,无需 API Key: **[Cyber-Escape-Room](https://cyber-escape-room-ai.onrender.com)** ## 快速开始 ### 前置条件 - Node.js 18+ - npm - Gemini API key ### 安装说明 1. **克隆仓库** git clone https://github.com/ali-hue-byte/Cyber-Escape-Room.git cd Cyber-Escape-Room 2. **安装依赖** npm install 3. **创建环境变量文件** cp .env.example .env 编辑 `.env` 并添加你的 Gemini API key: GEMINI_API_KEY=your_Gemini_api_key 还没有 key 吗?在 [aistudio.google.com](https://aistudio.google.com) 免费获取一个。 4. **启动开发服务器** npm run dev 5. **在浏览器中打开** http://localhost:3000 ## 项目结构 ``` cyber-escape-room/ ├── server.ts # Express + Vite server (single process) ├── .env.example # Environment variable template ├── src/ │ ├── components/ # React components │ ├── App.tsx # Main game UI and state │ └── types.ts # TypeScript interfaces ├── package.json # Frontend + backend deps └── README.md # This file ``` ## 如何游玩 ### 1️⃣ **选择难度** 在初级、中级或专家难度级别之间进行选择。 ### 2️⃣ **生成事件** Gemini AI 会创建一个独特的网络安全事件。解决方案**安全地存储在后端**(绝不发送给客户端)。 ### 3️⃣ **调查** 就以下内容向后端数据库提问: - 员工的活动和陈述 - 安全日志和事件 - 电子邮件通信 - 网络连接 ### 4️⃣ **分析证据** 在证据面板中审查证据: - **电子邮件**:通信内容和邮件头 - **日志**:安全事件和严重程度 - **网络**:流量和协议 - **访谈**:员工陈述 - **警报**:安全警告 ### 5️⃣ **使用提示**(可选) 请求最多 3 个渐进式提示(每个提示会扣减分数)。 ### 6️⃣ **提交指控** 提供你的调查结果: - 攻击类型 - 入口点 - 漏洞 - 缓解策略 ### 7️⃣ **查看结果** 查看由安全后端评估的 AI 评分和正确答案。 ## 评分系统 | 组成部分 | 分数 | 公式 | |-----------|--------|---------| | 准确率 | 0-100 | 4 个字段(攻击类型、入口点、漏洞、缓解策略),每项 0-25 分,由 AI 评分 | | 时间奖励 | 0-50 | `floor(min(100, max(0, 100 - timeSpentSeconds / 20)) × 0.5)` | | 提示扣分 | -10/提示 | `hintsUsed × 10` | | **总分** | 0-150 | `clamp(0, 150, Accuracy + Time Bonus - Hint Penalty)` | ### 调查员等级 | 等级 | 总分 | |------|--------| | 初级 SOC Level I 分析师 | 0-59 | | 合格认证安全助理 | 60-79 | | 事件响应主管 (level II) | 80-94 | | 精英网络威胁猎人 (level III) | 95-150 | ## 🛡️ 后端 API 参考 所有 endpoint 都与前端运行在同一个 Express 服务器上(默认端口为 3000)。 ### POST `/api/incident/generate` 生成一个新的事件。解决方案存储在服务器端,**不**返回给客户端。 ``` curl -X POST http://localhost:3000/api/incident/generate \ -H "Content-Type: application/json" \ -d '{"difficulty": "Intermediate"}' ``` 返回 `{ caseData: { id, companyName, category, scenarioDescription, timeline, employees, logs, emails, networkActivity, alerts, hintsLeftCount } }` ### POST `/api/incident/chat` 与事件数据库 / 主调查员进行聊天。 ``` curl -X POST http://localhost:3000/api/incident/chat \ -H "Content-Type: application/json" \ -d '{ "incidentId": "case_xxxxxxxx", "message": "Tell me about the employees" }' ``` ### POST `/api/incident/hint` 获取渐进式提示(1、2 或 3)。 ``` curl -X POST http://localhost:3000/api/incident/hint \ -H "Content-Type: application/json" \ -d '{ "incidentId": "case_xxxxxxxx", "hintLevel": 1 }' ``` ### POST `/api/incident/accuse` 提交并进行 AI 评分的最终指控。真实答案绝不会发送给客户端。 ``` curl -X POST http://localhost:3000/api/incident/accuse \ -H "Content-Type: application/json" \ -d '{ "incidentId": "case_xxxxxxxx", "submission": { "attackType": "Phishing", "entryPoint": "Email", "vulnerability": "User clicked link", "mitigation": "Security awareness training" }, "timeSpentSeconds": 420, "hintsUsed": 1 }' ``` 返回 `{ evaluation: { accuracyScore, timeBonus, hintPenalty, totalScore, rating, feedback, correctSolution } }` ## 技术栈 | 层级 | 技术 | 用途 | |-------|-----------|---------| | **前端** | React 19 + TypeScript | 组件 UI | | **样式** | Tailwind CSS | 暗黑主题 UI | | **构建** | Vite | 快速打包,在开发环境下同时作为前端服务器 | | **后端** | Express.js | API 服务器(与 Vite 运行在单一进程中) | | **AI** | Gemini API (`gemini-3.5-flash`) | 内容生成与评分 | | **安全** | dotenv + express-rate-limit | 密钥保护与滥用防范 | | **开发** | Github Copilot | AI 结对编程助手 | ## 许可证 MIT Licence ## 支持 - **问题**:在 GitHub Issues 上报告 bug - **讨论**:加入 GitHub Discussions ## Cyber Escape Room AI – 演示视频 https://github.com/user-attachments/assets/4890e93c-54e3-4c26-90f4-34c45db52584
**以 🔐 安全为核心构建** [GitHub](https://github.com/ali-hue-byte/Cyber-Escape-Room) · [Microsoft AI Skills Fest 2026](https://microsoft.com)
标签:AI游戏, GNU通用公共许可证, MITM代理, Node.js, React, Syscalls, TypeScript, 安全插件, 安全运营(SOC), 库, 应急响应, 网络安全, 自动化攻击, 隐私保护