-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkernel_types.go
375 lines (359 loc) · 6.71 KB
/
kernel_types.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
//go:build windows && cgo
package etw
type KernelLoggerType int
// The events returned from the Kernel Logger
const (
UnknownLoggerType KernelLoggerType = iota
ProcessRundown
CreateProcess
TerminateProcess
OpenThread
SetThreadContext
CreateHandle
CloseHandle
DuplicateHandle
LoadImage
UnloadImage
ImageRundown
RegOpenKey
RegCloseKey
RegCreateKCB
RegDeleteKCB
RegKCBRundown
RegCreateKey
RegDeleteKey
RegDeleteValue
RegQueryKey
RegQueryValue
RegSetValue
FileOpEnd
FileRundown
ReleaseFile
CloseFile
DeleteFile
RenameFile
SetFileInformation
ReadFile
WriteFile
EnumDirectory
MapViewFile
UnmapViewFile
MapFileRundown
SendTCPv4
SendUDPv4
RecvTCPv4
RecvUDPv4
DisconnectTCPv4
RetransmitTCPv4
ReconnectTCPv4
ConnectTCPv4
AcceptTCPv4
SendTCPv6
SendUDPv6
RecvTCPv6
RecvUDPv6
DisconnectTCPv6
RetransmitTCPv6
ReconnectTCPv6
ConnectTCPv6
AcceptTCPv6
VirtualAlloc
VirtualFree
QueryDNS
ReplyDNS
CreateThread
TerminateThread
ThreadRundown
CreateFile
StackWalk
)
func (self KernelLoggerType) String() string {
switch self {
case ProcessRundown:
return "ProcessRundown"
case CreateProcess:
return "CreateProcess"
case TerminateProcess:
return "TerminateProcess"
case OpenThread:
return "OpenThread"
case SetThreadContext:
return "SetThreadContext"
case CreateHandle:
return "CreateHandle"
case CloseHandle:
return "CloseHandle"
case DuplicateHandle:
return "DuplicateHandle"
case LoadImage:
return "LoadImage"
case UnloadImage:
return "UnloadImage"
case ImageRundown:
return "ImageRundown"
case RegOpenKey:
return "RegOpenKey"
case RegCloseKey:
return "RegCloseKey"
case RegCreateKCB:
return "RegCreateKCB"
case RegDeleteKCB:
return "RegDeleteKCB"
case RegKCBRundown:
return "RegKCBRundown"
case RegCreateKey:
return "RegCreateKey"
case RegDeleteKey:
return "RegDeleteKey"
case RegDeleteValue:
return "RegDeleteValue"
case RegQueryKey:
return "RegQueryKey"
case RegQueryValue:
return "RegQueryValue"
case RegSetValue:
return "RegSetValue"
case FileOpEnd:
return "FileOpEnd"
case FileRundown:
return "FileRundown"
case ReleaseFile:
return "ReleaseFile"
case CloseFile:
return "CloseFile"
case DeleteFile:
return "DeleteFile"
case RenameFile:
return "RenameFile"
case SetFileInformation:
return "SetFileInformation"
case ReadFile:
return "ReadFile"
case WriteFile:
return "WriteFile"
case EnumDirectory:
return "EnumDirectory"
case MapViewFile:
return "MapViewFile"
case UnmapViewFile:
return "UnmapViewFile"
case MapFileRundown:
return "MapFileRundown"
case SendTCPv4:
return "SendTCPv4"
case SendUDPv4:
return "SendUDPv4"
case RecvTCPv4:
return "RecvTCPv4"
case RecvUDPv4:
return "RecvUDPv4"
case DisconnectTCPv4:
return "DisconnectTCPv4"
case RetransmitTCPv4:
return "RetransmitTCPv4"
case ReconnectTCPv4:
return "ReconnectTCPv4"
case ConnectTCPv4:
return "ConnectTCPv4"
case AcceptTCPv4:
return "AcceptTCPv4"
case SendTCPv6:
return "SendTCPv6"
case SendUDPv6:
return "SendUDPv6"
case RecvTCPv6:
return "RecvTCPv6"
case RecvUDPv6:
return "RecvUDPv6"
case DisconnectTCPv6:
return "DisconnectTCPv6"
case RetransmitTCPv6:
return "RetransmitTCPv6"
case ReconnectTCPv6:
return "ReconnectTCPv6"
case ConnectTCPv6:
return "ConnectTCPv6"
case AcceptTCPv6:
return "AcceptTCPv6"
case VirtualAlloc:
return "VirtualAlloc"
case VirtualFree:
return "VirtualFree"
case QueryDNS:
return "QueryDNS"
case ReplyDNS:
return "ReplyDNS"
case CreateThread:
return "CreateThread"
case TerminateThread:
return "TerminateThread"
case ThreadRundown:
return "ThreadRundown"
case CreateFile:
return "CreateFile"
case StackWalk:
return "StackWalk"
default:
return ""
}
}
// https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/ntwmi/wmi_trace_packet/hookid.htm
func GetKernelEventType(e *Event) KernelLoggerType {
switch e.Header.ProviderID.Data1 {
// Process Information
// {3D6FA8D0-FE05-11D0-9DDA-00C04FD7BA7C}
case 0x3d6fa8d0:
switch e.Header.OpCode {
case 1:
return CreateProcess
case 2:
return TerminateProcess
case 3:
return ProcessRundown
}
// Thread Information
// {3D6FA8D1-FE05-11D0-9DDA-00C04FD7BA7C}
case 0x3d6fa8d1:
switch e.Header.OpCode {
case 1:
return CreateThread
case 2:
return TerminateThread
case 3:
return ThreadRundown
}
// Image loading/unloading
// {2CB15D1D-5FC1-11D2-ABE1-00A0C911F518}
case 0x2cb15d1d:
switch e.Header.OpCode {
case 2:
return UnloadImage
case 3:
return ImageRundown
case 10:
return LoadImage
}
// TCP Network
// {9A280AC0-C8E0-11D1-84E2-00C04FB998A2}
case 0x9a280ac0:
switch e.Header.OpCode {
case 15:
return AcceptTCPv4
case 31:
return AcceptTCPv6
case 10:
return SendTCPv4
case 26:
return SendTCPv6
case 11:
return RecvTCPv4
case 27:
return RecvTCPv6
case 12:
return ConnectTCPv4
case 28:
return ConnectTCPv6
case 13:
return DisconnectTCPv4
case 29:
return DisconnectTCPv6
case 16:
return ReconnectTCPv4
case 32:
return ReconnectTCPv6
case 14:
return RetransmitTCPv4
case 30:
return RetransmitTCPv6
}
// UDP Network
// {BF3A50C5-A9C9-4988-A005-2DF0B7C80F80}
case 0xbf3a50c5:
switch e.Header.OpCode {
case 10:
return SendUDPv4
case 26:
return SendUDPv6
case 11:
return RecvUDPv4
case 27:
return RecvUDPv6
}
// Handles
// {89497F50-EFFE-4440-8CF2-CE6B1CDCACA7}
case 0x89497f50:
switch e.Header.OpCode {
case 32:
return CreateHandle
case 33:
return CloseHandle
case 34:
return DuplicateHandle
}
// Registry Information
// {AE53722E-C863-11D2-8659-00C04FA321A1}
case 0xae53722e:
switch e.Header.OpCode {
case 10:
return RegCreateKey
case 11:
return RegOpenKey
case 27:
return RegCloseKey
case 12:
return RegDeleteKey
case 13:
return RegQueryKey
case 14:
return RegSetValue
case 15:
return RegDeleteValue
case 16:
return RegQueryValue
case 22:
return RegCreateKCB
case 23:
return RegDeleteKCB
case 25:
return RegKCBRundown
}
// File activity.
// {90CBDC39-4A3E-11D1-84F4-0000F80464E3}
case 0x90cbdc39:
switch e.Header.OpCode {
case 37:
return MapViewFile
case 38:
return UnmapViewFile
case 39:
return MapFileRundown
case 36, 35, 32:
return FileRundown
case 64:
return CreateFile
case 65:
return ReleaseFile
case 66:
return CloseFile
case 67:
return ReadFile
case 68:
return WriteFile
case 69:
return SetFileInformation
case 70:
return DeleteFile
case 71:
return RenameFile
case 72:
return EnumDirectory
case 76:
return FileOpEnd
}
// Stack traces
// {DEF2FE46-7BD6-4B80-BD94-F57FE20D0CE3}
case 0xdef2fe46:
return StackWalk
}
return UnknownLoggerType
}