-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathutils.go
More file actions
144 lines (127 loc) · 3.58 KB
/
Copy pathutils.go
File metadata and controls
144 lines (127 loc) · 3.58 KB
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
package main
import (
"io/ioutil"
"net"
"runtime"
"strings"
ps "github.com/mitchellh/go-ps"
)
// collectMACAddresses gathers all MAC addresses from network interfaces
func collectMACAddresses() []string {
var macs []string
ifaces, err := net.Interfaces()
if err != nil {
return macs
}
for _, iface := range ifaces {
mac := iface.HardwareAddr.String()
if mac != "" && mac != "00:00:00:00:00:00" {
macs = append(macs, strings.ToUpper(mac))
}
}
return macs
}
// collectDetectedFilePaths returns sandbox-related file paths that exist
func collectDetectedFilePaths() []string {
var detectedPaths []string
// Known sandbox file paths
sandboxPaths := []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 _, path := range sandboxPaths {
if fileExists(path) {
detectedPaths = append(detectedPaths, path)
}
}
return detectedPaths
}
// fileExists checks if a file exists
func fileExists(path string) bool {
if _, err := ioutil.ReadFile(path); err == nil {
return true
}
return false
}
// getProcessCount returns the number of running processes
func getProcessCount() int {
processes, err := ps.Processes()
if err != nil {
return -1
}
return len(processes)
}
// getCPUCores returns the number of CPU cores
func getCPUCores() int {
return runtime.NumCPU()
}
// getTempFileCount returns the number of files in the temp directory
func getTempFileCount() int {
tempDir := `C:\windows\temp`
files, err := ioutil.ReadDir(tempDir)
if err != nil {
return -1
}
return len(files)
}
// getSuspiciousProcesses identifies potentially suspicious sandbox processes
func getSuspiciousProcesses() []string {
var suspicious []string
knownSandboxProcesses := []string{
"vboxservice.exe",
"vboxtray.exe",
"vmtoolsd.exe",
"vmwaretray.exe",
"vmwareuser.exe",
"vmusrvc.exe",
"vmsrvc.exe",
"xenservice.exe",
"qemu-ga.exe",
"prl_cc.exe",
"prl_tools.exe",
"srvhost.exe", // Any.run specific
}
processes, err := ps.Processes()
if err != nil {
return suspicious
}
for _, proc := range processes {
procName := strings.ToLower(proc.Executable())
for _, sandboxProc := range knownSandboxProcesses {
if procName == sandboxProc {
suspicious = append(suspicious, procName)
}
}
}
return suspicious
}