Simoon896/ai-detection-engineering-platform

GitHub: Simoon896/ai-detection-engineering-platform

将 Wazuh SIEM 的告警调查、威胁狩猎和主动响应等安全运营操作转化为 AI 对话的 MCP 服务器。

Stars: 0 | Forks: 0

# AI 检测工程平台 [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Python 3.11+](https://img.shields.io/badge/Python-3.11+-blue.svg)](https://www.python.org/downloads/) [![MCP 2025-11-25](https://img.shields.io/badge/MCP-2025--11--25-green.svg)](https://modelcontextprotocol.io/) [![Docker](https://img.shields.io/badge/Docker-Ready-blue.svg)](https://github.com/gensecaihq/Wazuh-MCP-Server) **一个由 AI 驱动的 Wazuh 检测工程平台。** 通过与任何 AI 助手对话,您可以调查警报、狩猎威胁、调整误报、编辑和验证检测规则,并在整个 Wazuh 部署中运行 Atomic Red Team 验证。它作为 Model Context Protocol (MCP) 服务器构建。 ## 功能简介 您的 Wazuh SIEM 每天都会生成数以千计的警报、漏洞发现和 Agent 事件。调查这些事件意味着要同时处理多个仪表板、编写 API 查询以及跨工具手动关联数据。 此 MCP 服务器将该工作流转化为对话: ``` You: "Show me critical alerts from the last hour" AI: [calls get_wazuh_alerts] Found 3 critical alerts: 1. SSH brute force from 10.0.1.45 → agent-003 (Rule 5712, Level 10) 2. Rootkit detection on agent-007 (Rule 510, Level 12) 3. FIM change /etc/shadow on agent-001 (Rule 550, Level 10) You: "Block that source IP on agent-003" AI: [calls wazuh_block_ip] Blocked 10.0.1.45 via firewall-drop on agent-003. You: "Which agents have unpatched critical CVEs?" AI: [calls get_critical_vulnerabilities] 3 agents with critical vulnerabilities... ``` 它与 **Claude Desktop**、**Open WebUI + Ollama**(完全本地、气隙隔离)、**mcphost** 或任何兼容 MCP 的客户端配合使用。 ## 兼容云端和本地 LLM 这是一个标准的 MCP 工具服务器。它不关心您使用什么 LLM —— 它只负责执行工具并返回结果。 | 模式 | LLM | 客户端 | 数据是否离开您的网络? | |------|-----|--------|--------------------------| | **云端** | Claude、GPT 等 | Claude Desktop、任何 MCP 客户端 | 是(发送至 LLM 提供商) | | **本地** | 通过 Ollama 运行的 Llama、Qwen、Mistral | Open WebUI、mcphost、IBM/mcp-cli | **否。完全支持气隙隔离。** | **对于无法将 SIEM 数据发送到云 API 的安全团队**(出于合规性、气隙网络、数据主权原因),使用 Ollama 的本地模式可将所有数据保留在本地。两种模式共存 —— 相同的服务器、相同的工具、相同的 API。 ### 快速开始:使用 mcphost 的本地 LLM ``` # 1. 启动 MCP server docker compose up -d # 2. 安装 mcphost(Go binary,无依赖) go install github.com/mark3labs/mcphost@latest # 3. 配置 cat > ~/.mcphost.yml << 'EOF' mcpServers: wazuh: type: remote url: http://localhost:3000/mcp headers: ["Authorization: Bearer ${env://MCP_API_KEY}"] EOF # 4. 使用本地模型与你的 SIEM 聊天 export MCP_API_KEY="your-key-from-server-logs" mcphost --model ollama/qwen2.5:7b ``` ### 快速开始:使用 Open WebUI 的多用户 SOC Open WebUI v0.6.31+ 原生连接到我们的 `/mcp` 端点。在管理设置中将其添加为 MCP 工具服务器,您的整个团队即可获得带有对话历史记录、RBAC 和 Web UI 的 AI 驱动 SIEM 分析功能。 ## 48 个安全工具 每个工具都经过验证、速率限制、范围检查和审计日志记录。 | 类别 | 工具 | 功能描述 | |----------|-------|-------------| | **警报** (4) | `get_wazuh_alerts` `get_wazuh_alert_summary` `analyze_alert_patterns` `search_security_events` | 通过 Elasticsearch 查询、过滤、搜索和分析警报数据 | | **Agent** (6) | `get_wazuh_agents` `get_wazuh_running_agents` `check_agent_health` `get_agent_processes` `get_agent_ports` `get_agent_configuration` | 监控 Agent 状态、运行中的进程、开放的端口和配置 | | **漏洞** (3) | `get_wazuh_vulnerabilities` `get_critical_vulnerabilities` `vulnerability_summary` | 按严重程度、Agent 和软件包查询 CVE | | **安全分析** (6) | `analyze_security_threat` `check_ioc_reputation` `perform_risk_assessment` `get_top_security_threats` `generate_security_report` `run_compliance_check` | 威胁分析、IOC 查询、风险评分、合规性检查 | | **系统** (10) | `get_wazuh_statistics` `get_wazuh_cluster_health` `get_wazuh_rules_summary` `search_wazuh_manager_logs` ... | 集群健康状态、规则、Manager 日志、统计信息 | | **主动响应** (9) | `wazuh_block_ip` `wazuh_isolate_host` `wazuh_kill_process` `wazuh_disable_user` `wazuh_quarantine_file` ... | 封禁 IP、隔离主机、终止进程、隔离文件 | | **验证** (5) | `wazuh_check_blocked_ip` `wazuh_check_agent_isolation` `wazuh_check_process` `wazuh_check_user_status` ... | 验证主动响应操作是否已生效 | | **回滚** (5) | `wazuh_unisolate_host` `wazuh_enable_user` `wazuh_restore_file` `wazuh_firewall_allow` `wazuh_host_allow` | 撤销主动响应操作 | ## 快速开始 ### 前置条件 - Docker 20.10+ 及 Compose v2 - Wazuh 4.8.0–4.14.4,且已启用 API 访问 ### 部署 ``` git clone https://github.com/gensecaihq/Wazuh-MCP-Server.git cd Wazuh-MCP-Server cp .env.example .env ``` 编辑 `.env`: ``` WAZUH_HOST=your-wazuh-server WAZUH_USER=your-api-user WAZUH_PASS=your-api-password ``` ``` docker compose up -d curl http://localhost:3000/health ``` ### 连接 Claude Desktop 1. **Settings** → **Connectors** → **Add custom connector** 2. URL: `https://your-server/mcp` 3. 在 Advanced settings 中添加 Bearer token ## 安全性 此服务器位于 LLM 和您的 SIEM 之间。安全性不是可选项。 | 层级 | 功能描述 | |-------|-------------| | **RBAC** | 每个工具的作用域强制执行。14 个主动响应工具需要 `wazuh:write` 权限。只读 token 可以查询但绝不能触发操作。无认证模式下默认为只读。 | | **审计日志** | 每次破坏性工具调用(封禁 IP、隔离主机、终止进程)都会记录客户端 ID、会话、时间戳和完整参数。 | | **输出净化** | 警报 `full_log` 字段中的凭证、token 和 API 密钥在到达 LLM 之前会被脱敏。防止通过 AI 响应泄露凭证。 | | **输入验证** | 验证每个参数:用于 Agent ID 的正则表达式、用于 IP 的 `ipaddress` 模块、用于主动响应的 shell 元字符阻断、Elasticsearch Query DSL(无字符串插值)。 | | **速率限制** | 每个客户端的滑动窗口机制,具有逐步升级的封锁时长(10秒 → 5分钟)。 | | **断路器** | Wazuh API 故障会触发 60 秒的快速失败,并自动恢复。在 HALF_OPEN 状态下进行单次尝试。 | | **日志净化** | 全局过滤器会从所有服务器日志中脱敏密码、token 和机密信息。 | | **容器加固** | 非 root 用户、只读文件系统、`CAP_DROP ALL`、`no-new-privileges`。 | ``` # 生成安全的 API key python -c "import secrets; print('wazuh_' + secrets.token_urlsafe(32))" ``` ## 配置 ### 必需配置 | 变量 | 描述 | |----------|-------------| | `WAZUH_HOST` | Wazuh Manager 主机名或 IP | | `WAZUH_USER` | API 用户名 | | `WAZUH_PASS` | API 密码 | ### 可选配置 | 变量 | 默认值 | 描述 | |----------|---------|-------------| | `WAZUH_PORT` | `55000` | Manager API 端口 | | `MCP_HOST` | `0.0.0.0` | 服务器绑定地址 | | `MCP_PORT` | `3000` | 服务器端口 | | `AUTH_MODE` | `bearer` | `oauth`、`bearer` 或 `none` | | `AUTH_SECRET_KEY` | 自动生成 | JWT 签名密钥 | | `AUTHLESS_ALLOW_WRITE` | `false` | 在无认证模式下允许主动响应 | | `ALLOWED_ORIGINS` | `https://claude.ai` | CORS 来源(逗号分隔) | | `REDIS_URL` | — | 用于多实例会话存储的 Redis URL | ### Wazuh Indexer(用于警报搜索 + 漏洞) | 变量 | 默认值 | 描述 | |----------|---------|-------------| | `WAZUH_INDEXER_HOST` | — | Indexer 主机名 | | `WAZUH_INDEXER_PORT` | `9200` | Indexer 端口 | | `WAZUH_INDEXER_USER` | — | Indexer 用户名 | | `WAZUH_INDEXER_PASS` | — | Indexer 密码 | ## API 端点 | 端点 | 方法 | 描述 | |----------|--------|-------------| | `/mcp` | POST/GET/DELETE | MCP Streamable HTTP(推荐) | | `/sse` | GET | 旧版 Server-Sent Events | | `/health` | GET | 健康检查(无需认证) | | `/metrics` | GET | Prometheus 指标 | | `/auth/token` | POST | 交换 API 密钥以获取 JWT | | `/docs` | GET | OpenAPI 文档 | ## 架构 ``` src/wazuh_mcp_server/ ├── server.py # MCP protocol + 48 tool handlers ├── config.py # Environment-based configuration ├── auth.py # JWT + API key authentication ├── oauth.py # OAuth 2.0 with Dynamic Client Registration ├── security.py # Rate limiting, CORS, input validation ├── monitoring.py # Prometheus metrics, structured logging ├── resilience.py # Circuit breakers, retries, graceful shutdown ├── session_store.py # Pluggable sessions (in-memory + Redis) └── api/ ├── wazuh_client.py # Wazuh Manager REST API client └── wazuh_indexer.py # Wazuh Indexer (Elasticsearch) client ``` ## 进一步探索:自主智能 SOC 将此 MCP 服务器与 [**Wazuh OpenClaw Autopilot**](https://github.com/gensecaihq/Wazuh-Openclaw-Autopilot) 结合使用,构建一个完全自主的安全运营中心。 虽然此服务器为您提供了与 Wazuh 的对话式访问,但 OpenClaw 部署了可以**全天候工作**的 AI Agent —— 对警报进行分类、关联事件,并在无需人工干预的情况下推荐响应。 ``` Manual SOC: Alert → Analyst reviews → Hours → Response Agentic SOC: Alert → AI triages → Seconds → Response ready for approval ``` [**探索 OpenClaw Autopilot**](https://github.com/gensecaihq/Wazuh-Openclaw-Autopilot) ## 文档 | 指南 | 描述 | |-------|-------------| | [Claude 集成](docs/CLAUDE_INTEGRATION.md) | Claude Desktop 设置与认证 | | [配置](docs/configuration.md) | 完整配置参考 | | [高级功能](docs/ADVANCED_FEATURES.md) | HA、Serverless、紧凑模式 | | [API 文档](docs/api/) | 各工具文档 | | [安全](docs/security/) | 安全加固指南 | | [故障排除](docs/TROUBLESHOOTING.md) | 常见问题与解决方案 | | [运维](docs/OPERATIONS.md) | 部署、监控、维护 | ## 许可证 [MIT](LICENSE) ### 贡献者 | 头像 | 用户名 | 贡献 | |--------|----------|---------------| | | [@alokemajumder](https://github.com/alokemajumder) | 代码、Issues、讨论 | | | [@gensecai-dev](https://github.com/gensecai-dev) | 代码、讨论 | | | [@aiunmukto](https://github.com/aiunmukto) | 代码、PR | | | [@Karibusan](https://github.com/Karibusan) | 代码、Issues、PR | | | [@lwsinclair](https://github.com/lwsinclair) | 代码、PR | | | [@taylorwalton](https://github.com/taylorwalton) | PR | | | [@MilkyWay88](https://github.com/MilkyWay88) | PR | | | [@kanylbullen](https://github.com/kanylbullen) | 代码、PR | | | [@Uberkarhu](https://github.com/Uberkarhu) | Issues | | | [@cbassonbgroup](https://github.com/cbassonbgroup) | Issues | | | [@cybersentinel-06](_URL_24/>) | Issues | | | [@daod-arshad](https://github.com/daod-arshad) | Issues | | | [@mamema](https://github.com/mamema) | Issues | | | [@marcolinux46](https://github.com/marcolinux46) | Issues | | | [@matveevandrey](https://github.com/matveevandrey) | Issues | | | [@punkpeye](https://github.com/punkpeye) | Issues | | | [@tonyliu9189](https://github.com/tonyliu9189) | Issues | | | [@Vasanth120v](https://github.com/Vasanth120v) | 讨论 | | | [@gnix45](https://github.com/gnix45) | 讨论 | | | [@melmasry1987](https://github.com/melmasry1987) | 讨论 |
标签:AI工程, DLL 劫持, MCP, Wazuh, 大语言模型, 安全运营, 扫描框架, 搜索引擎查询, 自定义请求头, 请求拦截, 逆向工具