Skip to content

Commit

Permalink
Fix handling of -o with FileFormat and Local
Browse files Browse the repository at this point in the history
  • Loading branch information
j-baines committed Jul 29, 2024
1 parent b26ced4 commit a454499
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions cli/commandline.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,14 @@ func dbFlags(conf *config.Config) {

// handle generic sounding c2 flags.
func c2Flags(c2Selection *string, conf *config.Config) {

flag.BoolVar(&conf.ThirdPartyC2Server, "o", false, "Indicates if the reverse shell should be caught by an outside program (nc, openssl)")

if len(conf.SupportedC2) == 0 {
// the implementing exploit doesn't support any c2, just exit
return
}

c2Default, _ := c2.ImplToString(conf.SupportedC2[0])
c2Available := "The C2 server implementation to use. Supported: "
for _, value := range conf.SupportedC2 {
Expand All @@ -437,15 +445,13 @@ func c2Flags(c2Selection *string, conf *config.Config) {
} else {
flag.IntVar(&conf.C2Timeout, "t", 30, "The number of seconds to listen for reverse shells.")
}

flag.BoolVar(&conf.ThirdPartyC2Server, "o", false, "Indicates if the reverse shell should be caught by an outside program (nc, openssl)")
}

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

return false
}
Expand Down Expand Up @@ -679,7 +685,9 @@ func FormatFileCmdLineParse(conf *config.Config) bool {

return false
}
if !validateC2Selection(c2Selection, conf) {

// must be validate (to set default for payload gen) and then check third party c2
if validateC2Selection(c2Selection, conf) && !conf.ThirdPartyC2Server {
return false
}
if !conf.ThirdPartyC2Server && (conf.Lport == 0 || len(conf.Lhost) == 0) {
Expand Down Expand Up @@ -715,7 +723,8 @@ func LocalCmdLineParse(conf *config.Config) bool {
}
flag.Parse()

if !validateC2Selection(c2Selection, conf) {
// must be validate (to set default for payload gen) and then check third party c2
if validateC2Selection(c2Selection, conf) && !conf.ThirdPartyC2Server {
return false
}

Expand Down

0 comments on commit a454499

Please sign in to comment.