Skip to content

Commit 90fa8ae

Browse files
authored
Split runkey path as command components (#688)
* Use command type for runkeys * Enable --hash for command types
1 parent b1bcb0d commit 90fa8ae

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

dissect/target/helpers/record_modifier.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,16 @@ def _hash_path_records(field_name: str, resolved_path: TargetPath) -> Record:
6262

6363
def _resolve_path_types(target: Target, record: Record) -> Iterator[tuple[str, TargetPath]]:
6464
for field_name, field_type in record._field_types.items():
65-
if not issubclass(field_type, fieldtypes.path):
65+
if not issubclass(field_type, (fieldtypes.path, fieldtypes.command)):
6666
continue
6767

6868
path = getattr(record, field_name, None)
6969
if path is None:
7070
continue
7171

72+
if isinstance(path, fieldtypes.command):
73+
path = path.executable
74+
7275
yield field_name, target.resolve(str(path))
7376

7477

dissect/target/plugins/os/windows/regf/runkeys.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Iterator
2+
13
from dissect.target.exceptions import UnsupportedPluginError
24
from dissect.target.helpers.descriptor_extensions import (
35
RegistryRecordDescriptorExtension,
@@ -11,7 +13,7 @@
1113
[
1214
("datetime", "ts"),
1315
("wstring", "name"),
14-
("string", "path"),
16+
("command", "command"),
1517
("string", "key"),
1618
],
1719
)
@@ -48,7 +50,7 @@ def check_compatible(self) -> None:
4850
raise UnsupportedPluginError("No registry run key found")
4951

5052
@export(record=RunKeyRecord)
51-
def runkeys(self):
53+
def runkeys(self) -> Iterator[RunKeyRecord]:
5254
"""Iterate various run key locations. See source for all locations.
5355
5456
Run keys (Run and RunOnce) are registry keys that make a program run when a user logs on. a Run key runs every
@@ -63,7 +65,7 @@ def runkeys(self):
6365
domain (string): The target domain.
6466
ts (datetime): The registry key last modified timestamp.
6567
name (string): The run key name.
66-
path (string): The run key path.
68+
command (command): The run key command.
6769
key (string): The source key for this run key.
6870
"""
6971
for key in self.KEYS:
@@ -73,7 +75,7 @@ def runkeys(self):
7375
yield RunKeyRecord(
7476
ts=r.ts,
7577
name=entry.name,
76-
path=entry.value,
78+
command=entry.value,
7779
key=key,
7880
_target=self.target,
7981
_key=r,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dependencies = [
3434
"dissect.regf>=3.3.dev,<4.0.dev",
3535
"dissect.util>=3.0.dev,<4.0.dev",
3636
"dissect.volume>=3.0.dev,<4.0.dev",
37-
"flow.record~=3.14.0",
37+
"flow.record~=3.15.0",
3838
"structlog",
3939
]
4040
dynamic = ["version"]

tests/helpers/test_modifier.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import pytest
55
from flow.record import Record
6-
from flow.record.fieldtypes import digest, path
6+
from flow.record.fieldtypes import command, digest, path
77

88
from dissect.target import Target
99
from dissect.target.exceptions import FileNotFoundError, IsADirectoryError
@@ -32,6 +32,7 @@ def resolve_function() -> ModifierFunc:
3232
({"name": path}, 2),
3333
({"name": path, "test": path}, 3),
3434
({"name": path, "test": str}, 2),
35+
({"name": command}, 2),
3536
],
3637
)
3738
@patch("flow.record.Record")

0 commit comments

Comments
 (0)