Skip to content

Commit e6645c9

Browse files
committed
Added file path for debug so it doesn't always goto stdout
1 parent 7d95856 commit e6645c9

File tree

7 files changed

+566
-537
lines changed

7 files changed

+566
-537
lines changed

client/command/commands.go

+4
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,7 @@ func BindCommands(con *console.SliverConsoleClient) {
13241324
f.String("a", "arch", "amd64", "cpu architecture")
13251325
f.String("N", "name", "", "agent name")
13261326
f.Bool("d", "debug", false, "enable debug features")
1327+
f.String("O", "debug-file", "", "path to debug output")
13271328
f.Bool("e", "evasion", false, "enable evasion features (e.g. overwrite user space hooks)")
13281329
f.Bool("l", "skip-symbols", false, "skip symbol obfuscation")
13291330
f.String("I", "template", "sliver", "implant code template")
@@ -1385,6 +1386,7 @@ func BindCommands(con *console.SliverConsoleClient) {
13851386
f.String("a", "arch", "amd64", "cpu architecture")
13861387
f.String("N", "name", "", "agent name")
13871388
f.Bool("d", "debug", false, "enable debug features")
1389+
f.String("O", "debug-file", "", "path to debug output")
13881390
f.Bool("e", "evasion", false, "enable evasion features (e.g. overwrite user space hooks)")
13891391
f.Bool("l", "skip-symbols", false, "skip symbol obfuscation")
13901392
f.String("I", "template", "sliver", "implant code template")
@@ -1541,6 +1543,7 @@ func BindCommands(con *console.SliverConsoleClient) {
15411543
f.String("a", "arch", "amd64", "cpu architecture")
15421544

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

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

client/command/generate/generate.go

+3
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ func parseCompileFlags(ctx *grumble.Context, con *console.SliverConsoleClient) *
272272
limitDatetime := ctx.Flags.String("limit-datetime")
273273
limitFileExists := ctx.Flags.String("limit-fileexists")
274274
limitLocale := ctx.Flags.String("limit-locale")
275+
debugFile := ctx.Flags.String("debug-file")
275276

276277
isSharedLib := false
277278
isService := false
@@ -369,6 +370,8 @@ func parseCompileFlags(ctx *grumble.Context, con *console.SliverConsoleClient) *
369370
IsShellcode: isShellcode,
370371

371372
RunAtLoad: runAtLoad,
373+
374+
DebugFile: debugFile,
372375
}
373376

374377
return config

implant/sliver/sliver.go

+8
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ func main() {
162162

163163
// {{if .Config.Debug}}
164164
log.SetFlags(log.LstdFlags | log.Lshortfile)
165+
debugFilePath := "{{ .Config.DebugFile }}"
166+
if debugFilePath != "" {
167+
// Open the log file for writing
168+
file, err := os.OpenFile(debugFilePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
169+
if err == nil {
170+
log.SetOutput(file)
171+
}
172+
}
165173
// {{else}}
166174
log.SetFlags(0)
167175
log.SetOutput(ioutil.Discard)

protobuf/clientpb/client.pb.go

+547-537
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protobuf/clientpb/client.proto

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ message ImplantConfig {
171171
bool IsShellcode = 104;
172172

173173
bool RunAtLoad = 105;
174+
string DebugFile = 106;
174175
}
175176

176177
message ExternalImplantConfig {

server/db/models/implant.go

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ type ImplantConfig struct {
8787
MtlsKey string
8888

8989
Debug bool
90+
DebugFile string
9091
Evasion bool
9192
ObfuscateSymbols bool
9293
ReconnectInterval int64
@@ -159,6 +160,7 @@ func (ic *ImplantConfig) ToProtobuf() *clientpb.ImplantConfig {
159160
MtlsKey: ic.MtlsKey,
160161

161162
Debug: ic.Debug,
163+
DebugFile: ic.DebugFile,
162164
Evasion: ic.Evasion,
163165
ObfuscateSymbols: ic.ObfuscateSymbols,
164166
TemplateName: ic.TemplateName,

server/generate/binaries.go

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ func ImplantConfigFromProtobuf(pbConfig *clientpb.ImplantConfig) (string, *model
148148
cfg.MtlsCert = pbConfig.MtlsCert
149149
cfg.MtlsKey = pbConfig.MtlsKey
150150
cfg.Debug = pbConfig.Debug
151+
cfg.DebugFile = pbConfig.DebugFile
151152
cfg.Evasion = pbConfig.Evasion
152153
cfg.ObfuscateSymbols = pbConfig.ObfuscateSymbols
153154
cfg.TemplateName = pbConfig.TemplateName

0 commit comments

Comments
 (0)