mirror of
https://github.com/mariocandela/beelzebub.git
synced 2025-07-01 18:47:26 -04:00
Improve initial TCP honeypot structure
This commit is contained in:
@ -5,5 +5,5 @@ core:
|
|||||||
logDisableTimestamp: true
|
logDisableTimestamp: true
|
||||||
logsPath: ./logs
|
logsPath: ./logs
|
||||||
tracing:
|
tracing:
|
||||||
rabbitMQEnabled: true
|
rabbitMQEnabled: false
|
||||||
rabbitMQURI: "amqp://beelzebub:b33lz3b4b@localhost:8888/"
|
rabbitMQURI: ""
|
||||||
|
@ -2,6 +2,5 @@ apiVersion: "v1"
|
|||||||
protocol: "tcp"
|
protocol: "tcp"
|
||||||
address: ":3306"
|
address: ":3306"
|
||||||
description: "Mysql"
|
description: "Mysql"
|
||||||
commands:
|
banner: "mysql 4.0"
|
||||||
- regex: "hello"
|
deadlineTimeoutSeconds: 60
|
||||||
handler: "WORLD"
|
|
@ -38,6 +38,7 @@ type BeelzebubServiceConfiguration struct {
|
|||||||
DeadlineTimeoutSeconds int `yaml:"deadlineTimeoutSeconds"`
|
DeadlineTimeoutSeconds int `yaml:"deadlineTimeoutSeconds"`
|
||||||
PasswordRegex string `yaml:"passwordRegex"`
|
PasswordRegex string `yaml:"passwordRegex"`
|
||||||
Description string `yaml:"description"`
|
Description string `yaml:"description"`
|
||||||
|
Banner string `yaml:"banner"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Command struct {
|
type Command struct {
|
||||||
|
49
protocols/transmissionControlProtocolStrategy.go
Normal file
49
protocols/transmissionControlProtocolStrategy.go
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package protocols
|
||||||
|
|
||||||
|
import (
|
||||||
|
"beelzebub/parser"
|
||||||
|
"beelzebub/tracer"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"net"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TransmissionControlProtocolStrategy struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (TCPStrategy *TransmissionControlProtocolStrategy) Init(beelzebubServiceConfiguration parser.BeelzebubServiceConfiguration, tr tracer.Tracer) error {
|
||||||
|
listen, err := net.Listen("TCP", beelzebubServiceConfiguration.Address)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Error during init TCP Protocol: %s", err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer listen.Close()
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
if conn, err := listen.Accept(); err == nil {
|
||||||
|
conn.SetDeadline(time.Now().Add(time.Duration(beelzebubServiceConfiguration.DeadlineTimeoutSeconds) * time.Second))
|
||||||
|
go handleIncomingRequest(conn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"port": beelzebubServiceConfiguration.Address,
|
||||||
|
"banner": beelzebubServiceConfiguration.Banner,
|
||||||
|
}).Infof("Init service %s", beelzebubServiceConfiguration.Protocol)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleIncomingRequest(conn net.Conn) {
|
||||||
|
buffer := make([]byte, 1024)
|
||||||
|
_, err := conn.Read(buffer)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
// respond
|
||||||
|
conn.Write([]byte("Hi back!\n"))
|
||||||
|
|
||||||
|
// close conn
|
||||||
|
conn.Close()
|
||||||
|
}
|
Reference in New Issue
Block a user