Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
sentinel-mcp — 使用MCP、Gemini 2.0 Flash、Dynatrace可观测性和MongoDB的自主AI驱动网络防御系统。谷歌云黑客马拉松参赛作品。 | Kitploit
工具/GitLabGitLab/reyjesusq/sentinel-mcp
防御工具云安全入侵检测事件响应AI 安全异常检测
GitLabreyjesusq/sentinel-mcp

sentinel-mcp

使用MCP、Gemini 2.0 Flash、Dynatrace可观测性和MongoDB的自主AI驱动网络防御系统。谷歌云黑客马拉松参赛作品。

查看仓库
2个月前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

SentinelMCP — AI驱动的网络防御系统

Google Cloud Hackathon 提交项目 — 由 Google Cloud Agent Builder (Vertex AI Agent) 编排的自主威胁检测与响应,基于 Gemini 2.0 Flash、模型上下文协议(MCP)和 Dynatrace 可观测性。

Agent Builder Gemini 2.0 Flash Dynatrace MongoDB MCP Protocol


问题所在

安全团队在处理典型安全事件时,平均检测时间(MTTD)为 30分钟,平均修复时间(MTTR)为 4小时。等到人工分析师检测到攻击、编写防火墙规则并部署完毕,损失早已造成。

解决方案

SentinelMCP 将 MTTD 缩短至 < 30秒,MTTR 缩短至 < 30秒。它部署了一个 Google Cloud Agent Builder 代理,接收 Dynatrace 异常 Webhook,通过 Gemini 2.0 Flash 进行推理,然后通过 MCP 调用真实的防御工具——直接在实时基础设施上执行操作,而不仅仅是发出告警。

root@kitploit:~
Dynatrace webhook  →  Agent Builder 接收告警  →  Gemini 推理  →  MCP 工具执行  →  威胁消除
       1 秒                        2 秒                      8 秒                  15 秒                  总计 25 秒

最终结果:过去需要人工分析师耗时 4 小时的事件生命周期,现在可在 30 秒内自主完成,并在 MongoDB 中保留完整的审计轨迹,通过 Jaeger 实现分布式链路追踪。


架构

root@kitploit:~
┌──────────────────────────────────────────────────────────────────────┐
│                         沙箱环境                                      │
│                                                                      │
│   ┌─────────────┐   100–1000 req/s   ┌──────────────────────────┐   │
│   │  攻击方       │ ──────────────────►│   受害者服务              │   │
│   │ (DDoS/SQLi)│                    │   端口 8080               │   │
│   └─────────────┘                    │   /admin/* 控制 API      │   │
│                                      └────────────┬─────────────┘   │
└───────────────────────────────────────────────────│──────────────────┘
                                                    │ 指标 + 异常 webhook
                   ┌────────────────────────────────▼─────────────────┐
                   │         Dynatrace Mock (异常引擎)                 │
                   │  威胁风险评分 → 触发 POST /alerts/simulate        │
                   └────────────────────────┬─────────────────────────┘
                                            │ webhook
          ┌─────────────────────────────────▼──────────────────────────┐
          │          Google Cloud Agent Builder (Vertex AI Agent)      │
          │  ┌──────────────────────────────────────────────────────┐  │
          │  │  Gemini 2.0 Flash  ──  对威胁上下文进行推理          │  │
          │  │  工具清单  ──  从 MCP 动态获取                        │  │
          │  │  HITL 门控  ──  置信度低于阈值时暂停                  │  │
          │  └──────────────────────────────────────────────────────┘  │
          └──────────────┬─────────────────────────┬───────────────────┘
                         │ REST 调用                │ 审计写入
         ┌───────────────▼──────┐      ┌────────────▼──────────┐
         │  MCP 服务器 :8001    │      │  MongoDB 7.0 Atlas    │
         │  11 个真实工具       │      │  事件 + 轨迹          │
         └───────────┬──────────┘      └───────────────────────┘
                     │ 作用于实时基础设施
         ┌───────────▼──────────┐
         │  FastAPI :8000       │
         │  victims-service :8080 │
         └──────────────────────┘

                   ┌──────────────────────────────────────────────────┐
                   │              可观测性栈                          │
                   │  OTel Collector ──► Jaeger (分布式链路追踪)      │
                   │  Prometheus ──────────────► Grafana              │
                   └──────────────────────────────────────────────────┘

关键设计原则: 优雅降级 + 人在回路(HITL)。Agent Builder 代理在无法以足够置信度做出决策时,会安全暂停并将控制权交还给操作员——它永远不会在关键基础设施上盲目猜测。


现场演示 — Google Cloud Run

三个服务均已部署并运行在 Google Cloud Run 上:

针对生产环境发起实时攻击:

root@kitploit:~
.\attack.production.ps1 status   # 验证所有服务健康
.\attack.production.ps1 ddos     # DDoS — Gemini 封锁 IP + 限速
.\attack.production.ps1 sql      # SQL 注入 — Gemini 激活 WAF
.\attack.production.ps1 brute    # 暴力破解 — Gemini 封锁源 IP
.\attack.production.ps1 stop     # 重置防御

攻击容器在本地运行,通过 HTTPS 攻击 Cloud Run 上的 victim-service。在指挥中心仪表盘实时观察检测→推理→消除的完整周期。


如何使用 Google Cloud Agent Builder

Google Cloud Agent Builder (Vertex AI ReasoningEngine) 是 SentinelMCP 的核心编排器。实现代码位于 sentinel_mcp/agent/agent_builder.py。

SentinelAgent 继承自 vertexai.preview.reasoning_engines.Queryable——这是 Agent Builder 的官方编程接口——可以在本地运行,也可以通过一条命令部署到托管的 Agent Builder 服务中。

关键代码 — sentinel_mcp/agent/agent_builder.py:

root@kitploit:~
class SentinelAgent(reasoning_engines.Queryable):

    def set_up(self):
        # MCP 工具作为 Vertex AI FunctionDeclarations — Gemini 运行时选择
        mcp_tools = Tool(function_declarations=[
            FunctionDeclaration(name="block_ip_address", ...),
            FunctionDeclaration(name="activate_waf", ...),
            FunctionDeclaration(name="rate_limit_requests", ...),
            FunctionDeclaration(name="scale_service", ...),
            FunctionDeclaration(name="collect_forensic_logs", ...),
            FunctionDeclaration(name="analyze_attack_pattern", ...),
        ])
        self._model = GenerativeModel("gemini-2.0-flash-001", tools=[mcp_tools])
        self._chat = self._model.start_chat()

    def query(self, *, incident: dict) -> dict:
        # 入口 — Agent Builder 每次收到 Dynatrace webhook 时调用
        response = self._chat.send_message(threat_prompt(incident))
        tool_calls = [{"name": p.function_call.name, "args": dict(p.function_call.args)}
                      for p in response.candidates[0].content.parts if p.function_call]
        return {"engine": "agent_builder", "tool_calls": tool_calls, ...}

部署到 Google Cloud Agent Builder:

root@kitploit:~
# 本地测试(使用 google_ai_studio 后端无需 GCP)
python scripts/deploy_agent_builder.py --test-only

# 部署到托管的 Agent Builder 端点
python scripts/deploy_agent_builder.py --project my-gcp-project

将 Agent Builder 设为活动后端:

root@kitploit:~
# .env
GEMINI_BACKEND=agent_builder
GOOGLE_CLOUD_PROJECT=my-gcp-project
VERTEX_LOCATION=us-central1

如何使用 Dynatrace 和 MCP

Dynatrace

SentinelMCP 在三个层面集成 Dynatrace 可观测性:

  1. OpenTelemetry 管道 — sentinel-otel-collector 从 FastAPI 核心采集 span 和指标,并将其转发到 Dynatrace Mock 端点(OTLP/HTTP :14318)。每个事件、工具执行和 LLM 调用都通过完整关联 ID 进行端到端链路追踪。

  2. 带自动触发的异常引擎 — dynatrace-mock 运行后台循环,监控 http_requests_total,计算威胁风险评分(dynatrace_mock_sentinel_risk_score,0–10),并在评分超过关键阈值时自动向 SentinelMCP 发送 POST /api/v1/alerts/simulate/{type}——复现生产环境中 Dynatrace Davis 异常检测 webhook 的精确行为。

  3. 由 Dynatrace 指标驱动的 Grafana 仪表盘 — 风险评分仪表和趋势图直接使用 dynatrace_mock_sentinel_risk_score,可以直观地看到 Dynatrace 标记异常的确切时刻与 SentinelMCP 完成消除的时刻。

MCP(模型上下文协议)

Gemini 代理在运行时动态发现其防御能力——无需硬编码工具列表,功能变更时无需重写提示:

root@kitploit:~
GET /mcp/tools  →  返回 11 个工具描述  →  Gemini 选择并调用工具

每个工具在实时目录中标记为 REAL 或 Audit-Only。Gemini 读取此标志,了解自己能在实时基础设施上做什么,并在推理轨迹中解释每个工具选择。增加新的防御能力无需任何提示工程。

作用于实时基础设施的工具:


快速开始

前提条件: Docker Desktop 24+、Google Cloud 凭据或 AI Studio API 密钥、约 3 GB 磁盘空间、约 2 GB 内存。

1 — 启动栈

root@kitploit:~
docker compose up -d --build

首次运行会下载基础镜像(约 3 GB,5–10 分钟)。后续运行不到 1 分钟。

2 — 启动模拟沙箱

root@kitploit:~
cd simulacion
docker compose up -d victim-service
cd ..

3 — 验证所有组件启动

root@kitploit:~
docker compose ps
# 预期: 8 个服务运行中/健康

curl http://localhost:8000/health
# 预期: {"status": "healthy", "service": "SentinelMCP", ...}

4 — 发起攻击,观察 AI 防御

root@kitploit:~
.\attack.ps1 ddos        # DDoS 攻击(默认)
.\attack.ps1 sql         # SQL 注入
.\attack.ps1 brute       # 暴力破解
.\attack.ps1 stop        # 停止攻击 + 重置防御
.\attack.ps1 status      # 检查系统状态

在攻击运行时打开指挥中心:

root@kitploit:~
http://localhost:8000/dashboard

在约 25 秒内观察 4 个阶段:

  1. THREAT DETECTED — Dynatrace 触发告警
  2. DEFENDING — Gemini 读取 MCP 工具目录,选择操作,记录推理过程
  3. 工具执行 — IP 被封锁、WAF 启用、速率限制生效(均为真实操作)
  4. NEUTRALIZED — 显示 MTTD 和 MTTR,附带完整审计轨迹

5 — 配置 Google Cloud (Vertex AI)

SentinelMCP 基于 Gemini。选择适合你环境的认证方式:

选项 A — Google AI Studio(最快设置):

root@kitploit:~
# 编辑 .env
GOOGLE_API_KEY=AIza...your_key_here
GEMINI_BACKEND=google_ai_studio

选项 B — Google Cloud 上的 Vertex AI:

root@kitploit:~
gcloud auth application-default login
.\scripts\setup_gcloud.ps1   # 设置项目、创建 SA 密钥、自动更新 .env

然后重启 AI 引擎:docker compose restart api


所有接口

生产环境 (Google Cloud Run)

本地 (Docker Compose)


攻击场景


MCP 工具注册表(11 个工具)

root@kitploit:~
GET http://localhost:8001/mcp/tools

SentinelMCP 采用故障安全审计模式。如果目标基础设施不可达,代理会记录预期操作而不中断管道,确保优雅降级。Gemini 读取目录中的 REAL / Audit-Only 标志——它能精确知道哪些操作可以执行,哪些只能建议。


项目结构

root@kitploit:~
sentinel_mcp/
├── api/              FastAPI 核心 — 路由、模式、仪表盘 UI
├── agent/            决策引擎 + LLM 提供商 (Gemini 2.0 Flash, Vertex AI)
├── mcp_server/       MCP 服务器 + 11 个工具实现
├── services/         事件服务、修复编排器、威胁计算器
├── observability/    OTel / Dynatrace / SigNoz 提供商
└── core/             配置、日志、异常

simulacion/
├── victim-service/   带 /admin/* 控制面的 FastAPI 目标服务
└── attacker/         Python 攻击引擎 (DDoS / SQLi / 暴力破解)

docker/
├── prometheus.yml    抓取配置 (victim-service 每 5 秒)
└── grafana/          自动预配仪表盘 — 6 面板基础设施见证

技术栈

下载工具
服务URL
指挥中心(仪表盘)https://sentinel-api-62d3d66zda-uc.a.run.app/dashboard
Swagger API 文档https://sentinel-api-62d3d66zda-uc.a.run.app/docs
健康检查https://sentinel-api-62d3d66zda-uc.a.run.app/health
MCP 工具目录https://sentinel-mcp-62d3d66zda-uc.a.run.app/mcp/tools
受害者服务https://victim-service-62d3d66zda-uc.a.run.app
职责实现方式
Webhook 接收SentinelAgent.query(incident=...) — Agent Builder 在每次 Dynatrace 告警时调用
工具声明set_up() 中将 6 个 MCP 工具注册为 Vertex AI FunctionDeclaration 对象
推理Gemini 2.0 Flash 读取威胁上下文 + 工具目录,选择最小工具集,自动调用
HITL 门控如果 Gemini 未返回任何工具调用(置信度低于阈值),则触发 escalate_to_humans=True
审计每次工具调用记录到 MongoDB Atlas,并作为 OTel span 导出到 Jaeger
工具功能
block_ip_addressPOST /admin/block_ip — 在运行中的中间件里封锁攻击者 IP
activate_wafPOST /admin/waf — 在运行中的服务里启用 WAF 阻断模式
rate_limit_requestsPOST /admin/rate_limit — 滑动窗口速率限制,立即生效
scale_service通过 Docker SDK 操作 socket — 在负载下启动真实的副本容器
rollbackPOST /admin/reset_defenses — 展示完整的事件生命周期:攻击→防御→恢复
collect_forensic_logs从运行中的容器捕获真实证据,用于事后审查
build_attack_timeline从实时容器日志构建时间线
analyze_attack_pattern使用真实事件上下文数据对攻击类型分类
identify_iocs从实时事件文件中提取真实 IP、用户代理和载荷
URL说明
https://sentinel-api-62d3d66zda-uc.a.run.app/dashboard指挥中心 — 主演示 UI
https://sentinel-api-62d3d66zda-uc.a.run.app/docsSwagger — 交互式 API 探索器
https://sentinel-api-62d3d66zda-uc.a.run.app/health健康检查
https://sentinel-api-62d3d66zda-uc.a.run.app/api/v1/incidents事件历史 (JSON)
https://sentinel-mcp-62d3d66zda-uc.a.run.app/mcp/toolsGemini 读取的实时 MCP 工具目录
https://victim-service-62d3d66zda-uc.a.run.app受害者服务(被攻击的目标)
URL说明
http://localhost:8000/dashboard指挥中心 — 主演示 UI
http://localhost:8000/docsSwagger — 交互式 API 探索器
http://localhost:8000/api/v1/incidents事件历史 (JSON)
http://localhost:8000/api/v1/incidents/statistics/summary所有事件的 MTTD / MTTR 平均值
http://localhost:8001/mcp/toolsGemini 读取的实时 MCP 工具目录
http://localhost:8080受害者服务(被攻击的目标)
http://localhost:14499Dynatrace Mock — 实时指标 + 异常引擎
http://localhost:16686Jaeger — 分布式链路追踪
http://localhost:9090Prometheus — 原始指标
http://localhost:3000Grafana — 基础设施仪表盘(admin / admin)
场景脚本发生过程
DDoS.\attack.ps1 ddos1000 req/s 洪泛;Gemini 封锁 IP + 启用速率限制
SQL 注入.\attack.ps1 sql载荷检测;Gemini 以阻断模式激活 WAF
暴力破解.\attack.ps1 brute登录尝试轰炸;Gemini 封锁源 IP + 启用 WAF
自动模式仪表盘 🎯 Auto ON每 45–90 秒随机攻击,完全自主响应
工具类别模式
analyze_attack_pattern分析REAL
identify_iocs分析REAL
block_ip_address防御REAL → victim-service
activate_waf防御REAL → victim-service
rate_limit_requests防御REAL → victim-service
scale_service防御REAL → Docker SDK
collect_forensic_logs取证REAL
build_attack_timeline取证REAL
patch_vulnerabilities修复Audit-Only
apply_hardening修复Audit-Only
rollback修复REAL → victim-service
层技术
代理编排器Google Cloud Agent Builder (Vertex AI Agent)
大语言模型Gemini 2.0 Flash — 通过 google-genai SDK
工具协议MCP (Model Context Protocol) — 11 个真实工具
APIFastAPI + Uvicorn (Python 3.11)
数据库MongoDB 7.0 Atlas (Motor 异步)
可观测性OpenTelemetry → Dynatrace
链路追踪Jaeger
指标Prometheus + Grafana
HTTP 客户端httpx (异步)
容器编排Docker Compose v2