feat: Trace command output for SSH Strategy (#35)

manage command output SSH strategy
This commit is contained in:
Mario Candela
2023-04-14 22:35:11 +02:00
committed by GitHub
parent fe6d95ecd6
commit 49a4022f56
2 changed files with 17 additions and 12 deletions

View File

@ -5,13 +5,14 @@ import (
"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 {
@ -46,15 +47,7 @@ func (SSHStrategy *SecureShellStrategy) Init(beelzebubServiceConfiguration parse
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
}
@ -81,6 +74,17 @@ func (SSHStrategy *SecureShellStrategy) Init(beelzebubServiceConfiguration parse
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
}
}