(t *testing.T)
| 1287 | } |
| 1288 | |
| 1289 | func TestEvasionScanner(t *testing.T) { |
| 1290 | var tests = []*struct { |
| 1291 | name string |
| 1292 | gen func() error |
| 1293 | want func(e *event.Event) bool |
| 1294 | completed bool |
| 1295 | }{ |
| 1296 | { |
| 1297 | "direct syscall", |
| 1298 | func() error { |
| 1299 | cmd := exec.Command("_fixtures/direct-syscall/direct-syscall.exe") |
| 1300 | return cmd.Run() |
| 1301 | }, |
| 1302 | func(e *event.Event) bool { |
| 1303 | if strings.Contains(strings.ToLower(e.Callstack.String()), strings.ToLower("direct-syscall.exe")) && e.Type == event.SetThreadContext { |
| 1304 | log.Info(e, e.Callstack) |
| 1305 | return containsEvasion(e, "direct_syscall") |
| 1306 | } |
| 1307 | return false |
| 1308 | }, |
| 1309 | false, |
| 1310 | }, |
| 1311 | { |
| 1312 | "indirect syscall", |
| 1313 | func() error { |
| 1314 | cmd := exec.Command("_fixtures/indirect-syscall/indirect-syscall.exe") |
| 1315 | return cmd.Run() |
| 1316 | }, |
| 1317 | func(e *event.Event) bool { |
| 1318 | if strings.Contains(strings.ToLower(e.Callstack.String()), strings.ToLower("indirect-syscall.exe")) && e.Type == event.SetThreadContext { |
| 1319 | log.Info(e, e.Callstack) |
| 1320 | return containsEvasion(e, "indirect_syscall") |
| 1321 | } |
| 1322 | return false |
| 1323 | }, |
| 1324 | false, |
| 1325 | }, |
| 1326 | } |
| 1327 | |
| 1328 | evsConfig := config.EventSourceConfig{ |
| 1329 | EnableThreadEvents: true, |
| 1330 | EnableModuleEvents: true, |
| 1331 | EnableFileIOEvents: false, |
| 1332 | EnableVAMapEvents: true, |
| 1333 | EnableNetEvents: true, |
| 1334 | EnableRegistryEvents: false, |
| 1335 | EnableMemEvents: false, |
| 1336 | EnableHandleEvents: false, |
| 1337 | EnableDNSEvents: false, |
| 1338 | EnableAuditAPIEvents: true, |
| 1339 | StackEnrichment: true, |
| 1340 | } |
| 1341 | evsConfig.Init() |
| 1342 | |
| 1343 | hsnap := new(handle.SnapshotterMock) |
| 1344 | hsnap.On("FindByObject", mock.Anything).Return(htypes.Handle{}, false) |
| 1345 | hsnap.On("FindHandles", mock.Anything).Return([]htypes.Handle{}, nil) |
| 1346 | hsnap.On("Write", mock.Anything).Return(nil) |
nothing calls this directly
no test coverage detected