Skip to content

Commit 79b8ff7

Browse files
committed
Address final feedback
1 parent 322f79f commit 79b8ff7

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

volatility3/framework/plugins/windows/debugregisters.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,7 @@ def _generator(
148148
file3, sym3 = path_and_symbol(vads, dr3)
149149

150150
# if none map to an actual file VAD then bail
151-
if not (
152-
isinstance(file0, str)
153-
or isinstance(file1, str)
154-
or isinstance(file2, str)
155-
or isinstance(file3, str)
156-
):
151+
if not (file0 or file1 or file2 or file3):
157152
continue
158153

159154
process_name = owner_proc.ImageFileName.cast(
@@ -173,17 +168,17 @@ def _generator(
173168
thread.Tcb.State,
174169
dr7,
175170
format_hints.Hex(dr0),
176-
file0,
177-
sym0,
171+
file0 or renderers.NotApplicableValue(),
172+
sym0 or renderers.NotApplicableValue(),
178173
format_hints.Hex(dr1),
179-
file1,
180-
sym1,
174+
file1 or renderers.NotApplicableValue(),
175+
sym1 or renderers.NotApplicableValue(),
181176
format_hints.Hex(dr2),
182-
file2,
183-
sym2,
177+
file2 or renderers.NotApplicableValue(),
178+
sym2 or renderers.NotApplicableValue(),
184179
format_hints.Hex(dr3),
185-
file3,
186-
sym3,
180+
file3 or renderers.NotApplicableValue(),
181+
sym3 or renderers.NotApplicableValue(),
187182
),
188183
)
189184

volatility3/framework/plugins/windows/pe_symbols.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def path_and_symbol_for_address(
423423
collected_modules: collected_modules_type,
424424
ranges: ranges_type,
425425
address: int,
426-
) -> Tuple[str, str]:
426+
) -> Tuple[Optional[str], Optional[str]]:
427427
"""
428428
Method for plugins to determine the file path and symbol name for a given address
429429
@@ -438,12 +438,12 @@ def path_and_symbol_for_address(
438438
Tuple[str|renderers.NotApplicableValue|renderers.NotAvailableValue, str|renderers.NotApplicableValue|renderers.NotAvailableValue]
439439
"""
440440
if not address:
441-
return renderers.NotApplicableValue(), renderers.NotApplicableValue()
441+
return None, None
442442

443443
filepath = PESymbols.filepath_for_address(ranges, address)
444444

445445
if not filepath:
446-
return renderers.NotAvailableValue(), renderers.NotAvailableValue()
446+
return None, None
447447

448448
filename = PESymbols.filename_for_path(filepath).lower()
449449

@@ -452,12 +452,12 @@ def path_and_symbol_for_address(
452452
filename: {wanted_addresses_identifier: [address]}
453453
}
454454

455-
found_symbols, _missing_msybols = PESymbols.find_symbols(
455+
found_symbols, _missing_symbols = PESymbols.find_symbols(
456456
context, config_path, filter_module, collected_modules
457457
)
458458

459459
if not found_symbols or filename not in found_symbols:
460-
return filepath, renderers.NotAvailableValue()
460+
return filepath, None
461461

462462
return filepath, found_symbols[filename][0][0]
463463

volatility3/framework/plugins/windows/unhooked_system_calls.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ class unhooked_system_calls(interfaces.plugins.PluginInterface):
7171
}
7272
}
7373

74+
# This data structure is used to track unique implementations of functions across processes
75+
# The outer dictionary holds the module name (e.g., ntdll.dll)
76+
# The next dictionary holds the function names (NtTerminateProcess, NtSetValueKey, etc.) inside a module
77+
# The innermost dictionary holds the unique implementation (bytes) of a function across processes
78+
# Each implementation is tracked along with the process(es) that host it
79+
# For systems without malware, all functions should have the same implementation
80+
# When API hooking/module unhooking is done, the victim (infected) processes will have unique implementations
7481
_code_bytes_type = Dict[str, Dict[str, Dict[bytes, List[Tuple[int, str]]]]]
7582

7683
@classmethod
@@ -127,6 +134,7 @@ def _gather_code_bytes(
127134
except exceptions.InvalidAddressException:
128135
continue
129136

137+
# see the definition of _code_bytes_type for details of this data structure
130138
if dll_name not in code_bytes:
131139
code_bytes[dll_name] = {}
132140

0 commit comments

Comments
 (0)