Compare commits

..

34 Commits

Author SHA1 Message Date
9025edee1e Bump github.com/sirupsen/logrus from 1.9.0 to 1.9.1 (#41)
Bumps [github.com/sirupsen/logrus](https://github.com/sirupsen/logrus) from 1.9.0 to 1.9.1.
- [Release notes](https://github.com/sirupsen/logrus/releases)
- [Changelog](https://github.com/sirupsen/logrus/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sirupsen/logrus/compare/v1.9.0...v1.9.1)

---
updated-dependencies:
- dependency-name: github.com/sirupsen/logrus
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-17 10:03:23 +02:00
853708a598 Bump golang.org/x/crypto from 0.8.0 to 0.9.0 (#40)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.8.0 to 0.9.0.
- [Commits](https://github.com/golang/crypto/compare/v0.8.0...v0.9.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-10 09:35:14 +02:00
8d9f1b48da Bump github.com/rabbitmq/amqp091-go from 1.8.0 to 1.8.1 (#39)
Bumps [github.com/rabbitmq/amqp091-go](https://github.com/rabbitmq/amqp091-go) from 1.8.0 to 1.8.1.
- [Release notes](https://github.com/rabbitmq/amqp091-go/releases)
- [Changelog](https://github.com/rabbitmq/amqp091-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rabbitmq/amqp091-go/compare/v1.8.0...v1.8.1)

---
updated-dependencies:
- dependency-name: github.com/rabbitmq/amqp091-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-05 09:06:22 +02:00
9d0a92e74e Bump github.com/prometheus/client_golang from 1.15.0 to 1.15.1 (#38) 2023-05-04 07:53:46 +02:00
49a4022f56 feat: Trace command output for SSH Strategy (#35)
manage command output SSH strategy
2023-04-14 22:35:11 +02:00
fe6d95ecd6 Create pull_request_template.md
Signed-off-by: Mario Candela <m4r10.php@gmail.com>
2023-04-14 22:26:45 +02:00
d24a580a78 Bump github.com/prometheus/client_golang from 1.14.0 to 1.15.0 (#34) 2023-04-14 07:51:58 +02:00
9a354add6f fix typo 2023-04-13 21:50:25 +02:00
3652af6dc3 refactoring pipeline CD docker image 2023-04-13 21:48:38 +02:00
5532d3c629 Bump golang.org/x/crypto from 0.7.0 to 0.8.0 (#32) 2023-04-10 07:08:11 +02:00
97ab2f6e95 Fixed Backward Compatibility 2023-03-31 22:06:08 +02:00
f50f5185df feature: Configured prometheus, improve readme (#31) 2023-03-31 20:03:42 +02:00
5a70e5c900 Update SECURITY.md
Signed-off-by: Mario Candela <m4r10.php@gmail.com>
2023-03-26 23:08:15 +02:00
142dccabf1 Bump github.com/rabbitmq/amqp091-go from 1.7.0 to 1.8.0 (#30)
Bumps [github.com/rabbitmq/amqp091-go](https://github.com/rabbitmq/amqp091-go) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/rabbitmq/amqp091-go/releases)
- [Changelog](https://github.com/rabbitmq/amqp091-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rabbitmq/amqp091-go/compare/v1.7.0...v1.8.0)

---
updated-dependencies:
- dependency-name: github.com/rabbitmq/amqp091-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-22 07:42:05 +01:00
8337281f21 test: add rabbitMQ integration test (#29)
* added integration test dependencies

* added rabbitMQ use case integration test

* configured rabbitMQ integration test URI

* fix typo, configured integration test pipeline
2023-03-21 11:20:12 +01:00
1c402141bf Update README.md
Add telegram channel
2023-03-09 07:32:36 +01:00
9c9fd0b676 Bump golang.org/x/crypto from 0.6.0 to 0.7.0 (#28)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.6.0 to 0.7.0.
- [Release notes](https://github.com/golang/crypto/releases)
- [Commits](https://github.com/golang/crypto/compare/v0.6.0...v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-06 07:45:00 +01:00
97cfdcc8af Update codeql.yml
improve performance and cost CodeQL

Signed-off-by: Mario Candela <m4r10.php@gmail.com>
2023-03-05 17:26:07 +01:00
c7c169c96d Create SECURITY.md
Signed-off-by: Mario Candela <m4r10.php@gmail.com>
2023-03-05 17:23:40 +01:00
f733a0ea96 Create codeql.yml
Signed-off-by: Mario Candela <m4r10.php@gmail.com>
2023-03-05 17:09:21 +01:00
31a75cc128 Update ci.yml
Signed-off-by: Mario Candela <m4r10.php@gmail.com>
2023-03-05 15:22:21 +01:00
fd7db83fd8 Update README.md (#27)
Signed-off-by: Ikko Eltociear Ashimine <eltociear@gmail.com>
2023-03-03 18:29:43 +01:00
1b01933946 Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 (#26)
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.1 to 1.8.2.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.1...v1.8.2)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-27 06:34:54 +01:00
6548cf62ce Bump golang.org/x/net from 0.6.0 to 0.7.0 (#25)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.6.0 to 0.7.0.
- [Release notes](https://github.com/golang/net/releases)
- [Commits](https://github.com/golang/net/compare/v0.6.0...v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-26 18:09:25 +01:00
6468b5aa6f refactor:Added Integration test and tiny refactoring (#23)
* Refactoring name convention

* Added integration test

* Added Makefile

* Bump golang.org/x/crypto from 0.0.0-20220826181053-bd7e27e6170d to 0.6.0

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.0.0-20220826181053-bd7e27e6170d to 0.6.0.
- [Release notes](https://github.com/golang/crypto/releases)
- [Commits](https://github.com/golang/crypto/commits/v0.6.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

* Upgrade go from 1.16 to 1.20

* Added integration test: HTTP, TCP, SSH

* Added Makefile Improve README.md

* Fixed unit test CI

* Fixed go-version

* Added integration test into C.I. actions

---------

Signed-off-by: Mario Candela <m4r10.php@gmail.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-26 18:04:05 +01:00
bbcc8c9094 Bump github.com/rabbitmq/amqp091-go from 1.5.0 to 1.7.0 (#22)
Bumps [github.com/rabbitmq/amqp091-go](https://github.com/rabbitmq/amqp091-go) from 1.5.0 to 1.7.0.
- [Release notes](https://github.com/rabbitmq/amqp091-go/releases)
- [Changelog](https://github.com/rabbitmq/amqp091-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rabbitmq/amqp091-go/compare/v1.5.0...v1.7.0)

---
updated-dependencies:
- dependency-name: github.com/rabbitmq/amqp091-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-16 20:27:32 +01:00
6ff99e4eed Bump github.com/jarcoal/httpmock from 1.2.0 to 1.3.0 (#20)
Bumps [github.com/jarcoal/httpmock](https://github.com/jarcoal/httpmock) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/jarcoal/httpmock/releases)
- [Commits](https://github.com/jarcoal/httpmock/compare/v1.2.0...v1.3.0)

---
updated-dependencies:
- dependency-name: github.com/jarcoal/httpmock
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-09 18:06:39 +01:00
0ebb6fa1e2 Update README.md
Signed-off-by: Mario Candela <m4r10.php@gmail.com>
2023-01-29 12:34:56 +01:00
6f9781f06f Update FUNDING.yml
Signed-off-by: Mario Candela <m4r10.php@gmail.com>
2023-01-27 10:49:47 +01:00
e4ca84589b feat!: Tiny refactoring, changed plugin name (#17)
* tiny refactoring naming
2023-01-22 13:00:52 +01:00
31f5ca9cb1 Update README.md
Signed-off-by: Mario Candela <m4r10.php@gmail.com>
2023-01-08 13:10:19 +01:00
c6855e8511 Update README.md
Signed-off-by: Mario Candela <m4r10.php@gmail.com>
2022-12-21 00:12:43 +01:00
6d2500d0f5 copy the ca-certificate.crt into scratch container 2022-12-19 23:08:21 +01:00
c98b888985 Add 2222:2222 ports mapping.
Signed-off-by: Mario Candela <m4r10.php@gmail.com>
2022-12-18 18:49:13 +01:00
33 changed files with 672 additions and 146 deletions

1
.github/FUNDING.yml vendored
View File

@ -1 +1,2 @@
patreon: mariocandela
custom: ["https://www.paypal.com/donate/?business=P75FH5LXKQTAC&no_recurring=0&currency_code=EUR"]

View File

@ -8,7 +8,7 @@ on:
jobs:
build:
CI:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
@ -16,9 +16,9 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.16
go-version: 1.20.0
- name: Dependences
- name: Dependencies
run: go mod download
- name: Vet
@ -30,7 +30,7 @@ jobs:
- name: Unit tests
run: |
go test ./... -coverprofile coverage.tmp.out -covermode count
go test ./... -v -coverprofile coverage.tmp.out -covermode count
go tool cover -func coverage.tmp.out
- name: Quality Gate - Test coverage shall be above threshold
@ -39,7 +39,7 @@ jobs:
run: |
echo "Quality Gate: checking test coverage is above threshold ..."
echo "Threshold : $TESTCOVERAGE_THRESHOLD %"
# Excluded the concrete strategy from the coverage calculation, this will be tested in the integration tests
# Excluded the concrete strategy from the coverage calculation, because tested by integration tests
cat coverage.tmp.out | grep -v "secureShellStrategy.go" | grep -v "hypertextTransferProtocolStrategy.go" | grep -v "transmissionControlProtocolStrategy.go" > coverage.out
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
echo "Current test coverage : $totalCoverage %"
@ -50,3 +50,26 @@ jobs:
echo "Failed"
exit 1
fi
- name: Start integration test dependencies
run: |
make test.dependencies.start
- name: Wait for RabbitMQ to be ready
run: |
sleep 2
count=0
until docker exec rabbitmq rabbitmqctl list_queues > /dev/null 2>&1; do
count=$((count+1))
if [ $count -gt 10 ]; then
echo "RabbitMQ did not start within the specified time"
exit 1
fi
echo "Waiting for RabbitMQ to start..."
sleep 5
done
- name: Integration tests
run: |
make test.integration.verbose
make test.dependencies.down

40
.github/workflows/codeql.yml vendored Normal file
View File

@ -0,0 +1,40 @@
name: "CodeQL"
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '36 10 * * 0'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Build beelzebub
run: go build ./...
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"

View File

@ -6,21 +6,26 @@ on:
- 'v*.*.*'
jobs:
build:
CD:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Docker login
env:
DOCKER_USER: ${{secrets.DOCKER_USER}}
DOCKER_ACCESS_TOKEN: ${{secrets.DOCKER_ACCESS_TOKEN}}
run: |
docker login -u $DOCKER_USER -p $DOCKER_ACCESS_TOKEN
- name: Build the Docker image
run: docker build . --file Dockerfile --tag m4r10/beelzebub:${{ github.ref_name }}
- name: Docker Push
run: docker push m4r10/beelzebub:${{ github.ref_name }}
-
name: Checkout
uses: actions/checkout@v3
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: m4r10/beelzebub:${{ github.ref_name }}

4
.gitignore vendored
View File

@ -1,3 +1,5 @@
.DS_Store
.idea
logs
logs
.vscode
.history

View File

@ -29,6 +29,8 @@ RUN cp /build/main .
# Build a small image
FROM scratch
# copy the ca-certificate.crt from the builder stage
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /dist/main /
ENTRYPOINT ["/main"]

30
Makefile Normal file
View File

@ -0,0 +1,30 @@
DOCKER_COMPOSE := $(shell which docker-compose)
ifeq (${DOCKER_COMPOSE},)
DOCKER_COMPOSE = docker compose
endif
beelzebub.start:
${DOCKER_COMPOSE} build;
${DOCKER_COMPOSE} up -d;
beelzebub.stop:
${DOCKER_COMPOSE} down;
test.unit:
go test ./...
test.unit.verbose:
go test ./... -v
test.dependencies.start:
${DOCKER_COMPOSE} -f ./integration_test/docker-compose.yml up -d
test.dependencies.down:
${DOCKER_COMPOSE} -f ./integration_test/docker-compose.yml down
test.integration:
INTEGRATION=1 go test ./...
test.integration.verbose:
INTEGRATION=1 go test ./... -v

View File

@ -1,10 +1,19 @@
# Beelzebub ![CI](https://github.com/mariocandela/beelzebub/actions/workflows/ci.yml/badge.svg) ![Docker](https://github.com/mariocandela/beelzebub/actions/workflows/docker-image.yml/badge.svg)
![CI](https://github.com/mariocandela/beelzebub/actions/workflows/ci.yml/badge.svg) ![Docker](https://github.com/mariocandela/beelzebub/actions/workflows/docker-image.yml/badge.svg) ![codeql](https://github.com/mariocandela/beelzebub/actions/workflows/codeql.yml/badge.svg)
# Beelzebub
[![logo-1.png](https://i.postimg.cc/KvbsJFp3/logo-1.png)](https://postimg.cc/yWfPNqH7)
A secure honeypot framework low code, extremely easy to configure by yaml 🚀
## Examples:
## OpenAI GPT integration
How to integrate with OpenAI GPT-3: [`Medium Article`](https://medium.com/@mario.candela.personal/how-to-build-a-highly-effective-honeypot-with-beelzebub-and-chatgpt-a2f0f05b3e1)
[![OpenAI Integration Diagram](https://static.swimlanes.io/24d6634a381aa8eb0decf5bac7ae214d.png)](https://static.swimlanes.io/24d6634a381aa8eb0decf5bac7ae214d.png)
## Telegram bot realtime attacks
bot: [`telegram channel`](https://t.me/beelzebubhoneypot)
## Examples
[`mariocandela/beelzebub-example`](https://github.com/mariocandela/beelzebub-example)
@ -25,12 +34,30 @@ $ go build
$ ./beelzebub
```
Unit Test:
### Unit Test:
```bash
$ go test ./...
$ make test.unit
```
### Integration test:
Run integration testing
```bash
$ make test.integration
```
## Features
- OpenAPI ChatBot GPT-3 Linux virtualization
- SSH Honeypot
- HTTP Honeypot
- TCP Honeypot
- Prometheus openmetrics
- Docker
- RabbitMQ integration
## Example configuration service
The configurations are inside the /configurations/services directory, just add a new file for each service/port.
@ -95,7 +122,7 @@ address: ":2222"
description: "SSH interactive ChatGPT"
commands:
- regex: "^(.+)$"
plugin: "OpenAIChatGPT"
plugin: "OpenAIGPTLinuxTerminal"
serverVersion: "OpenSSH"
serverName: "ubuntu"
passwordRegex: "^(root|qwerty|Smoker666|123456|jenkins|minecraft|sinus|alex|postgres|Ly123456)$"
@ -136,18 +163,6 @@ deadlineTimeoutSeconds: 60
![alt text](https://i.postimg.cc/jdpfT0LB/Schermata-2022-06-02-alle-12-46-50.png)
## Features
- OpenAPI ChatBot GPT-3 integration
- SSH Honeypot
- HTTP Honeypot
- TCP Honeypot
- Easy to create a new strategy
- Easy to extend event tracking logic
- Strong code quality
- Docker
- RabbitMQ integration
## TODO
- telnet
@ -173,3 +188,5 @@ Happy hacking!
## License
This project is licensed under [GNU GPL 3 License](LICENSE).
[![](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/donate/?business=P75FH5LXKQTAC&no_recurring=0&currency_code=EUR)

13
SECURITY.md Normal file
View File

@ -0,0 +1,13 @@
# Security Policy
## Supported Versions
| Version | Supported |
| ------- | ------------------ |
| >= 2.0.0 | :white_check_mark: |
| < 2.0.0 | :x: |
## Reporting a Vulnerability
Please report (suspected) security vulnerabilities to mario.candela.personal@gmail.com.
You will receive a response from us within 48 hours. If the issue is confirmed, we will release a patch as soon as possible depending on complexity but historically within a few days.

View File

@ -3,19 +3,24 @@ package builder
import (
"beelzebub/parser"
"beelzebub/protocols"
"beelzebub/protocols/strategies"
"beelzebub/tracer"
"errors"
"fmt"
"io"
"net/http"
"os"
"github.com/prometheus/client_golang/prometheus/promhttp"
amqp "github.com/rabbitmq/amqp091-go"
log "github.com/sirupsen/logrus"
"io"
"os"
)
const RabbitmqQueueName = "event"
type Builder struct {
beelzebubServicesConfiguration []parser.BeelzebubServiceConfiguration
beelzebubCoreConfigurations *parser.BeelzebubCoreConfigurations
traceStrategy tracer.Strategy
rabbitMQChannel *amqp.Channel
rabbitMQConnection *amqp.Connection
@ -68,24 +73,33 @@ func (b *Builder) buildRabbitMQ(rabbitMQURI string) error {
}
func (b *Builder) Close() error {
if err := b.rabbitMQChannel.Close(); err != nil {
return err
if b.rabbitMQConnection != nil {
if err := b.rabbitMQChannel.Close(); err != nil {
return err
}
if err := b.rabbitMQConnection.Close(); err != nil {
return err
}
}
if err := b.rabbitMQConnection.Close(); err != nil {
return err
}
if err := b.logsFile.Close(); err != nil {
return err
}
return nil
}
func (b *Builder) Run() error {
// Init Prometheus openmetrics
go func() {
if (b.beelzebubCoreConfigurations.Core.Prometheus != parser.Prometheus{}) {
http.Handle(b.beelzebubCoreConfigurations.Core.Prometheus.Path, promhttp.Handler())
if err := http.ListenAndServe(b.beelzebubCoreConfigurations.Core.Prometheus.Port, nil); err != nil {
log.Fatalf("Error init Prometheus: %s", err.Error())
}
}
}()
// Init Protocol strategies
secureShellStrategy := &protocols.SecureShellStrategy{}
hypertextTransferProtocolStrategy := &protocols.HypertextTransferProtocolStrategy{}
transmissionControlProtocolStrategy := &protocols.TransmissionControlProtocolStrategy{}
secureShellStrategy := &strategies.SecureShellStrategy{}
hypertextTransferProtocolStrategy := &strategies.HypertextTransferProtocolStrategy{}
transmissionControlProtocolStrategy := &strategies.TransmissionControlProtocolStrategy{}
// Init Tracer strategies, and set the trace strategy default HTTP
protocolManager := protocols.InitProtocolManager(b.traceStrategy, hypertextTransferProtocolStrategy)
@ -110,6 +124,7 @@ func (b *Builder) Run() error {
return errors.New(fmt.Sprintf("Error during init protocol: %s, %s", beelzebubServiceConfiguration.Protocol, err.Error()))
}
}
return nil
}
@ -117,6 +132,7 @@ func (b *Builder) build() *Builder {
return &Builder{
beelzebubServicesConfiguration: b.beelzebubServicesConfiguration,
traceStrategy: b.traceStrategy,
beelzebubCoreConfigurations: b.beelzebubCoreConfigurations,
}
}

View File

@ -5,6 +5,7 @@ import (
"beelzebub/tracer"
"context"
"encoding/json"
amqp "github.com/rabbitmq/amqp091-go"
log "github.com/sirupsen/logrus"
)
@ -21,7 +22,7 @@ func NewDirector(builder *Builder) *Director {
func (d *Director) BuildBeelzebub(beelzebubCoreConfigurations *parser.BeelzebubCoreConfigurations, beelzebubServicesConfiguration []parser.BeelzebubServiceConfiguration) (*Builder, error) {
d.builder.beelzebubServicesConfiguration = beelzebubServicesConfiguration
d.builder.beelzebubCoreConfigurations = beelzebubCoreConfigurations
if err := d.builder.buildLogger(beelzebubCoreConfigurations.Core.Logging); err != nil {
return nil, err
}

View File

@ -7,3 +7,7 @@ core:
tracing:
rabbitMQEnabled: false
rabbitMQURI: ""
prometheus:
path: "/metrics"
port: ":2112"

View File

@ -4,7 +4,7 @@ address: ":2222"
description: "SSH interactive ChatGPT"
commands:
- regex: "^(.+)$"
plugin: "OpenAIChatGPT"
plugin: "OpenAIGPTLinuxTerminal"
serverVersion: "OpenSSH"
serverName: "ubuntu"
passwordRegex: "^(root|qwerty|Smoker666|123456|jenkins|minecraft|sinus|alex|postgres|Ly123456)$"

View File

@ -8,9 +8,11 @@ services:
restart: always
ports: # Remove me, if you use configuration network_mode: host
- "22:22"
- "2222:2222"
- "8080:8080"
- "80:80"
- "3306:3306"
- "2112:2112" # Prometheus openmetrics
environment:
RABBITMQ_URI: ${RABBITMQ_URI}
volumes:

35
go.mod
View File

@ -1,15 +1,38 @@
module beelzebub
go 1.16
go 1.20
require (
github.com/gliderlabs/ssh v0.3.5
github.com/go-resty/resty/v2 v2.7.0
github.com/google/uuid v1.3.0
github.com/jarcoal/httpmock v1.2.0
github.com/rabbitmq/amqp091-go v1.5.0
github.com/sirupsen/logrus v1.9.0
github.com/stretchr/testify v1.8.1
golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d
github.com/jarcoal/httpmock v1.3.0
github.com/melbahja/goph v1.3.1
github.com/prometheus/client_golang v1.15.1
github.com/rabbitmq/amqp091-go v1.8.1
github.com/sirupsen/logrus v1.9.1
github.com/stretchr/testify v1.8.2
golang.org/x/crypto v0.9.0
gopkg.in/yaml.v3 v3.0.1
)
require (
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/sftp v1.13.5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
)

107
go.sum
View File

@ -1,5 +1,9 @@
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@ -7,79 +11,116 @@ github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY=
github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4=
github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY=
github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/jarcoal/httpmock v1.2.0 h1:gSvTxxFR/MEMfsGrvRbdfpRUMBStovlSRLw0Ep1bwwc=
github.com/jarcoal/httpmock v1.2.0/go.mod h1:oCoTsnAz4+UoOUIf5lJOWV2QQIW5UoeUI6aM2YnWAZk=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/jarcoal/httpmock v1.3.0 h1:2RJ8GP0IIaWwcC9Fp2BmVi8Kog3v2Hn7VXM3fTd+nuc=
github.com/jarcoal/httpmock v1.3.0/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg=
github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/maxatome/go-testdeep v1.11.0 h1:Tgh5efyCYyJFGUYiT0qxBSIDeXw0F5zSoatlou685kk=
github.com/maxatome/go-testdeep v1.11.0/go.mod h1:011SgQ6efzZYAen6fDn4BqQ+lUR72ysdyKe7Dyogw70=
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/maxatome/go-testdeep v1.12.0 h1:Ql7Go8Tg0C1D/uMMX59LAoYK7LffeJQ6X2T04nTH68g=
github.com/melbahja/goph v1.3.1 h1:FxFevAwCCpLkM4WBmnVVxcJBcBz6lKQpsN5biV2hA6w=
github.com/melbahja/goph v1.3.1/go.mod h1:uG+VfK2Dlhk+O32zFrRlc3kYKTlV6+BtvPWd/kK7U68=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/sftp v1.13.5 h1:a3RLUqkyjYRtBTZJZ1VRrKbN3zhuPLlUc3sphVz81go=
github.com/pkg/sftp v1.13.5/go.mod h1:wHDZ0IZX6JcBYRK1TH9bcVq8G7TLpVHYIGJRFnmPfxg=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rabbitmq/amqp091-go v1.5.0 h1:VouyHPBu1CrKyJVfteGknGOGCzmOz0zcv/tONLkb7rg=
github.com/rabbitmq/amqp091-go v1.5.0/go.mod h1:JsV0ofX5f1nwOGafb8L5rBItt9GyhfQfcJj+oyz0dGg=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/prometheus/client_golang v1.15.1 h1:8tXpTmJbyH5lydzFPoxSIJ0J46jdh3tylbvM1xCv0LI=
github.com/prometheus/client_golang v1.15.1/go.mod h1:e9yaBhRPU2pPNsZwE+JdQl0KEt1N9XgF6zxWmaC0xOk=
github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4=
github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM=
github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc=
github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI=
github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY=
github.com/rabbitmq/amqp091-go v1.8.1 h1:RejT1SBUim5doqcL6s7iN6SBmsQqyTgXb1xMlH0h1hA=
github.com/rabbitmq/amqp091-go v1.8.1/go.mod h1:+jPrT9iY2eLjRaMSRHUhc3z14E/l85kv/f+6luSD3pc=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/sirupsen/logrus v1.9.1 h1:Ou41VVR3nMWWmTiEUnj0OlsgOSCUFgsPAOl6jRIcVtQ=
github.com/sirupsen/logrus v1.9.1/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA=
go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d h1:3qF+Z8Hkrw9sOhrFHti9TlB1Hkac1x+DNRkv0XQiFjo=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b h1:ZmngSVLe/wycRns9MKikG9OWIEjGcGAkacif7oYQaUY=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64 h1:UiNENfZ8gDvpiWw7IpOMQ27spWmThO1RwwdQVbJahJM=
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 h1:Q5284mrmYTpACcm+eAKjKJH48BBwSyfJqmmGDTtT8Vc=
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -0,0 +1,12 @@
core:
logging:
debug: false
debugReportCaller: false
logDisableTimestamp: true
logsPath: ./logs
tracing:
rabbitMQEnabled: true
rabbitMQURI: "amqp://integration:integration@localhost:5672/"
prometheus:
path: "/metrics"
port: ":2112"

View File

@ -0,0 +1,19 @@
apiVersion: "v1"
protocol: "http"
address: ":8080"
description: "Wordpress 6.0"
commands:
- regex: "index.php"
handler: "mocked response"
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: "mocked response"
headers:
- "Content-Type: text/html"
- "Server: Apache/2.4.53 (Debian)"
- "X-Powered-By: PHP/7.4.29"
statusCode: 400

View File

@ -0,0 +1,25 @@
apiVersion: "v1"
protocol: "ssh"
address: ":2222"
description: "SSH interactive"
commands:
- regex: "^ls$"
handler: "Documents Images Desktop Downloads .m2 .kube .ssh .docker"
- regex: "^pwd$"
handler: "/home/"
- regex: "^uname -m$"
handler: "x86_64"
- regex: "^docker ps$"
handler: "CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES"
- regex: "^docker .*$"
handler: "Error response from daemon: dial unix docker.raw.sock: connect: connection refused"
- regex: "^uname$"
handler: "Linux"
- regex: "^ps$"
handler: " PID TTY TIME CMD\n21642 ttys000 0:00.07 /bin/dockerd"
- regex: "^(.+)$"
handler: "command not found"
serverVersion: "OpenSSH"
serverName: "ubuntu"
passwordRegex: "^(root|qwerty|Smoker666|123456|jenkins|minecraft|sinus|alex|postgres|Ly123456)$"
deadlineTimeoutSeconds: 60

View File

@ -0,0 +1,6 @@
apiVersion: "v1"
protocol: "tcp"
address: ":3306"
description: "Mysql 8.0.29"
banner: "8.0.29"
deadlineTimeoutSeconds: 10

View File

@ -0,0 +1,10 @@
version: "3.9"
services:
rabbitmq:
image: rabbitmq:3-alpine
container_name: 'rabbitmq'
ports:
- 5672:5672
environment:
- RABBITMQ_DEFAULT_USER=integration
- RABBITMQ_DEFAULT_PASS=integration

View File

@ -0,0 +1,163 @@
package integration
import (
"beelzebub/builder"
"beelzebub/parser"
"beelzebub/tracer"
"encoding/json"
"net"
"net/http"
"os"
"testing"
"github.com/go-resty/resty/v2"
"github.com/melbahja/goph"
amqp "github.com/rabbitmq/amqp091-go"
"github.com/stretchr/testify/suite"
"golang.org/x/crypto/ssh"
)
type IntegrationTestSuite struct {
suite.Suite
beelzebubBuilder *builder.Builder
prometheusHost string
httpHoneypotHost string
tcpHoneypotHost string
sshHoneypotHost string
rabbitMQURI string
}
func TestIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(IntegrationTestSuite))
}
func (suite *IntegrationTestSuite) SetupSuite() {
suite.T().Helper()
if os.Getenv("INTEGRATION") == "" {
suite.T().Skip("skipping integration tests, set environment variable INTEGRATION")
}
suite.httpHoneypotHost = "http://localhost:8080"
suite.tcpHoneypotHost = "localhost:3306"
suite.sshHoneypotHost = "localhost"
suite.prometheusHost = "http://localhost:2112/metrics"
beelzebubConfigPath := "./configurations/beelzebub.yaml"
servicesConfigDirectory := "./configurations/services/"
parser := parser.Init(beelzebubConfigPath, servicesConfigDirectory)
coreConfigurations, err := parser.ReadConfigurationsCore()
suite.Require().NoError(err)
suite.rabbitMQURI = coreConfigurations.Core.Tracing.RabbitMQURI
beelzebubServicesConfiguration, err := parser.ReadConfigurationsServices()
suite.Require().NoError(err)
suite.beelzebubBuilder = builder.NewBuilder()
director := builder.NewDirector(suite.beelzebubBuilder)
suite.beelzebubBuilder, err = director.BuildBeelzebub(coreConfigurations, beelzebubServicesConfiguration)
suite.Require().NoError(err)
suite.Require().NoError(suite.beelzebubBuilder.Run())
}
func (suite *IntegrationTestSuite) TestInvokeHTTPHoneypot() {
response, err := resty.New().R().
Get(suite.httpHoneypotHost + "/index.php")
suite.Require().NoError(err)
suite.Equal(http.StatusOK, response.StatusCode())
suite.Equal("mocked response", string(response.Body()))
response, err = resty.New().R().
Get(suite.httpHoneypotHost + "/wp-admin")
suite.Require().NoError(err)
suite.Equal(http.StatusBadRequest, response.StatusCode())
suite.Equal("mocked response", string(response.Body()))
}
func (suite *IntegrationTestSuite) TestInvokeTCPHoneypot() {
tcpAddr, err := net.ResolveTCPAddr("tcp", suite.tcpHoneypotHost)
suite.Require().NoError(err)
conn, err := net.DialTCP("tcp", nil, tcpAddr)
suite.Require().NoError(err)
defer conn.Close()
_, err = conn.Write([]byte("hello!"))
suite.Require().NoError(err)
reply := make([]byte, 1024)
n, err := conn.Read(reply)
suite.Require().NoError(err)
suite.Equal("8.0.29\n", string(reply[:n]))
}
func (suite *IntegrationTestSuite) TestInvokeSSHHoneypot() {
client, err := goph.NewConn(
&goph.Config{
User: "root",
Addr: suite.sshHoneypotHost,
Port: 2222,
Auth: goph.Password("root"),
Callback: ssh.InsecureIgnoreHostKey(),
})
suite.Require().NoError(err)
defer client.Close()
out, err := client.Run("")
suite.Require().NoError(err)
suite.Equal("root@ubuntu:~$ ", string(out))
}
func (suite *IntegrationTestSuite) TestRabbitMQ() {
conn, err := amqp.Dial(suite.rabbitMQURI)
suite.Require().NoError(err)
defer conn.Close()
ch, err := conn.Channel()
suite.Require().NoError(err)
defer ch.Close()
msgs, err := ch.Consume("event", "", true, false, false, false, nil)
suite.Require().NoError(err)
//Invoke HTTP Honeypot
response, err := resty.New().R().Get(suite.httpHoneypotHost + "/index.php")
suite.Require().NoError(err)
suite.Equal(http.StatusOK, response.StatusCode())
for msg := range msgs {
var event tracer.Event
err := json.Unmarshal(msg.Body, &event)
suite.Require().NoError(err)
suite.Equal("GET", event.HTTPMethod)
suite.Equal("/index.php", event.RequestURI)
break
}
}
func (suite *IntegrationTestSuite) TestPrometheus() {
//Invoke HTTP Honeypot
response, err := resty.New().R().Get(suite.httpHoneypotHost + "/index.php")
suite.Require().NoError(err)
suite.Equal(http.StatusOK, response.StatusCode())
response, err = resty.New().R().Get(suite.prometheusHost)
suite.Require().NoError(err)
suite.Equal(http.StatusOK, response.StatusCode())
}
func (suite *IntegrationTestSuite) TestShutdownBeelzebub() {
suite.Require().NoError(suite.beelzebubBuilder.Close())
}

View File

@ -2,17 +2,19 @@ package parser
import (
"fmt"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"
"io/ioutil"
"os"
"path/filepath"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"
)
type BeelzebubCoreConfigurations struct {
Core struct {
Logging Logging `yaml:"logging"`
Tracing Tracing `yaml:"tracing"`
Logging Logging `yaml:"logging"`
Tracing Tracing `yaml:"tracing"`
Prometheus Prometheus `yaml:"prometheus"`
}
}
@ -28,6 +30,11 @@ type Tracing struct {
RabbitMQURI string `yaml:"rabbitMQURI"`
}
type Prometheus struct {
Path string `yaml:"path"`
Port string `yaml:"port"`
}
type Plugin struct {
OpenAPIChatGPTSecretKey string `yaml:"openAPIChatGPTSecretKey"`
}

View File

@ -1,4 +1,4 @@
package plugin
package plugins
import (
"encoding/json"
@ -8,7 +8,7 @@ import (
"strings"
)
const ChatGPTPluginName = "OpenAIChatGPT"
const ChatGPTPluginName = "OpenAIGPTLinuxTerminal"
const openAIGPTEndpoint = "https://api.openai.com/v1/completions"
type History struct {
@ -58,13 +58,13 @@ type gptRequest struct {
Stop []string `json:"stop"`
}
//Reference: https://www.engraved.blog/building-a-virtual-machine-inside/
const chatGPTFirstQuestion = "I want you to act as a Linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. Do no write explanations. Do not type commands unless I instruct you to do so.\n\nA:pwd\n\nQ:/home/user\n\n"
// Reference: https://www.engraved.blog/building-a-virtual-machine-inside/
const promptVirtualizeLinuxTerminal = "I want you to act as a Linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. Do no write explanations. Do not type commands unless I instruct you to do so.\n\nA:pwd\n\nQ:/home/user\n\n"
func buildPrompt(histories []History, command string) string {
var sb strings.Builder
sb.WriteString(chatGPTFirstQuestion)
sb.WriteString(promptVirtualizeLinuxTerminal)
for _, history := range histories {
sb.WriteString(fmt.Sprintf("A:%s\n\nQ:%s\n\n", history.Input, history.Output))

View File

@ -1,4 +1,4 @@
package plugin
package plugins
import (
"github.com/go-resty/resty/v2"

View File

@ -1,4 +1,4 @@
package protocols
package strategies
import (
"beelzebub/parser"

View File

@ -1,17 +1,18 @@
package protocols
package strategies
import (
"beelzebub/parser"
"beelzebub/plugin"
"beelzebub/plugins"
"beelzebub/tracer"
"fmt"
"regexp"
"strings"
"time"
"github.com/gliderlabs/ssh"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
"golang.org/x/crypto/ssh/terminal"
"regexp"
"strings"
"time"
)
type SecureShellStrategy struct {
@ -40,21 +41,13 @@ func (SSHStrategy *SecureShellStrategy) Init(beelzebubServiceConfiguration parse
})
term := terminal.NewTerminal(sess, buildPrompt(sess.User(), beelzebubServiceConfiguration.ServerName))
var histories []plugin.History
var histories []plugins.History
for {
commandInput, err := term.ReadLine()
if err != nil {
break
}
tr.TraceEvent(tracer.Event{
Msg: "New SSH Terminal Session",
RemoteAddr: sess.RemoteAddr().String(),
Status: tracer.Interaction.String(),
Command: commandInput,
ID: uuidSession.String(),
Protocol: tracer.SSH.String(),
Description: beelzebubServiceConfiguration.Description,
})
if commandInput == "exit" {
break
}
@ -68,8 +61,8 @@ func (SSHStrategy *SecureShellStrategy) Init(beelzebubServiceConfiguration parse
if matched {
commandOutput := command.Handler
if command.Plugin == plugin.ChatGPTPluginName {
openAIGPTVirtualTerminal := plugin.OpenAIGPTVirtualTerminal{Histories: histories, OpenAPIChatGPTSecretKey: beelzebubServiceConfiguration.Plugin.OpenAPIChatGPTSecretKey}
if command.Plugin == plugins.ChatGPTPluginName {
openAIGPTVirtualTerminal := plugins.OpenAIGPTVirtualTerminal{Histories: histories, OpenAPIChatGPTSecretKey: beelzebubServiceConfiguration.Plugin.OpenAPIChatGPTSecretKey}
openAIGPTVirtualTerminal.InjectDependency()
if commandOutput, err = openAIGPTVirtualTerminal.GetCompletions(commandInput); err != nil {
@ -78,9 +71,20 @@ func (SSHStrategy *SecureShellStrategy) Init(beelzebubServiceConfiguration parse
}
}
histories = append(histories, plugin.History{Input: commandInput, Output: commandOutput})
histories = append(histories, plugins.History{Input: commandInput, Output: commandOutput})
term.Write(append([]byte(commandOutput), '\n'))
tr.TraceEvent(tracer.Event{
Msg: "New SSH Terminal Session",
RemoteAddr: sess.RemoteAddr().String(),
Status: tracer.Interaction.String(),
Command: commandInput,
CommandOutput: commandOutput,
ID: uuidSession.String(),
Protocol: tracer.SSH.String(),
Description: beelzebubServiceConfiguration.Description,
})
break
}
}

View File

@ -1,4 +1,4 @@
package protocols
package strategies
import (
"beelzebub/parser"

17
pull_request_template.md Normal file
View File

@ -0,0 +1,17 @@
All Submissions:
* [ ] Have you followed the guidelines in our Contributing document?
* [ ] Have you checked to ensure there aren't other open [Pull Requests](../../pulls) for the same update/change?
<!-- You can erase any parts of this template not applicable to your Pull Request. -->
### New Feature Submissions:
1. [ ] Does your submission pass tests?
2. [ ] Have you lint your code locally before submission?
### Changes to Core Features:
* [ ] Have you added an explanation of what your changes do and why you'd like us to include them?
* [ ] Have you written new tests for your core changes, as applicable?
* [ ] Have you successfully run tests with your changes locally?

View File

@ -2,34 +2,17 @@ package tracer
import (
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
type Strategy func(event Event)
type Tracer interface {
TraceEvent(event Event)
}
type tracer struct {
strategy Strategy
}
func Init(strategy Strategy) *tracer {
return &tracer{
strategy: strategy,
}
}
func (tracer *tracer) TraceEvent(event Event) {
event.DateTime = time.Now().UTC().Format(time.RFC3339)
tracer.strategy(event)
}
type Event struct {
DateTime string
RemoteAddr string
Protocol string
Command string
CommandOutput string
Status string
Msg string
ID string
@ -71,3 +54,63 @@ const (
func (status Status) String() string {
return [...]string{"Start", "End", "Stateless", "Interaction"}[status]
}
type Strategy func(event Event)
type Tracer interface {
TraceEvent(event Event)
}
type tracer struct {
strategy Strategy
}
var (
eventsTotal = promauto.NewCounter(prometheus.CounterOpts{
Namespace: "beelzebub",
Name: "events_total",
Help: "The total number of events",
})
eventsSSHTotal = promauto.NewCounter(prometheus.CounterOpts{
Namespace: "beelzebub",
Name: "ssh_events_total",
Help: "The total number of SSH events",
})
eventsTCPTotal = promauto.NewCounter(prometheus.CounterOpts{
Namespace: "beelzebub",
Name: "tcp_events_total",
Help: "The total number of TCP events",
})
eventsHTTPTotal = promauto.NewCounter(prometheus.CounterOpts{
Namespace: "beelzebub",
Name: "http_events_total",
Help: "The total number of HTTP events",
})
)
func Init(strategy Strategy) *tracer {
return &tracer{
strategy: strategy,
}
}
func (tracer *tracer) TraceEvent(event Event) {
event.DateTime = time.Now().UTC().Format(time.RFC3339)
tracer.strategy(event)
//Openmetrics
eventsTotal.Inc()
switch event.Protocol {
case HTTP.String():
eventsHTTPTotal.Inc()
break
case SSH.String():
eventsSSHTotal.Inc()
break
case TCP.String():
eventsTCPTotal.Inc()
break
}
}