Skip to content

Commit 5d2a5f9

Browse files
authored
Merge pull request #1276 from dgmcdona/dgmcdona/windows-callbacks-validity-check
Windows: Callbacks - fixes bad callback validity check
2 parents c37d9ee + db55f23 commit 5d2a5f9

File tree

2 files changed

+40
-8
lines changed

2 files changed

+40
-8
lines changed

volatility3/framework/plugins/windows/callbacks.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,12 @@ def scan(
248248
context, layer_name, nt_symbol_table, constraints
249249
):
250250
try:
251-
if hasattr(mem_object, "is_valid") and not mem_object.is_valid():
252-
continue
251+
if isinstance(mem_object, callbacks._SHUTDOWN_PACKET):
252+
if not mem_object.is_parseable(type_map):
253+
continue
254+
elif hasattr(mem_object, "is_valid"):
255+
if not mem_object.is_valid():
256+
continue
253257

254258
yield cls._process_scanned_callback(mem_object, type_map)
255259
except exceptions.InvalidAddressException:

volatility3/framework/symbols/windows/extensions/callbacks.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
from typing import Dict
23

34
from volatility3.framework import exceptions, objects
45
from volatility3.framework.symbols.windows.extensions import pool
@@ -24,27 +25,54 @@ def is_valid(self) -> bool:
2425
and self.Entry.Blink.is_readable()
2526
and self.DeviceObject.is_readable()
2627
):
28+
vollog.debug(
29+
f"Callback obj 0x{self.vol.offset:x} invalid due to unreadable structure members"
30+
)
2731
return False
2832

33+
except exceptions.InvalidAddressException:
34+
vollog.debug(
35+
f"callback obj 0x{self.vol.offset:x} invalid due to invalid address access"
36+
)
37+
return False
38+
39+
return True
40+
41+
def is_parseable(self, type_map: Dict[int, str]) -> bool:
42+
"""
43+
Determines whether or not this `_SHUTDOWN_PACKET` callback can be reliably parsed.
44+
Requires a `type_map` that maps NT executive object type indices to string representations.
45+
This type map can be acquired via the `handles.Handles.get_type_map` classmethod.
46+
"""
47+
if not self.is_valid():
48+
return False
49+
50+
try:
51+
2952
device = self.DeviceObject
3053
if not device or not (device.DriverObject.DriverStart % 0x1000 == 0):
3154
vollog.debug(
3255
f"callback obj 0x{self.vol.offset:x} invalid due to invalid device object"
3356
)
3457
return False
3558

59+
header = device.get_object_header()
60+
object_type = header.get_object_type(type_map)
61+
is_valid = object_type == "Device"
62+
if not is_valid:
63+
vollog.debug(
64+
f"Callback obj 0x{self.vol.offset:x} invalid due to invalid device type: wanted 'Device', found '{object_type}'"
65+
)
66+
return is_valid
3667
except exceptions.InvalidAddressException:
3768
vollog.debug(
3869
f"callback obj 0x{self.vol.offset:x} invalid due to invalid address access"
3970
)
4071
return False
41-
42-
try:
43-
header = device.get_object_header()
44-
valid = header.NameInfo.Name == "Device"
45-
return valid
4672
except ValueError:
47-
vollog.debug(f"Could not get NameInfo for object at 0x{self.vol.offset:x}")
73+
vollog.debug(
74+
f"Could not get object type for object at 0x{self.vol.offset:x}"
75+
)
4876
return False
4977

5078

0 commit comments

Comments
 (0)