Skip to content

Commit 3b2e4d9

Browse files
committed
refactor: refine presentation of C2 channel modes
1 parent 04025f6 commit 3b2e4d9

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

core/internal/cc/operator/cmd.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,16 +510,17 @@ func gen_agent_cmd() *cobra.Command {
510510
}
511511
}
512512
}
513+
513514
genAgentCmd.Flags().StringP("cc", "", default_cc, "C2 server address (Required)")
514-
genAgentCmd.Flags().StringP("c2-channel-mode", "", def.C2ChannelModeDefault, fmt.Sprintf("C2 channel wrapper mode. Available: %s", strings.Join(transport.AllC2ChannelModes(), ",")))
515-
genAgentCmd.Flags().StringP("cc-http-port", "", live.RuntimeConfig.CCHTTPPort, "Port for plain HTTP C2 transport")
515+
genAgentCmd.Flags().StringP("c2-channel-mode", "", def.C2ChannelModeDefault, fmt.Sprintf("C2 channel wrapper mode. Available: %s", strings.Join(transport.AllC2ChannelModesDetailed(), ";")))
516+
genAgentCmd.Flags().StringP("cc-http-port", "", live.RuntimeConfig.CCHTTPPort, "Port for HTTP Polling/Beaconing C2 transport")
516517
genAgentCmd.Flags().StringP("proxy", "", "", "Hard coded proxy URL for agent's C2 transport. Example: socks5://127.0.0.1:9050")
517518
genAgentCmd.Flags().StringP("cdn", "", "", "CDN proxy to reach C2. Example: wss://cdn.example.com/ws")
518519
genAgentCmd.Flags().StringP("doh", "", "", "DNS over HTTPS server to use for DNS resolution. Example: https://1.1.1.1/dns-query")
519520
genAgentCmd.Flags().BoolP("kcp", "", false, "Use KCP (secure UDP multiplexed tunnel)")
520521
addFlagToGroup("C2 Transport Options", "cc", "c2-channel-mode", "cc-http-port", "proxy", "cdn", "doh", "kcp")
521522

522-
// Group 3: Beaconing (Polling Mode Only)
523+
// Group 3: Beaconing (Polling/Beaconing Mode Only)
523524
genAgentCmd.Flags().IntP("interval", "i", 60, "C2 beacon interval in seconds")
524525
genAgentCmd.Flags().IntP("jitter", "j", 20, "C2 beacon jitter percentage (0-100)")
525526
addFlagToGroup("Beaconing Options (HTTP Mode)", "interval", "jitter")

core/internal/transport/c2channel_http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,5 +618,5 @@ func (s *HTTPServerStream) Close() error {
618618
}
619619

620620
func init() {
621-
RegisterC2Channel("http_poll", "Plain HTTP/1.1 stateless polling wrapper", &HTTPChannelWrapper{})
621+
RegisterC2Channel("http_poll", "HTTP/1.1 stateless polling wrapper. Use `https://` to enable TLS", &HTTPChannelWrapper{})
622622
}

core/internal/transport/c2transport.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,19 @@ func AllC2ChannelModes() []string {
7474
return names
7575
}
7676

77+
func AllC2ChannelModesDetailed() []string {
78+
descriptions := []string{}
79+
// Get C2 channel descriptions
80+
C2Channels.Range(func(key, value any) bool {
81+
descriptor := value.(C2ChannelDescriptor)
82+
description := fmt.Sprintf("%s: %s", descriptor.Name, descriptor.Description)
83+
descriptions = append(descriptions, description)
84+
return true
85+
})
86+
sort.Strings(descriptions)
87+
return descriptions
88+
}
89+
7790
// GenericStreamTransport adapts a raw ReadWriteCloser to the StreamTransport interface.
7891
// It intentionally exposes only byte-stream semantics to higher protocol layers.
7992
type GenericStreamTransport struct {

0 commit comments

Comments
 (0)