Skip to content

Updates to C2 Handling New Exploit Types #202

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

Merged
merged 2 commits into from
Jul 29, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 3 additions & 1 deletion framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import (
"sync"
"time"

"github.com/vulncheck-oss/go-exploit"
"github.com/vulncheck-oss/go-exploit/c2"
"github.com/vulncheck-oss/go-exploit/cli"
"github.com/vulncheck-oss/go-exploit/config"
Expand Down Expand Up @@ -275,7 +276,8 @@ func parseCommandLine(conf *config.Config) bool {
}

func startC2Server(conf *config.Config) bool {
if conf.DoExploit && !conf.ThirdPartyC2Server && conf.Bport == 0 {
if conf.DoExploit && !conf.ThirdPartyC2Server && conf.Bport == 0 &&
(conf.ExType != exploit.InformationDisclosure && conf.ExType != exploit.Webshell) {
c2Impl, success := c2.GetInstance(conf.C2Type)
if !success || c2Impl == nil {
return false
Expand Down
Loading