Skip to content

Commit a454499

Browse files
committed
Fix handling of -o with FileFormat and Local
1 parent b26ced4 commit a454499

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

cli/commandline.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,14 @@ func dbFlags(conf *config.Config) {
411411

412412
// handle generic sounding c2 flags.
413413
func c2Flags(c2Selection *string, conf *config.Config) {
414+
415+
flag.BoolVar(&conf.ThirdPartyC2Server, "o", false, "Indicates if the reverse shell should be caught by an outside program (nc, openssl)")
416+
417+
if len(conf.SupportedC2) == 0 {
418+
// the implementing exploit doesn't support any c2, just exit
419+
return
420+
}
421+
414422
c2Default, _ := c2.ImplToString(conf.SupportedC2[0])
415423
c2Available := "The C2 server implementation to use. Supported: "
416424
for _, value := range conf.SupportedC2 {
@@ -437,15 +445,13 @@ func c2Flags(c2Selection *string, conf *config.Config) {
437445
} else {
438446
flag.IntVar(&conf.C2Timeout, "t", 30, "The number of seconds to listen for reverse shells.")
439447
}
440-
441-
flag.BoolVar(&conf.ThirdPartyC2Server, "o", false, "Indicates if the reverse shell should be caught by an outside program (nc, openssl)")
442448
}
443449

444450
// loop through the c2 the exploit supports and find the one the user actually selected.
445451
func validateC2Selection(c2Selection string, conf *config.Config) bool {
446452
c2Selected, ok := c2.StringToImpl(c2Selection)
447453
if !ok {
448-
output.PrintFrameworkError("Provided an invalid c2 implementation")
454+
output.PrintFrameworkError("The user provided an invalid c2 implementation")
449455

450456
return false
451457
}
@@ -679,7 +685,9 @@ func FormatFileCmdLineParse(conf *config.Config) bool {
679685

680686
return false
681687
}
682-
if !validateC2Selection(c2Selection, conf) {
688+
689+
// must be validate (to set default for payload gen) and then check third party c2
690+
if validateC2Selection(c2Selection, conf) && !conf.ThirdPartyC2Server {
683691
return false
684692
}
685693
if !conf.ThirdPartyC2Server && (conf.Lport == 0 || len(conf.Lhost) == 0) {
@@ -715,7 +723,8 @@ func LocalCmdLineParse(conf *config.Config) bool {
715723
}
716724
flag.Parse()
717725

718-
if !validateC2Selection(c2Selection, conf) {
726+
// must be validate (to set default for payload gen) and then check third party c2
727+
if validateC2Selection(c2Selection, conf) && !conf.ThirdPartyC2Server {
719728
return false
720729
}
721730

0 commit comments

Comments
 (0)