Skip to content

Commit e0e4541

Browse files
committed
refactor(filter): Change registry.value filter field semantics
The registry.value filter field yields the name of the created or modified registry value. The new registry.data field returns the captured value data.
1 parent 7fb5a90 commit e0e4541

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

pkg/filter/accessor_windows.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,9 +940,14 @@ func (r *registryAccessor) Get(f Field, e *event.Event) (params.Value, error) {
940940
case fields.RegistryKeyHandle:
941941
return e.GetParamAsString(params.RegKeyHandle), nil
942942
case fields.RegistryValue:
943-
return e.Params.GetRaw(params.RegValue)
943+
if e.IsRegSetValue() {
944+
return filepath.Base(filepath.Base(e.GetParamAsString(params.RegPath))), nil
945+
}
946+
return nil, nil
944947
case fields.RegistryValueType:
945948
return e.Params.GetString(params.RegValueType)
949+
case fields.RegistryData:
950+
return e.GetParamAsString(params.RegData), nil
946951
case fields.RegistryStatus:
947952
return e.GetParamAsString(params.NTStatus), nil
948953
}

pkg/filter/fields/fields_windows.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,12 @@ const (
479479
RegistryKeyName Field = "registry.key.name"
480480
// RegistryKeyHandle represents the registry KCB address
481481
RegistryKeyHandle Field = "registry.key.handle"
482-
// RegistryValue represents the registry value
482+
// RegistryValue represents the registry value name field
483483
RegistryValue Field = "registry.value"
484-
// RegistryValueType represents the registry value type
484+
// RegistryValueType represents the registry value type field
485485
RegistryValueType Field = "registry.value.type"
486+
// RegistryData represents the captured registry data field
487+
RegistryData Field = "registry.data"
486488
// RegistryStatus represent the registry operation status
487489
RegistryStatus Field = "registry.status"
488490

@@ -1000,8 +1002,9 @@ var fields = map[Field]FieldInfo{
10001002
RegistryPath: {RegistryPath, "fully qualified registry path", params.UnicodeString, []string{"registry.path = 'HKEY_LOCAL_MACHINE\\SYSTEM'"}, nil, nil},
10011003
RegistryKeyName: {RegistryKeyName, "registry key name", params.UnicodeString, []string{"registry.key.name = 'CurrentControlSet'"}, nil, nil},
10021004
RegistryKeyHandle: {RegistryKeyHandle, "registry key object address", params.Address, []string{"registry.key.handle = 'FFFFB905D60C2268'"}, nil, nil},
1003-
RegistryValue: {RegistryValue, "registry value content", params.UnicodeString, []string{"registry.value = '%SystemRoot%\\system32'"}, nil, nil},
1005+
RegistryValue: {RegistryValue, "registry value name", params.UnicodeString, []string{"registry.value = 'Epoch'"}, nil, nil},
10041006
RegistryValueType: {RegistryValueType, "type of registry value", params.UnicodeString, []string{"registry.value.type = 'REG_SZ'"}, nil, nil},
1007+
RegistryData: {RegistryData, "registry value captured data", params.Object, []string{"registry.data = '%SystemRoot%'"}, nil, nil},
10051008
RegistryStatus: {RegistryStatus, "status of registry operation", params.UnicodeString, []string{"registry.status != 'success'"}, nil, nil},
10061009

10071010
NetDIP: {NetDIP, "destination IP address", params.IP, []string{"net.dip = 172.17.0.3"}, nil, nil},

pkg/filter/filter_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ func TestRegistryFilter(t *testing.T) {
863863
Category: event.Registry,
864864
Params: event.Params{
865865
params.RegPath: {Name: params.RegPath, Type: params.UnicodeString, Value: `HKEY_LOCAL_MACHINE\SYSTEM\Setup\Pid`},
866-
params.RegValue: {Name: params.RegValue, Type: params.Uint32, Value: uint32(10234)},
866+
params.RegData: {Name: params.RegData, Type: params.Uint32, Value: uint32(10234)},
867867
params.RegValueType: {Name: params.RegValueType, Type: params.AnsiString, Value: "DWORD"},
868868
params.NTStatus: {Name: params.NTStatus, Type: params.AnsiString, Value: "success"},
869869
params.RegKeyHandle: {Name: params.RegKeyHandle, Type: params.Address, Value: uint64(18446666033449935464)},
@@ -878,8 +878,9 @@ func TestRegistryFilter(t *testing.T) {
878878
{`registry.status startswith ('key not', 'succ')`, true},
879879
{`registry.path = 'HKEY_LOCAL_MACHINE\\SYSTEM\\Setup\\Pid'`, true},
880880
{`registry.key.name icontains ('Setup', 'setup')`, true},
881-
{`registry.value = 10234`, true},
881+
{`registry.value = 'Pid'`, true},
882882
{`registry.value.type in ('DWORD', 'QWORD')`, true},
883+
{`registry.data = '10234'`, true},
883884
{`MD5(registry.path) = 'eab870b2a516206575d2ffa2b98d8af5'`, true},
884885
}
885886

0 commit comments

Comments
 (0)