(t *testing.T)
| 681 | } |
| 682 | |
| 683 | func TestSequenceOOO(t *testing.T) { |
| 684 | log.SetLevel(log.DebugLevel) |
| 685 | |
| 686 | c := &config.FilterConfig{Name: "LSASS memory dumping via legitimate or offensive tools"} |
| 687 | f := filter.New(` |
| 688 | sequence |
| 689 | maxspan 2m |
| 690 | |evt.name = 'OpenProcess' and evt.arg[exe] imatches '?:\\Windows\\System32\\lsass.exe'| by ps.uuid |
| 691 | |evt.name = 'CreateFile' and file.operation = 'CREATE' and file.extension = '.dmp'| by ps.uuid |
| 692 | `, &config.Config{EventSource: config.EventSourceConfig{EnableFileIOEvents: true}, Filters: &config.Filters{}}) |
| 693 | require.NoError(t, f.Compile()) |
| 694 | |
| 695 | ss := newSequenceState(f, c, new(ps.SnapshotterMock)) |
| 696 | |
| 697 | e1 := &event.Event{ |
| 698 | Type: event.CreateFile, |
| 699 | Timestamp: time.Now(), |
| 700 | Name: "CreateFile", |
| 701 | Tid: 2484, |
| 702 | PID: 859, |
| 703 | Category: event.File, |
| 704 | PS: &pstypes.PS{ |
| 705 | Name: "cmd.exe", |
| 706 | Exe: "C:\\Windows\\system32\\rundll32.exe", |
| 707 | }, |
| 708 | Params: event.Params{ |
| 709 | params.FilePath: {Name: params.FilePath, Type: params.UnicodeString, Value: "C:\\temp\\lsass.dmp"}, |
| 710 | params.FileOperation: {Name: params.FileOperation, Type: params.UnicodeString, Value: "CREATE"}, |
| 711 | }, |
| 712 | Metadata: map[event.MetadataKey]any{"foo": "bar", "fooz": "barzz"}, |
| 713 | } |
| 714 | require.False(t, ss.runSequence(e1)) |
| 715 | require.Len(t, ss.partials[1], 1) |
| 716 | assert.True(t, ss.partials[1][0].ContainsMeta(event.RuleSequenceOOOKey)) |
| 717 | |
| 718 | e2 := &event.Event{ |
| 719 | Type: event.OpenProcess, |
| 720 | Timestamp: time.Now(), |
| 721 | Name: "OpenProcess", |
| 722 | Tid: 2484, |
| 723 | PID: 859, |
| 724 | PS: &pstypes.PS{ |
| 725 | Name: "cmd.exe", |
| 726 | Exe: "C:\\Windows\\system32\\rundll32.exe", |
| 727 | }, |
| 728 | Params: event.Params{ |
| 729 | params.Exe: {Name: params.Exe, Type: params.UnicodeString, Value: "C:\\Windows\\System32\\lsass.exe"}, |
| 730 | params.ProcessID: {Name: params.ProcessID, Type: params.PID, Value: uint32(2243)}, |
| 731 | params.DesiredAccess: {Name: params.DesiredAccess, Type: params.Flags, Value: uint32(0x1400), Flags: event.PsAccessRightFlags}, |
| 732 | }, |
| 733 | Metadata: map[event.MetadataKey]any{"foo": "bar", "fooz": "barzz"}, |
| 734 | } |
| 735 | |
| 736 | require.True(t, ss.runSequence(e2)) |
| 737 | assert.Len(t, ss.partials[0], 1) |
| 738 | assert.False(t, ss.partials[1][0].ContainsMeta(event.RuleSequenceOOOKey)) |
| 739 | } |
| 740 |
nothing calls this directly
no test coverage detected