Skip to content

Commit 95496b6

Browse files
authoredJan 30, 2025
Allow for manual triggering of C2 startup (#300)
* Allow for manual triggering of C2 startup * Add DisableC2Start details as why you would want to use it
1 parent fa82ee3 commit 95496b6

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed
 

‎config/config.go

+14
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ type Config struct {
9898
DoVersionCheck bool
9999
// indicates if we run the exploit
100100
DoExploit bool
101+
// automatically start the c2 or not
102+
C2AutoStart bool
101103
// the user requested c2 to use
102104
C2Type c2.Impl
103105
// C2 server timeout
@@ -171,6 +173,7 @@ func NewRemoteExploit(implemented ImplementedFeatures, extype ExploitType, suppo
171173
newConf.Vendor = vendor
172174
newConf.Products = product
173175
newConf.Product = fmt.Sprintf("%s %s", vendor, strings.Join(product, "/"))
176+
newConf.C2AutoStart = true
174177
newConf.CPE = cpe
175178
newConf.CVE = cve
176179
newConf.Protocol = protocol
@@ -191,6 +194,7 @@ func NewLocalExploit(implemented ImplementedFeatures, extype ExploitType, suppor
191194
newConf.Vendor = vendor
192195
newConf.Products = product
193196
newConf.Product = fmt.Sprintf("%s %s", vendor, strings.Join(product, "/"))
197+
newConf.C2AutoStart = true
194198
newConf.CPE = cpe
195199
newConf.CVE = cve
196200

@@ -312,6 +316,16 @@ func (conf *Config) GetBoolFlag(name string) bool {
312316
return *value
313317
}
314318

319+
// Disable automatic start of c2 servers. Manually starting is required after
320+
// this function is called. This is useful when you have an exploit that
321+
// may have multiple stages and you are guaranteed to not need the C2
322+
// setup. An example is an exploit that needs to retrieve a CAPTCHA may not
323+
// want to start up the C2 until the first stage is retrieved and the
324+
// CAPTCHA is solved.
325+
func (conf *Config) DisableC2Start() {
326+
conf.C2AutoStart = false
327+
}
328+
315329
// Some C2 (ShellTunnel) don't actually care how the payload is generated, but
316330
// the underlying C2 might be implied depending on how the individual exploit
317331
// has been developed. It is certainly not a requirement to call this function

‎framework.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,13 @@ func parseCommandLine(conf *config.Config) bool {
278278
}
279279
}
280280

281+
// Manually start the C2 server. This is used when Config.C2AutoStart is
282+
// disabled and for when you may not want to start the server until
283+
// another action is complete.
284+
func StartC2(conf *config.Config) bool {
285+
return startC2Server(conf)
286+
}
287+
281288
func startC2Server(conf *config.Config) bool {
282289
if conf.DoExploit && !conf.ThirdPartyC2Server && conf.Bport == 0 &&
283290
(conf.ExType != config.InformationDisclosure && conf.ExType != config.Webshell) {
@@ -416,8 +423,10 @@ func RunProgram(sploit Exploit, conf *config.Config) {
416423
}
417424

418425
// if the c2 server is meant to catch responses, initialize and start so it can bind
419-
if !startC2Server(conf) {
420-
return
426+
if conf.C2AutoStart {
427+
if !startC2Server(conf) {
428+
return
429+
}
421430
}
422431

423432
if conf.ExType == config.FileFormat || conf.ExType == config.Local {

0 commit comments

Comments
 (0)
Failed to load comments.