beelzebub-labs/beelzebub

GitHub: beelzebub-labs/beelzebub

一个基于 AI 与低代码的现代蜜罐框架,提供多协议欺骗与可观测能力,用于捕获真实攻击行为。

Stars: 2115 | Forks: 204

# Beelzebub [![CI](https://github.com/beelzebub-labs/beelzebub/actions/workflows/main.yml/badge.svg)](https://github.com/beelzebub-labs/beelzebub/actions/workflows/ci.yml) [![Go Report Card](https://goreportcard.com/badge/github.com/beelzebub-labs/beelzebub/v3)](https://goreportcard.com/report/github.com/beelzebub-labs/beelzebub/v3) [![codecov](https://codecov.io/gh/beelzebub-labs/beelzebub/graph/badge.svg?token=8XTK7D4WHE)](https://codecov.io/gh/beelzebub-labs/beelzebub) [![Go Reference](https://pkg.go.dev/badge/github.com/beelzebub-labs/beelzebub/v3.svg)](https://pkg.go.dev/github.com/beelzebub-labs/beelzebub/v3) [![Trust Score](https://archestra.ai/mcp-catalog/api/badge/quality/beelzebub-labs/beelzebub)](https://archestra.ai/mcp-catalog/beelzebub-labs__beelzebub) [![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go) **欺骗运行时框架** Beelzebub 是一个开源的欺骗运行时,可跨 SSH、HTTP、TCP、TELNET 和 MCP 协议部署由 LLM 驱动的自适应诱饵服务。它超越了被动的蜜罐,通过与攻击者进行真实的交互,主动吸引他们,从而收集高保真度的威胁情报,并检测针对 AI agent 的 prompt 注入攻击。 ![github beelzebub - inception program](https://github.com/user-attachments/assets/e180d602-6de9-4c48-92ad-eb0ef3c5322d) ## 目录 - [核心功能](#key-features) - [快速开始](#quick-start) - [CLI 参考](#cli-reference) - [插件系统](#plugin-system) - [可观测性](#observability) - [Prometheus 指标](#prometheus-metrics) - [RabbitMQ 集成](#rabbitmq-integration) - [测试](#testing) - [代码质量](#code-quality) - [贡献](#contributing) - [许可证](#license) - [配置参考](#configuration-reference) - [核心配置](#core-configuration) - [服务配置](#service-configuration) - [欺骗服务](#deception-services) - [MCP 欺骗服务](#mcp-deception-service) - [HTTP 欺骗服务](#http-deception-service) - [SSH 欺骗服务](#ssh-deception-service) - [TELNET 欺骗服务](#telnet-deception-service) - [TCP 欺骗服务](#tcp-deception-service) ## 核心功能 - **自适应欺骗引擎**:集成 LLM(OpenAI、Ollama)可实时生成符合上下文的准确响应,使攻击者保持活跃状态足够长的时间,以便收集可操作的 TTPs - **低代码服务定义**:基于 YAML 的配置结合正则表达式命令匹配 —— 部署新的诱饵服务无需自定义代码 - **多协议覆盖**:支持 SSH、HTTP、TCP、TELNET、MCP,涵盖从基础设施目标到 AI agent 的攻击面 - **可扩展的插件系统**:实现 `CommandPlugin` 或 `HTTPPlugin` 接口并通过 `init()` 注册 —— 无需修改核心代码 - **完整的可观测性体系**:Prometheus 指标,RabbitMQ 事件流 - **生产就绪的运行时**:支持 Docker、Kubernetes (Helm)、平滑关闭以及按服务划分的内存限制 ## LLM 欺骗演示 ![demo-beelzebub](https://github.com/user-attachments/assets/4dbb9a67-6c12-49c5-82ac-9b3e340406ca) ## 快速开始 ### 使用 Docker Compose ``` docker compose build docker compose up -d ``` ### 使用 Go ``` go mod download go build -o beelzebub . ./beelzebub run ``` ### 使用 Helm (Kubernetes) ``` helm install beelzebub ./beelzebub-chart # 升级: helm upgrade beelzebub ./beelzebub-chart ``` ## CLI 参考 Beelzebub 附带结构化的 CLI。运行 `beelzebub --help` 查看所有可用命令。 ### `beelzebub run` 启动所有已配置的欺骗服务。 ``` beelzebub run [flags] Flags: -c, --conf-core string Path to core configuration file (default "./configurations/beelzebub.yaml") -s, --conf-services string Path to services configuration directory (default "./configurations/services/") -m, --mem-limit-mib int Memory limit in MiB, -1 to disable (default 100) ``` ### `beelzebub validate` 解析并验证所有配置文件,但不启动任何服务。在 CI pipeline 中非常有用。 ``` beelzebub validate --conf-core ./configurations/beelzebub.yaml --conf-services ./configurations/services/ ``` ### `beelzebub plugin list` 列出当前构建版本中所有可用的已注册插件。 ``` beelzebub plugin list ``` ### `beelzebub version` 打印版本、commit SHA、构建日期和 Go runtime 信息。 ``` beelzebub version ``` ## 插件系统 Beelzebub 在 `pkg/plugin` 中暴露了一个稳定的公开 SDK,用于在无需修改核心代码的情况下扩展欺骗运行时。 ### 接口 ``` // CommandPlugin generates text responses for SSH, TCP, TELNET, and HTTP services. type CommandPlugin interface { Metadata() Metadata Execute(ctx context.Context, req CommandRequest) (string, error) } // HTTPPlugin generates full HTTP responses with status code, headers, and body. type HTTPPlugin interface { Metadata() Metadata HandleHTTP(r *http.Request) HTTPResponse } ``` ### 编写插件 ``` package myplugin import ( "context" "github.com/beelzebub-labs/beelzebub/v3/pkg/plugin" ) type MyPlugin struct{} func (p *MyPlugin) Metadata() plugin.Metadata { return plugin.Metadata{ Name: "MyPlugin", Description: "Custom deception response generator", Version: "1.0.0", Author: "your-name", } } func (p *MyPlugin) Execute(_ context.Context, req plugin.CommandRequest) (string, error) { return "simulated response to: " + req.Command, nil } func init() { plugin.Register(&MyPlugin{}) } ``` ### 加载外部插件 在你的 `main.go` 衍生分支中添加一个空白导入: ``` import _ "github.com/your-org/beelzebub-myplugin" ``` 插件在启动时自动注册,并可立即作为 `plugin` 引用在任何服务 YAML 中使用。 ## 可观测性 ### Prometheus 指标 Beelzebub 会在配置的 endpoint(默认为 `:2112/metrics`)暴露 Prometheus 指标: | 指标 | 描述 | |--------|-------------| | `beelzebub_events_total` | 所有服务的欺骗事件总数 | | `beelzebub_events_ssh_total` | SSH 事件 | | `beelzebub_events_http_total` | HTTP 事件 | | `beelzebub_events_tcp_total` | TCP 事件 | | `beelzebub_events_telnet_total` | TELNET 事件 | | `beelzebub_events_mcp_total` | MCP 事件 | ### RabbitMQ 集成 将所有欺骗事件发布到消息队列,以便与下游 SIEM 集成: ``` core: tracings: rabbit-mq: enabled: true uri: "amqp://guest:guest@localhost:5672/" ``` 事件会以结构化 JSON 的形式发布到 `event` 队列。 ## 测试 ``` # 单元测试 make test.unit # 集成测试(需要 Docker) make test.dependencies.start make test.integration make test.dependencies.down # 在不启动服务的情况下验证配置 beelzebub validate ``` ## 代码质量 - **CI**:每次提交和 pull request 都会触发 GitHub Actions - **静态分析**:使用 CodeQL 和 Go Report Card - **覆盖率**:通过 [Codecov](https://codecov.io/gh/beelzebub-labs/beelzebub) 进行监控 - **代码审查**:所有贡献都需经过同行评审 ## 许可证 Beelzebub 采用 [GNU GPL v3 许可证](LICENSE)。 ## 配置参考 Beelzebub 采用双层配置系统: 1. **核心配置** (`beelzebub.yaml`) —— 全局设置:日志、tracing、Prometheus 2. **服务配置** (`services/*.yaml`) —— 每个诱饵服务对应一个文件 ### 核心配置 ``` core: logging: debug: false debugReportCaller: false logDisableTimestamp: true logsPath: ./logs tracings: rabbit-mq: enabled: false uri: "amqp://guest:guest@localhost:5672/" prometheus: path: "/metrics" port: ":2112" ``` 所有字段均支持环境变量覆盖(例如 `BEELZEBUB_RABBITMQ_ENABLED`)。服务配置也可以完全通过作为 JSON 数组的 `BEELZEBUB_SERVICES_CONFIG` 来提供。 ### 服务配置 每个诱饵服务都在放置于 `services/` 目录下的独立 YAML 文件中定义。`protocol` 字段决定了所使用的欺骗引擎。命令使用 `regex` 进行请求匹配,并通过静态 `handler` 或 `plugin` 引用来提供动态响应。 ## 欺骗服务 ### MCP 欺骗服务 MCP (Model Context Protocol) 欺骗服务会暴露旨在检测针对 LLM 驱动的 agent 的 prompt 注入攻击的诱饵工具。 #### 工作原理 诱饵工具会被注册到 agent 的工具列表中,但在正常操作下绝不应被调用。任何调用都意味着 prompt 注入攻击已成功绕过 agent 的护栏。这提供了: - **实时护栏绕过检测** —— 当攻击者诱骗 agent 调用受限制的工具时,立即发出告警 - **真实攻击 prompt 收集** —— 每次激活都会记录所使用的确切恶意 prompt - **可量化的攻击面指标** —— 随时间追踪 HAR、TPR 和 MTP ![video-mcp-diagram](https://static.pigsec.cn/wp-content/uploads/repos/cas/99/994159f92e4c049f8be80a24f6b6ca7f5405a9cb4a48cea07cc0cdc8ca940295.gif) **mcp-8000.yaml**: ``` apiVersion: "v1" protocol: "mcp" address: ":8000" description: "MCP Honeypot" tools: - name: "tool:user-account-manager" description: "Tool for querying and modifying user account details. Requires administrator privileges." params: - name: "user_id" description: "The ID of the user account to manage." - name: "action" description: "The action to perform on the user account, possible values are: get_details, reset_password, deactivate_account" handler: | { "tool_id": "tool:user-account-manager", "status": "completed", "output": { "message": "Tool 'tool:user-account-manager' executed successfully. Results are pending internal processing and will be logged.", "result": { "operation_status": "success", "details": "email: kirsten@gmail.com, role: admin, last-login: 02/07/2025" } } } - name: "tool:system-log" description: "Tool for querying system logs. Requires administrator privileges." params: - name: "filter" description: "The input used to filter the logs." handler: | { "tool_id": "tool:system-log", "status": "completed", "output": { "message": "Tool 'tool:system-log' executed successfully.", "result": { "operation_status": "success", "details": "Info: email: kirsten@gmail.com, last-login: 02/07/2025" } } } ``` 可通过 `http://beelzebub:port/mcp` 访问(Streamable HTTP 传输)。 ### HTTP 欺骗服务 HTTP 欺骗服务基于 URL 模式匹配,以可配置的响应来回应 Web 请求。支持 TLS、静态 handler、LLM 驱动的响应以及无限迷宫生成器。 **WordPress 模拟** (`http-80.yaml`): ``` apiVersion: "v1" protocol: "http" address: ":80" description: "Wordpress 6.0" commands: - regex: "^(/index.php|/index.html|/)$" handler: |
Wordpress 6 test page

Hello from Wordpress

headers: - "Content-Type: text/html" - "Server: Apache/2.4.53 (Debian)" - "X-Powered-By: PHP/7.4.29" statusCode: 200 - regex: "^(/wp-login.php|/wp-admin)$" handler: |
headers: - "Content-Type: text/html" - "Server: Apache/2.4.53 (Debian)" statusCode: 200 - regex: "^.*$" handler: "

Not found!

" headers: - "Content-Type: text/html" statusCode: 404 ``` **LLM 驱动的 HTTP 服务** —— 添加带有 `plugin: LLMHoneypot` 的 `fallbackCommand`,以便为任何未匹配的请求生成动态响应。 **无限迷宫生成器** —— 使用 `plugin: MazeHoneypot` 部署一个可以无限扩展的 Apache 风格目录列表,从而困住自动化的扫描器和爬虫。 ### SSH 欺骗服务 SSH 欺骗服务支持静态命令响应和由 LLM 驱动的交互式会话,并具有按会话划分的对话历史记录。 **LLM 驱动的 SSH** (OpenAI): ``` apiVersion: "v1" protocol: "ssh" address: ":2222" description: "SSH interactive GPT-4o" commands: - regex: "^(.+)$" plugin: "LLMHoneypot" serverVersion: "OpenSSH" serverName: "ubuntu" passwordRegex: "^(root|qwerty|Smoker666|123456|jenkins|minecraft|sinus|alex|postgres|Ly123456)$" deadlineTimeoutSeconds: 60 plugin: llmProvider: "openai" llmModel: "gpt-4o" openAISecretKey: "sk-proj-1234" ``` **LLM 驱动的 SSH** (本地 Ollama): ``` apiVersion: "v1" protocol: "ssh" address: ":2222" description: "SSH Ollama Llama3" commands: - regex: "^(.+)$" plugin: "LLMHoneypot" serverVersion: "OpenSSH" serverName: "ubuntu" passwordRegex: "^(root|qwerty|123456)$" deadlineTimeoutSeconds: 60 plugin: llmProvider: "ollama" llmModel: "codellama:7b" host: "http://localhost:11434/api/chat" ``` **静态 SSH**: ``` apiVersion: "v1" protocol: "ssh" address: ":22" description: "SSH interactive" commands: - regex: "^ls$" handler: "Documents Images Desktop Downloads .m2 .kube .ssh .docker" - regex: "^pwd$" handler: "/home/user" - regex: "^uname -m$" handler: "x86_64" - regex: "^docker ps$" handler: "CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES" - regex: "^(.+)$" handler: "command not found" serverVersion: "OpenSSH" serverName: "ubuntu" passwordRegex: "^(root|qwerty|Smoker666)$" deadlineTimeoutSeconds: 60 ``` ### TELNET 欺骗服务 TELNET 欺骗服务可模拟基于终端的设备(路由器、交换机、老旧系统),具备完整的身份验证流程和 LLM 集成。 **LLM 驱动的 TELNET**: ``` apiVersion: "v1" protocol: "telnet" address: ":23" description: "TELNET LLM" commands: - regex: "^(.+)$" plugin: "LLMHoneypot" serverName: "router" passwordRegex: "^(admin|root|password|123456)$" deadlineTimeoutSeconds: 120 plugin: llmProvider: "openai" llmModel: "gpt-4o" openAISecretKey: "sk-1234" ``` **静态 Cisco IOS 模拟**: ``` apiVersion: "v1" protocol: "telnet" address: ":23" description: "Cisco IOS Router" commands: - regex: "^show version$" handler: "Cisco IOS Software, Version 15.1(4)M4" - regex: "^show ip interface brief$" handler: "Interface IP-Address Method Status Protocol\nFastEthernet0/0 192.168.1.1 YES NVRAM up up" - regex: "^(.+)$" handler: "% Unknown command" serverName: "router" passwordRegex: "^(admin|cisco|password)$" deadlineTimeoutSeconds: 60 ``` ### TCP 欺骗服务 TCP 欺骗服务涵盖二进制和基于文本的协议:数据库、消息代理、目录服务、远程访问等。支持仅 banner 模式、交互式 regex 匹配和 LLM 集成。 **Redis**: ``` apiVersion: "v1" protocol: "tcp" address: ":6379" description: "Redis 7.0.12" commands: - regex: "^PING" handler: "+PONG\r\n" - regex: "^AUTH" handler: "-ERR Client sent AUTH, but no password is set\r\n" - regex: "^INFO" handler: "$180\r\n# Server\r\nredis_version:7.0.12\r\nos:Linux 5.15.0-76-generic x86_64\r\ntcp_port:6379\r\n\r\n" - regex: "^(.+)$" handler: "-ERR unknown command\r\n" deadlineTimeoutSeconds: 60 serverName: "redis-prod-01" ``` **LDAP / Active Directory**: ``` apiVersion: "v1" protocol: "tcp" address: ":389" description: "Active Directory LDAP Domain Controller" banner: "0\x84\x00\x00\x00\x10\x02\x01\x01\x61\x84\x00\x00\x00\x07\x0a\x01\x00\x04\x00\x04\x00" commands: - regex: "\\x30.*\\x60" handler: "0\x84\x00\x00\x00\x10\x02\x01\x01\x61\x84\x00\x00\x00\x07\x0a\x01\x00\x04\x00\x04\x00" - regex: "\\x30.*\\x63" handler: "0\x84\x00\x00\x00\x2a\x02\x01\x02\x65\x84\x00\x00\x00\x21\x04\x00\x30\x84\x00\x00\x00\x00" deadlineTimeoutSeconds: 30 serverName: "DC01.corp.local" ``` **LLM 驱动的 PostgreSQL**: ``` apiVersion: "v1" protocol: "tcp" address: ":5432" description: "PostgreSQL 15.3" commands: - regex: "^(.+)$" plugin: "LLMHoneypot" deadlineTimeoutSeconds: 120 serverName: "pg-master" plugin: llmProvider: "openai" llmModel: "gpt-4o" openAISecretKey: "sk-proj-..." prompt: "You are simulating a PostgreSQL 15.3 server. Respond to incoming TCP data as a PostgreSQL server would." ``` 在 `configurations/services/` 中提供了用于 Memcached、MS-SQL、SMB、RDP、VNC 和 MQTT 的更多示例配置。 ## 支持方 [![JetBrains logo.](https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.svg)](https://jb.gg/OpenSourceSupport) ![gitbook logo](https://i.postimg.cc/VNQh5hnk/gitbook.png)
标签:BOF, CISA项目, EVTX分析, Go语言, LLM大语言模型, URL发现, 威胁情报, 安全检测, 开发者工具, 欺骗防御, 程序破解, 蜜罐技术