Skip to content

Commit c032489

Browse files
authored
Feat: add MCP honeypot support (#199)
* Add MCP honeypot * Add http headers in plain text * Improve code coverage * Refactor README.md
1 parent e1e8012 commit c032489

File tree

12 files changed

+322
-46
lines changed

12 files changed

+322
-46
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
echo "Quality Gate: checking test coverage is above threshold ..."
4646
echo "Threshold : $TESTCOVERAGE_THRESHOLD %"
4747
# Excluded the concrete strategy from the unit test coverage, because covered by integration tests
48-
cat coverage.tmp.out | grep -v "ssh.go" | grep -v "http.go" | grep -v "tcp.go" | grep -v "builder.go" | grep -v "director.go" > coverage.out
48+
cat coverage.tmp.out | grep -v "mcp.go" | grep -v "ssh.go" | grep -v "http.go" | grep -v "tcp.go" | grep -v "builder.go" | grep -v "director.go" > coverage.out
4949
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
5050
echo "Current test coverage : $totalCoverage %"
5151
if (( $(echo "$totalCoverage $TESTCOVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then

README.md

Lines changed: 119 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,45 @@ Beelzebub is an advanced honeypot framework designed to provide a highly secure
1212

1313
<img src="https://beelzebub.netlify.app/go-beelzebub.png" alt="Beelzebub Logo" width="200"/>
1414

15-
## LLM Honeypot
15+
## Key Features
16+
17+
Beelzebub offers a wide range of features to enhance your honeypot environment:
18+
19+
- Low-code configuration: YAML-based, modular service definition
20+
- LLM integration: The LLM convincingly simulates a real system, creating high-interaction honeypot experiences, while actually maintaining low-interaction architecture for enhanced security and easy management.
21+
- Multi-protocol support: SSH, HTTP, TCP, MCP(Detect prompt injection against LLM agents)
22+
- Prometheus metrics & observability
23+
- Docker & Kubernetes ready
24+
- ELK stack ready, docs: [Official ELK integration](https://www.elastic.co/docs/reference/integrations/beelzebub)
25+
26+
## LLM SSH Honeypot Demo
1627

1728
[![asciicast](https://asciinema.org/a/665295.svg)](https://asciinema.org/a/665295)
1829

30+
## Code Quality
31+
32+
We are strongly committed to maintaining high code quality in the Beelzebub project. Our development workflow includes comprehensive testing, code reviews, static analysis, and continuous integration to ensure the reliability and maintainability of the codebase.
33+
34+
### What We Do
35+
36+
* **Automated Testing:**
37+
Both unit and integration tests are run on every pull request to catch regressions and ensure stability.
1938

20-
## Telegram Bot for Real-Time Attacks
39+
* **Static Analysis:**
40+
We use tools like Go Report Card and CodeQL to automatically check for code quality, style, and security issues.
2141

22-
Stay updated on real-time attacks by joining our dedicated Telegram channel: [Telegram Channel](https://t.me/beelzebubhoneypot)
42+
* **Code Coverage:**
43+
Our test coverage is monitored with [Codecov](https://codecov.io/gh/mariocandela/beelzebub), and we aim for extensive coverage of all core components.
2344

24-
## Examples
45+
* **Continuous Integration:**
46+
Every commit triggers automated CI pipelines on GitHub Actions, which run all tests and quality checks.
2547

26-
To better understand the capabilities of Beelzebub, you can explore our example repository: [mariocandela/beelzebub-example](https://github.com/mariocandela/beelzebub-example)
48+
* **Code Reviews:**
49+
All new contributions undergo peer review to maintain consistency and high standards across the project.
2750

2851
## Quick Start
2952

30-
We provide two quick start options for build and run Beelzebub: using Docker Compose or the Go compiler.
53+
You can run Beelzebub via Docker, Go compiler(cross device), or Helm (Kubernetes).
3154

3255
### Using Docker Compose
3356

@@ -43,6 +66,7 @@ We provide two quick start options for build and run Beelzebub: using Docker Com
4366
$ docker-compose up -d
4467
```
4568

69+
4670
### Using Go Compiler
4771

4872
1. Download the necessary Go modules:
@@ -78,55 +102,86 @@ We provide two quick start options for build and run Beelzebub: using Docker Com
78102
```bash
79103
$ helm upgrade beelzebub ./beelzebub-chart
80104
```
81-
## Testing
82105

83-
We provide two types of tests: unit tests and integration tests.
106+
## Example Configuration
84107

85-
### Unit Tests
108+
Beelzebub allows easy configuration for different services and ports. Simply create a new file for each service/port within the `/configurations/services` directory.
86109

87-
To run unit tests:
110+
To execute Beelzebub with your custom path, use the following command:
88111

89112
```bash
90-
$ make test.unit
113+
$ ./beelzebub --confCore ./configurations/beelzebub.yaml --confServices ./configurations/services/
91114
```
92115

93-
### Integration Tests
94-
95-
To run integration tests:
116+
Here are some example configurations for different honeypot scenarios:
96117

97-
```bash
98-
$ make test.dependencies.start
99-
$ make test.integration
100-
$ make test.dependencies.down
101-
```
118+
### MCP Honeypot
102119

103-
## Key Features
120+
#### Why choose an MCP Honeypot?
104121

105-
Beelzebub offers a wide range of features to enhance your honeypot environment:
122+
An MCP honeypot is a **decoy tool** that the agent should never invoke under normal circumstances. Integrating this strategy into your agent pipeline offers three key benefits:
106123

107-
- Support for Ollama
108-
- Support for OpenAI
109-
- SSH Honeypot
110-
- HTTP Honeypot
111-
- TCP Honeypot
112-
- Prometheus openmetrics integration
113-
- Docker integration
114-
- RabbitMQ integration
115-
- kubernetes
124+
* **Real-time detection of guardrail bypass attempts.**
125+
126+
Instantly identify when a prompt injection attack successfully convinces the agent to invoke a restricted tool.
127+
* **Automatic collection of real attack prompts for guardrail fine-tuning.**
128+
129+
Every activation logs genuine malicious prompts, enabling continuous improvement of your filtering mechanisms.
130+
* **Continuous monitoring of attack trends through key metrics (HAR, TPR, MTP).**
131+
132+
Track exploit frequency and system resilience using objective, actionable measurements.
116133

117-
## Example Configuration
134+
##### Example MCP Honeypot Configuration
118135

119-
Beelzebub allows easy configuration for different services and ports. Simply create a new file for each service/port within the `/configurations/services` directory.
136+
###### mcp-8000.yaml
120137

121-
To execute Beelzebub with your custom path, use the following command:
122-
123-
```bash
124-
$ ./beelzebub --confCore ./configurations/beelzebub.yaml --confServices ./configurations/services/
138+
```yaml
139+
apiVersion: "v1"
140+
protocol: "mcp"
141+
address: ":8000"
142+
description: "MCP Honeypot"
143+
tools:
144+
- name: "tool:user-account-manager"
145+
description: "Tool for querying and modifying user account details. Requires administrator privileges."
146+
params:
147+
- name: "user_id"
148+
description: "The ID of the user account to manage."
149+
- name: "action"
150+
description: "The action to perform on the user account, possible values are: get_details, reset_password, deactivate_account"
151+
handler: |
152+
{
153+
"tool_id": "tool:user-account-manager",
154+
"status": "completed",
155+
"output": {
156+
"message": "Tool 'tool:user-account-manager' executed successfully. Results are pending internal processing and will be logged.",
157+
"result": {
158+
"operation_status": "success",
159+
"details": "email: [email protected], role: admin, last-login: 02/07/2025"
160+
}
161+
}
162+
}
163+
- name: "tool:system-log"
164+
description: "Tool for querying system logs. Requires administrator privileges."
165+
params:
166+
- name: "filter"
167+
description: "The input used to filter the logs."
168+
handler: |
169+
{
170+
"tool_id": "tool:system-log",
171+
"status": "completed",
172+
"output": {
173+
"message": "Tool 'tool:system-log' executed successfully. Results are pending internal processing and will be logged.",
174+
"result": {
175+
"operation_status": "success",
176+
"details": "Info: email: [email protected], last-login: 02/07/2025"
177+
}
178+
}
179+
}
125180
```
126181
127-
Here are some example configurations for different honeypot scenarios:
182+
#### Invoke remotely: beelzebub:port/mcp (Streamable HTTPServer).
128183
129-
#### Example HTTP Honeypot on Port 80
184+
### HTTP Honeypot
130185
131186
###### http-80.yaml
132187
@@ -191,7 +246,7 @@ commands:
191246
statusCode: 404
192247
```
193248
194-
#### Example HTTP Honeypot on Port 8080
249+
### HTTP Honeypot
195250
196251
###### http-8080.yaml
197252
@@ -209,7 +264,7 @@ commands:
209264
statusCode: 401
210265
```
211266
212-
#### Example SSH Honeypot
267+
### SSH Honeypot
213268
214269
###### LLM Honeypots
215270
@@ -273,7 +328,7 @@ plugin:
273328
prompt: "You will act as an Ubuntu Linux terminal. The user will type commands, and you are to reply with what the terminal should show. Your responses must be contained within a single code block."
274329
```
275330
276-
###### SSH Honeypot on Port 22
331+
###### SSH Honeypot
277332
278333
###### ssh-22.yaml
279334
@@ -307,6 +362,29 @@ passwordRegex: "^(root|qwerty|Smoker666)$"
307362
deadlineTimeoutSeconds: 60
308363
```
309364
365+
## Testing
366+
367+
Maintaining excellent code quality is essential for security-focused projects like Beelzebub. We welcome all contributors who share our commitment to robust, readable, and reliable code!
368+
369+
### Unit Tests
370+
371+
For contributor, we have a comprehensive suite of unit/integration tests that cover the core functionality of Beelzebub. To run the unit tests, use the following command:
372+
373+
```bash
374+
$ make test.unit
375+
```
376+
377+
### Integration Tests
378+
379+
To run integration tests:
380+
381+
```bash
382+
$ make test.dependencies.start
383+
$ make test.integration
384+
$ make test.dependencies.down
385+
```
386+
387+
310388
## Roadmap
311389

312390
Our future plans for Beelzebub include developing it into a robust PaaS platform.

builder/builder.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package builder
33
import (
44
"errors"
55
"fmt"
6+
"github.com/mariocandela/beelzebub/v3/protocols/strategies/MCP"
67
"io"
78
"net/http"
89
"os"
@@ -112,6 +113,7 @@ Honeypot Framework, happy hacking!`)
112113
secureShellStrategy := &SSH.SSHStrategy{}
113114
hypertextTransferProtocolStrategy := &HTTP.HTTPStrategy{}
114115
transmissionControlProtocolStrategy := &TCP.TCPStrategy{}
116+
modelContextProtocolStrategy := &MCP.MCPStrategy{}
115117

116118
// Init Tracer strategies, and set the trace strategy default HTTP
117119
protocolManager := protocols.InitProtocolManager(b.traceStrategy, hypertextTransferProtocolStrategy)
@@ -139,6 +141,8 @@ Honeypot Framework, happy hacking!`)
139141
protocolManager.SetProtocolStrategy(secureShellStrategy)
140142
case "tcp":
141143
protocolManager.SetProtocolStrategy(transmissionControlProtocolStrategy)
144+
case "mcp":
145+
protocolManager.SetProtocolStrategy(modelContextProtocolStrategy)
142146
default:
143147
log.Fatalf("protocol %s not managed", beelzebubServiceConfiguration.Protocol)
144148
}

configurations/services/mcp-8000.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
apiVersion: "v1"
2+
protocol: "mcp"
3+
address: ":8000"
4+
description: "MCP Honeypot"
5+
tools:
6+
- name: "tool:user-account-manager"
7+
description: "Tool for querying and modifying user account details. Requires administrator privileges."
8+
params:
9+
- name: "user_id"
10+
description: "The ID of the user account to manage."
11+
- name: "action"
12+
description: "The action to perform on the user account, possible values are: get_details, reset_password, deactivate_account"
13+
handler: |
14+
{
15+
"tool_id": "tool:user-account-manager",
16+
"status": "completed",
17+
"output": {
18+
"message": "Tool 'tool:user-account-manager' executed successfully. Results are pending internal processing and will be logged.",
19+
"result": {
20+
"operation_status": "success",
21+
"details": "email: [email protected], role: admin, last-login: 02/07/2025"
22+
}
23+
}
24+
}
25+
- name: "tool:system-log"
26+
description: "Tool for querying system logs. Requires administrator privileges."
27+
params:
28+
- name: "filter"
29+
description: "The input used to filter the logs."
30+
handler: |
31+
{
32+
"tool_id": "tool:system-log",
33+
"status": "completed",
34+
"output": {
35+
"message": "Tool 'tool:system-log' executed successfully. Results are pending internal processing and will be logged.",
36+
"result": {
37+
"operation_status": "success",
38+
"details": "Info: email: [email protected], last-login: 02/07/2025"
39+
}
40+
}
41+
}

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ require (
2626
github.com/davecgh/go-spew v1.1.1 // indirect
2727
github.com/kr/fs v0.1.0 // indirect
2828
github.com/kr/text v0.2.0 // indirect
29+
github.com/mark3labs/mcp-go v0.32.0 // indirect
2930
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
3031
github.com/pkg/errors v0.9.1 // indirect
3132
github.com/pkg/sftp v1.13.5 // indirect
3233
github.com/pmezard/go-difflib v1.0.0 // indirect
3334
github.com/prometheus/client_model v0.6.1 // indirect
3435
github.com/prometheus/common v0.62.0 // indirect
3536
github.com/prometheus/procfs v0.15.1 // indirect
37+
github.com/spf13/cast v1.7.1 // indirect
38+
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
3639
golang.org/x/net v0.38.0 // indirect
3740
golang.org/x/sys v0.33.0 // indirect
3841
google.golang.org/protobuf v1.36.5 // indirect

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
2828
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
2929
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
3030
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
31+
github.com/mark3labs/mcp-go v0.32.0 h1:fgwmbfL2gbd67obg57OfV2Dnrhs1HtSdlY/i5fn7MU8=
32+
github.com/mark3labs/mcp-go v0.32.0/go.mod h1:rXqOudj/djTORU/ThxYx8fqEVj/5pvTuuebQ2RC7uk4=
3133
github.com/maxatome/go-testdeep v1.14.0 h1:rRlLv1+kI8eOI3OaBXZwb3O7xY3exRzdW5QyX48g9wI=
3234
github.com/maxatome/go-testdeep v1.14.0/go.mod h1:lPZc/HAcJMP92l7yI6TRz1aZN5URwUBUAfUNvrclaNM=
3335
github.com/melbahja/goph v1.4.0 h1:z0PgDbBFe66lRYl3v5dGb9aFgPy0kotuQ37QOwSQFqs=
@@ -54,10 +56,14 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR
5456
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
5557
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
5658
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
59+
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
60+
github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
5761
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
5862
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
5963
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
6064
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
65+
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
66+
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
6167
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
6268
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
6369
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=

parser/configurations_parser.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ type BeelzebubServiceConfiguration struct {
6363
Protocol string `yaml:"protocol"`
6464
Address string `yaml:"address"`
6565
Commands []Command `yaml:"commands"`
66+
Tools []Tool `yaml:"tools"`
6667
FallbackCommand Command `yaml:"fallbackCommand"`
6768
ServerVersion string `yaml:"serverVersion"`
6869
ServerName string `yaml:"serverName"`
@@ -86,6 +87,20 @@ type Command struct {
8687
Name string `yaml:"name"`
8788
}
8889

90+
// Tool is the struct that contains the configurations of the MCP Honeypot
91+
type Tool struct {
92+
Name string `yaml:"name"`
93+
Description string `yaml:"description"`
94+
Params []Param `yaml:"params"`
95+
Handler string `yaml:"handler"`
96+
}
97+
98+
// Param is the struct that contains the configurations of the parameters of the tools
99+
type Param struct {
100+
Name string `yaml:"name"`
101+
Description string `yaml:"description"`
102+
}
103+
89104
type configurationsParser struct {
90105
configurationsCorePath string
91106
configurationsServicesDirectory string

0 commit comments

Comments
 (0)