Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added file path for debug so it doesn't always goto stdout #1175

Merged
merged 1 commit into from
Mar 30, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions client/command/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,7 @@ func BindCommands(con *console.SliverConsoleClient) {
f.String("a", "arch", "amd64", "cpu architecture")
f.String("N", "name", "", "agent name")
f.Bool("d", "debug", false, "enable debug features")
f.String("O", "debug-file", "", "path to debug output")
f.Bool("e", "evasion", false, "enable evasion features (e.g. overwrite user space hooks)")
f.Bool("l", "skip-symbols", false, "skip symbol obfuscation")
f.String("I", "template", "sliver", "implant code template")
Expand Down Expand Up @@ -1385,6 +1386,7 @@ func BindCommands(con *console.SliverConsoleClient) {
f.String("a", "arch", "amd64", "cpu architecture")
f.String("N", "name", "", "agent name")
f.Bool("d", "debug", false, "enable debug features")
f.String("O", "debug-file", "", "path to debug output")
f.Bool("e", "evasion", false, "enable evasion features (e.g. overwrite user space hooks)")
f.Bool("l", "skip-symbols", false, "skip symbol obfuscation")
f.String("I", "template", "sliver", "implant code template")
Expand Down Expand Up @@ -1541,6 +1543,7 @@ func BindCommands(con *console.SliverConsoleClient) {
f.String("a", "arch", "amd64", "cpu architecture")

f.Bool("d", "debug", false, "enable debug features")
f.String("O", "debug-file", "", "path to debug output")
f.Bool("e", "evasion", false, "enable evasion features")
f.Bool("l", "skip-symbols", false, "skip symbol obfuscation")
f.Bool("G", "disable-sgn", false, "disable shikata ga nai shellcode encoder")
Expand Down Expand Up @@ -1609,6 +1612,7 @@ func BindCommands(con *console.SliverConsoleClient) {
f.String("a", "arch", "amd64", "cpu architecture")

f.Bool("d", "debug", false, "enable debug features")
f.String("O", "debug-file", "", "path to debug output")
f.Bool("e", "evasion", false, "enable evasion features")
f.Bool("l", "skip-symbols", false, "skip symbol obfuscation")

Expand Down
3 changes: 3 additions & 0 deletions client/command/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ func parseCompileFlags(ctx *grumble.Context, con *console.SliverConsoleClient) *
limitDatetime := ctx.Flags.String("limit-datetime")
limitFileExists := ctx.Flags.String("limit-fileexists")
limitLocale := ctx.Flags.String("limit-locale")
debugFile := ctx.Flags.String("debug-file")

isSharedLib := false
isService := false
Expand Down Expand Up @@ -369,6 +370,8 @@ func parseCompileFlags(ctx *grumble.Context, con *console.SliverConsoleClient) *
IsShellcode: isShellcode,

RunAtLoad: runAtLoad,

DebugFile: debugFile,
}

return config
Expand Down
8 changes: 8 additions & 0 deletions implant/sliver/sliver.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ func main() {

// {{if .Config.Debug}}
log.SetFlags(log.LstdFlags | log.Lshortfile)
debugFilePath := "{{ .Config.DebugFile }}"
if debugFilePath != "" {
// Open the log file for writing
file, err := os.OpenFile(debugFilePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err == nil {
log.SetOutput(file)
}
}
// {{else}}
log.SetFlags(0)
log.SetOutput(ioutil.Discard)
Expand Down
1,084 changes: 547 additions & 537 deletions protobuf/clientpb/client.pb.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions protobuf/clientpb/client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ message ImplantConfig {
bool IsShellcode = 104;

bool RunAtLoad = 105;
string DebugFile = 106;
}

message ExternalImplantConfig {
Expand Down
2 changes: 2 additions & 0 deletions server/db/models/implant.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ type ImplantConfig struct {
MtlsKey string

Debug bool
DebugFile string
Evasion bool
ObfuscateSymbols bool
ReconnectInterval int64
Expand Down Expand Up @@ -159,6 +160,7 @@ func (ic *ImplantConfig) ToProtobuf() *clientpb.ImplantConfig {
MtlsKey: ic.MtlsKey,

Debug: ic.Debug,
DebugFile: ic.DebugFile,
Evasion: ic.Evasion,
ObfuscateSymbols: ic.ObfuscateSymbols,
TemplateName: ic.TemplateName,
Expand Down
1 change: 1 addition & 0 deletions server/generate/binaries.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func ImplantConfigFromProtobuf(pbConfig *clientpb.ImplantConfig) (string, *model
cfg.MtlsCert = pbConfig.MtlsCert
cfg.MtlsKey = pbConfig.MtlsKey
cfg.Debug = pbConfig.Debug
cfg.DebugFile = pbConfig.DebugFile
cfg.Evasion = pbConfig.Evasion
cfg.ObfuscateSymbols = pbConfig.ObfuscateSymbols
cfg.TemplateName = pbConfig.TemplateName
Expand Down