Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
restart: always
ports:
- "22:22"
- "23:23"
- "2222:2222"
- "8080:8080"
- "8081:8081"
Expand All @@ -15,4 +16,4 @@ services:
RABBITMQ_URI: ${RABBITMQ_URI}
OPEN_AI_SECRET_KEY: ${OPEN_AI_SECRET_KEY}
volumes:
- "./configurations:/configurations"
- "./configurations:/configurations"
2 changes: 1 addition & 1 deletion plugins/beelzebub-cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (beelzebubCloud *beelzebubCloud) GetHoneypotsConfigurations() ([]parser.Bee
var honeypotsConfig []HoneypotConfigResponseDTO

if err = json.Unmarshal(response.Body(), &honeypotsConfig); err != nil {
return nil, "", err
return nil, "", fmt.Errorf("failed to parse honeypots response: %w, body: %s", err, string(response.Body()))
}

var servicesConfiguration = make([]parser.BeelzebubServiceConfiguration, 0)
Expand Down
6 changes: 3 additions & 3 deletions plugins/llm-integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (llmHoneypot *LLMHoneypot) buildPrompt(command string) ([]Message, error) {
var prompt string

switch llmHoneypot.Protocol {
case tracer.SSH:
case tracer.SSH, tracer.TELNET:
prompt = systemPromptVirtualizeLinuxTerminal
if llmHoneypot.CustomPrompt != "" {
prompt = llmHoneypot.CustomPrompt
Expand Down Expand Up @@ -194,7 +194,7 @@ func (llmHoneypot *LLMHoneypot) buildInputValidationPrompt(command string) ([]Me

if prompt == "" {
switch llmHoneypot.Protocol {
case tracer.SSH:
case tracer.SSH, tracer.TELNET:
prompt = inputValidationPromptSSH
case tracer.HTTP:
prompt = inputValidationPromptHTTP
Expand Down Expand Up @@ -223,7 +223,7 @@ func (llmHoneypot *LLMHoneypot) buildOutputValidationPrompt(command string) ([]M

if prompt == "" {
switch llmHoneypot.Protocol {
case tracer.SSH:
case tracer.SSH, tracer.TELNET:
prompt = outputValidationPromptSSH
case tracer.HTTP:
prompt = outputValidationPromptHTTP
Expand Down
108 changes: 59 additions & 49 deletions plugins/llm-integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ func TestBuildPromptWithCustomPrompt(t *testing.T) {
assert.Equal(t, prompt[0].Role, SYSTEM.String())
}

func TestBuildPromptTelnet(t *testing.T) {
honeypot := LLMHoneypot{
Histories: []Message{},
Protocol: tracer.TELNET,
}

prompt, err := honeypot.buildPrompt("ls")

assert.Nil(t, err)
assert.Equal(t, SystemPromptLen, len(prompt))
}

func TestBuildInputValidationPromptDefault(t *testing.T) {
llmHoneypot := LLMHoneypot{
Protocol: tracer.SSH,
Expand Down Expand Up @@ -121,7 +133,7 @@ func TestBuildInputValidationPromptDefault(t *testing.T) {
func TestBuildInputValidationPromptCustom(t *testing.T) {

llmHoneypot := LLMHoneypot{
Protocol: tracer.SSH,
Protocol: tracer.SSH,
InputValidationPrompt: "test",
}

Expand All @@ -145,7 +157,7 @@ func TestBuildOutputValidationPromptDefault(t *testing.T) {
assert.Equal(t, prompt[0].Role, SYSTEM.String())

llmHoneypot = LLMHoneypot{
Protocol: tracer.HTTP,
Protocol: tracer.HTTP,
OutputValidationPrompt: "test",
}

Expand Down Expand Up @@ -602,11 +614,11 @@ func TestIsInputValidFailValidation(t *testing.T) {
)

llmHoneypot := LLMHoneypot{
Histories: make([]Message, 0),
OpenAIKey: "sdjdnklfjndslkjanfk",
Protocol: tracer.SSH,
Model: "gpt-4o",
Provider: OpenAI,
Histories: make([]Message, 0),
OpenAIKey: "sdjdnklfjndslkjanfk",
Protocol: tracer.SSH,
Model: "gpt-4o",
Provider: OpenAI,
InputValidationPrompt: "test input validation",
}

Expand Down Expand Up @@ -648,11 +660,11 @@ func TestIsInputValidPassValidation(t *testing.T) {
)

llmHoneypot := LLMHoneypot{
Histories: make([]Message, 0),
OpenAIKey: "sdjdnklfjndslkjanfk",
Protocol: tracer.SSH,
Model: "gpt-4o",
Provider: OpenAI,
Histories: make([]Message, 0),
OpenAIKey: "sdjdnklfjndslkjanfk",
Protocol: tracer.SSH,
Model: "gpt-4o",
Provider: OpenAI,
InputValidationPrompt: "test input validation",
}

Expand Down Expand Up @@ -693,11 +705,11 @@ func TestIsOutputValidFailValidation(t *testing.T) {
)

llmHoneypot := LLMHoneypot{
Histories: make([]Message, 0),
OpenAIKey: "sdjdnklfjndslkjanfk",
Protocol: tracer.SSH,
Model: "gpt-4o",
Provider: OpenAI,
Histories: make([]Message, 0),
OpenAIKey: "sdjdnklfjndslkjanfk",
Protocol: tracer.SSH,
Model: "gpt-4o",
Provider: OpenAI,
OutputValidationPrompt: "test output validation",
}

Expand Down Expand Up @@ -739,11 +751,11 @@ func TestIsOutputValidPassValidation(t *testing.T) {
)

llmHoneypot := LLMHoneypot{
Histories: make([]Message, 0),
OpenAIKey: "sdjdnklfjndslkjanfk",
Protocol: tracer.SSH,
Model: "gpt-4o",
Provider: OpenAI,
Histories: make([]Message, 0),
OpenAIKey: "sdjdnklfjndslkjanfk",
Protocol: tracer.SSH,
Model: "gpt-4o",
Provider: OpenAI,
OutputValidationPrompt: "test output validation",
}

Expand Down Expand Up @@ -784,13 +796,13 @@ func TestExecuteModelFailInputValidation(t *testing.T) {
)

llmHoneypot := LLMHoneypot{
Histories: make([]Message, 0),
OpenAIKey: "sdjdnklfjndslkjanfk",
Protocol: tracer.SSH,
Model: "gpt-4o",
Provider: OpenAI,
Histories: make([]Message, 0),
OpenAIKey: "sdjdnklfjndslkjanfk",
Protocol: tracer.SSH,
Model: "gpt-4o",
Provider: OpenAI,
InputValidationEnabled: true,
InputValidationPrompt: "test input validation",
InputValidationPrompt: "test input validation",
}

openAIGPTVirtualTerminal := InitLLMHoneypot(llmHoneypot)
Expand Down Expand Up @@ -869,17 +881,16 @@ func TestExecuteModelPassInputValidationFailOutputValidation(t *testing.T) {
)

llmHoneypot := LLMHoneypot{
Histories: make([]Message, 0),
OpenAIKey: "sdjdnklfjndslkjanfk",
Protocol: tracer.SSH,
Model: "gpt-4o",
Provider: OpenAI,
CustomPrompt: "custom prompt",
InputValidationEnabled: true,
Histories: make([]Message, 0),
OpenAIKey: "sdjdnklfjndslkjanfk",
Protocol: tracer.SSH,
Model: "gpt-4o",
Provider: OpenAI,
CustomPrompt: "custom prompt",
InputValidationEnabled: true,
OutputValidationEnabled: true,
InputValidationPrompt: "test input validation",
OutputValidationPrompt: "test output validation",

InputValidationPrompt: "test input validation",
OutputValidationPrompt: "test output validation",
}

openAIGPTVirtualTerminal := InitLLMHoneypot(llmHoneypot)
Expand Down Expand Up @@ -958,17 +969,16 @@ func TestExecuteModelPassAllValidations(t *testing.T) {
)

llmHoneypot := LLMHoneypot{
Histories: make([]Message, 0),
OpenAIKey: "sdjdnklfjndslkjanfk",
Protocol: tracer.SSH,
Model: "gpt-4o",
Provider: OpenAI,
CustomPrompt: "custom prompt",
InputValidationEnabled: true,
Histories: make([]Message, 0),
OpenAIKey: "sdjdnklfjndslkjanfk",
Protocol: tracer.SSH,
Model: "gpt-4o",
Provider: OpenAI,
CustomPrompt: "custom prompt",
InputValidationEnabled: true,
OutputValidationEnabled: true,
InputValidationPrompt: "test input validation",
OutputValidationPrompt: "test output validation",

InputValidationPrompt: "test input validation",
OutputValidationPrompt: "test output validation",
}

openAIGPTVirtualTerminal := InitLLMHoneypot(llmHoneypot)
Expand All @@ -979,4 +989,4 @@ func TestExecuteModelPassAllValidations(t *testing.T) {

//Then
assert.Nil(t, err)
}
}
Loading
Loading