mirror of
https://github.com/mariocandela/beelzebub.git
synced 2025-07-01 18:47:26 -04:00
feat: Trace command output for SSH Strategy (#35)
manage command output SSH strategy
This commit is contained in:
@ -5,13 +5,14 @@ import (
|
|||||||
"beelzebub/plugins"
|
"beelzebub/plugins"
|
||||||
"beelzebub/tracer"
|
"beelzebub/tracer"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/gliderlabs/ssh"
|
"github.com/gliderlabs/ssh"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
"regexp"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type SecureShellStrategy struct {
|
type SecureShellStrategy struct {
|
||||||
@ -46,15 +47,7 @@ func (SSHStrategy *SecureShellStrategy) Init(beelzebubServiceConfiguration parse
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
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" {
|
if commandInput == "exit" {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -81,6 +74,17 @@ func (SSHStrategy *SecureShellStrategy) Init(beelzebubServiceConfiguration parse
|
|||||||
histories = append(histories, plugins.History{Input: commandInput, Output: commandOutput})
|
histories = append(histories, plugins.History{Input: commandInput, Output: commandOutput})
|
||||||
|
|
||||||
term.Write(append([]byte(commandOutput), '\n'))
|
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
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ type Event struct {
|
|||||||
RemoteAddr string
|
RemoteAddr string
|
||||||
Protocol string
|
Protocol string
|
||||||
Command string
|
Command string
|
||||||
|
CommandOutput string
|
||||||
Status string
|
Status string
|
||||||
Msg string
|
Msg string
|
||||||
ID string
|
ID string
|
||||||
|
Reference in New Issue
Block a user