MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / TestSequenceExpire

Function TestSequenceExpire

pkg/rules/sequence_test.go:785–923  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

783}
784
785func TestSequenceExpire(t *testing.T) {
786 log.SetLevel(log.DebugLevel)
787
788 var tests = []struct {
789 c *config.FilterConfig
790 expr string
791 evts []*event.Event
792 wants bool
793 }{
794 {
795 &config.FilterConfig{Name: "LSASS memory dumping via legitimate or offensive tools"},
796 `sequence
797 maxspan 2m
798 |evt.name = 'OpenProcess' and evt.arg[exe] imatches '?:\\Windows\\System32\\lsass.exe'| by ps.uuid
799 |evt.name = 'CreateFile' and file.operation = 'CREATE' and file.extension = '.dmp'| by ps.uuid
800 `,
801 []*event.Event{
802 {
803 Type: event.OpenProcess,
804 Timestamp: time.Now(),
805 Name: "OpenProcess",
806 Tid: 2484,
807 PID: 4143,
808 PS: &pstypes.PS{
809 Name: "cmd.exe",
810 Exe: "C:\\Windows\\system32\\rundll32.exe",
811 },
812 Params: event.Params{
813 params.Exe: {Name: params.Exe, Type: params.UnicodeString, Value: "C:\\Windows\\System32\\lsass.exe"},
814 params.ProcessID: {Name: params.ProcessID, Type: params.PID, Value: uint32(2243)},
815 params.DesiredAccess: {Name: params.DesiredAccess, Type: params.Flags, Value: uint32(0x1400), Flags: event.PsAccessRightFlags},
816 },
817 Metadata: map[event.MetadataKey]any{"foo": "bar", "fooz": "barzz"},
818 },
819 {
820 Type: event.TerminateProcess,
821 Name: "TerminateProcess",
822 Tid: 2484,
823 PID: 859,
824 PS: &pstypes.PS{
825 Name: "cmd.exe",
826 Exe: "C:\\Windows\\system32\\svchost.exe",
827 },
828 Params: event.Params{
829 params.ProcessID: {Name: params.ProcessID, Type: params.PID, Value: uint32(4143)},
830 params.ProcessName: {Name: params.ProcessName, Type: params.AnsiString, Value: "powershell.exe"},
831 },
832 },
833 },
834 true,
835 },
836 {
837 &config.FilterConfig{Name: "System Binary Proxy Execution via Rundll32"},
838 `sequence
839 maxspan 2m
840 |evt.name = 'CreateProcess' and ps.name = 'rundll32.exe'| by ps.pid
841 |evt.name = 'CreateProcess' and ps.name = 'connhost.exe'| by ps.parent.pid
842 `,

Callers

nothing calls this directly

Calls 10

NewFunction · 0.92
newSequenceStateFunction · 0.85
IsTerminateProcessMethod · 0.80
expireMethod · 0.80
runSequenceMethod · 0.80
EqualMethod · 0.80
AddMethod · 0.65
RunMethod · 0.65
CompileMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected