(t *testing.T)
| 587 | } |
| 588 | |
| 589 | func TestComplexSequence(t *testing.T) { |
| 590 | log.SetLevel(log.DebugLevel) |
| 591 | |
| 592 | c := &config.FilterConfig{Name: "Phishing dropper outbound communication"} |
| 593 | f := filter.New(` |
| 594 | sequence |
| 595 | maxspan 1h |
| 596 | |evt.name = 'CreateProcess' and ps.name in ('firefox.exe', 'chrome.exe', 'edge.exe')| by ps.pid |
| 597 | |evt.name = 'CreateFile' and file.operation = 'CREATE' and file.extension = '.exe'| by ps.pid |
| 598 | |evt.name in ('Send', 'Connect')| by ps.pid |
| 599 | `, &config.Config{EventSource: config.EventSourceConfig{EnableFileIOEvents: true}, Filters: &config.Filters{}}) |
| 600 | require.NoError(t, f.Compile()) |
| 601 | |
| 602 | ss := newSequenceState(f, c, new(ps.SnapshotterMock)) |
| 603 | |
| 604 | e1 := &event.Event{ |
| 605 | Seq: 1, |
| 606 | Type: event.CreateProcess, |
| 607 | Timestamp: time.Now(), |
| 608 | Category: event.Process, |
| 609 | Name: "CreateProcess", |
| 610 | Tid: 2484, |
| 611 | PID: 2243, |
| 612 | PS: &pstypes.PS{ |
| 613 | Name: "firefox.exe", |
| 614 | Exe: "C:\\Program Files\\Firefox\\firefox.exe", |
| 615 | }, |
| 616 | Params: event.Params{ |
| 617 | params.ProcessID: {Name: params.ProcessID, Type: params.PID, Value: uint32(2243)}, |
| 618 | params.ProcessName: {Name: params.ProcessName, Type: params.UnicodeString, Value: "firefox.exe"}, |
| 619 | }, |
| 620 | Metadata: map[event.MetadataKey]any{"foo": "bar", "fooz": "barzz"}, |
| 621 | } |
| 622 | require.False(t, ss.runSequence(e1)) |
| 623 | |
| 624 | e2 := &event.Event{ |
| 625 | Seq: 2, |
| 626 | Type: event.CreateFile, |
| 627 | Timestamp: time.Now().Add(time.Millisecond * 250), |
| 628 | Name: "CreateFile", |
| 629 | Tid: 2484, |
| 630 | PID: 2243, |
| 631 | Category: event.File, |
| 632 | PS: &pstypes.PS{ |
| 633 | Name: "firefox.exe", |
| 634 | Exe: "C:\\Program Files\\Mozilla Firefox\\firefox.exe", |
| 635 | Cmdline: "C:\\Program Files\\Mozilla Firefox\\firefox.exe\" -contentproc --channel=\"10464.7.539748228\\1366525930\" -childID 6 -isF", |
| 636 | }, |
| 637 | Params: event.Params{ |
| 638 | params.FilePath: {Name: params.FilePath, Type: params.UnicodeString, Value: "C:\\Temp\\dropper.exe"}, |
| 639 | params.FileOperation: {Name: params.FileOperation, Type: params.Enum, Value: uint32(2), Enum: fs.FileCreateDispositions}, |
| 640 | }, |
| 641 | Metadata: map[event.MetadataKey]any{"foo": "bar", "fooz": "barzz"}, |
| 642 | } |
| 643 | require.False(t, ss.runSequence(e2)) |
| 644 | |
| 645 | assert.Len(t, ss.partials[0], 1) |
| 646 | assert.Len(t, ss.partials[1], 1) |
nothing calls this directly
no test coverage detected