mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-22 17:44:52 +02:00
Convert all helper_ properties to get_ methods.
This commit is contained in:
@@ -103,7 +103,7 @@ class RegistryHive(interfaces.layers.TranslationLayerInterface):
|
||||
found_key = [] # type: typing.List[str]
|
||||
while key_array and node_key:
|
||||
for subkey in node_key.get_subkeys():
|
||||
if subkey.helper_name == key_array[0]:
|
||||
if subkey.get_name() == key_array[0]:
|
||||
node_key = subkey
|
||||
found_key, key_array = found_key + [key_array[0]], key_array[1:]
|
||||
break
|
||||
@@ -153,7 +153,7 @@ class RegistryHive(interfaces.layers.TranslationLayerInterface):
|
||||
|
||||
table = storage.Map.Directory[dir_index]
|
||||
entry = table.Table[table_index]
|
||||
return entry.helper_block_offset + suboffset
|
||||
return entry.get_block_offset() + suboffset
|
||||
|
||||
def mapping(self,
|
||||
offset: int,
|
||||
|
||||
@@ -584,9 +584,9 @@ class Struct(interfaces.objects.ObjectInterface):
|
||||
vollog.debug("Deprecated non-helper attribute {} requested from class override {}".format(attr,
|
||||
self.vol.type_name))
|
||||
# Uncomment the following line if we want to prohibit using non-helper properties
|
||||
# return self.__getattr_(attr)
|
||||
# return self.__getattr__(attr)
|
||||
|
||||
# Change this to an attribute error if we want to prohibit rather than deprecate member collisisons
|
||||
# Change this to an attribute error if we want to prohibit rather than deprecate member collisisons
|
||||
return object.__getattribute__(self, attr)
|
||||
|
||||
def __getattr__(self, attr: str) -> typing.Any:
|
||||
|
||||
@@ -47,8 +47,7 @@ class _CM_KEY_BODY(objects.Struct):
|
||||
"""This represents an open handle to a registry key and
|
||||
is not tied to the registry hive file format on disk."""
|
||||
|
||||
@property
|
||||
def helper_full_key_name(self) -> str:
|
||||
def get_full_key_name(self) -> str:
|
||||
output = []
|
||||
kcb = self.KeyControlBlock
|
||||
while kcb.ParentKcb:
|
||||
@@ -63,8 +62,7 @@ class _CM_KEY_BODY(objects.Struct):
|
||||
|
||||
|
||||
class _DEVICE_OBJECT(objects.Struct, ExecutiveObject):
|
||||
@property
|
||||
def helper_device_name(self) -> str:
|
||||
def get_device_name(self) -> str:
|
||||
header = self.object_header()
|
||||
return header.NameInfo.Name.String # type: ignore
|
||||
|
||||
@@ -73,7 +71,7 @@ class _FILE_OBJECT(objects.Struct, ExecutiveObject):
|
||||
def file_name_with_device(self) -> str:
|
||||
name = ""
|
||||
if self._context.memory[self.vol.layer_name].is_valid(self.DeviceObject):
|
||||
name = "\\Device\\{}".format(self.DeviceObject.helper_device_name)
|
||||
name = "\\Device\\{}".format(self.DeviceObject.get_device_name())
|
||||
|
||||
try:
|
||||
name += self.FileName.String
|
||||
@@ -124,15 +122,14 @@ class _ETHREAD(objects.Struct):
|
||||
|
||||
|
||||
class _UNICODE_STRING(objects.Struct):
|
||||
@property
|
||||
def helper_string(self) -> interfaces.objects.ObjectInterface:
|
||||
def get_string(self) -> interfaces.objects.ObjectInterface:
|
||||
# We explicitly do *not* catch errors here, we allow an exception to be thrown
|
||||
# (otherwise there's no way to determine anything went wrong)
|
||||
# It's up to the user of this method to catch exceptions
|
||||
return self.Buffer.dereference().cast("string", max_length = self.Length, errors = "replace",
|
||||
encoding = "utf16")
|
||||
|
||||
String = helper_string
|
||||
String = property(get_string)
|
||||
|
||||
|
||||
class _EPROCESS(generic.GenericIntelProcess):
|
||||
|
||||
@@ -27,8 +27,7 @@ class RegValueTypes(enum.Enum):
|
||||
|
||||
|
||||
class _HMAP_ENTRY(objects.Struct):
|
||||
@property
|
||||
def helper_block_offset(self) -> int:
|
||||
def get_block_offset(self) -> int:
|
||||
try:
|
||||
return self.PermanentBinAddress ^ (self.PermanentBinAddress & 0x3)
|
||||
except AttributeError:
|
||||
@@ -36,28 +35,26 @@ class _HMAP_ENTRY(objects.Struct):
|
||||
|
||||
|
||||
class _CMHIVE(objects.Struct):
|
||||
@property
|
||||
def helper_name(self) -> typing.Optional[interfaces.objects.ObjectInterface]:
|
||||
def get_name(self) -> typing.Optional[interfaces.objects.ObjectInterface]:
|
||||
"""Determine a name for the hive. Note that some attributes are
|
||||
unpredictably blank across different OS versions while others are populated,
|
||||
so we check all possibilities and take the first one that's not empty"""
|
||||
|
||||
for attr in ["FileFullPath", "FileUserName", "HiveRootPath"]:
|
||||
try:
|
||||
return getattr(self, attr).helper_string
|
||||
return getattr(self, attr).get_string()
|
||||
except (AttributeError, exceptions.InvalidAddressException):
|
||||
pass
|
||||
|
||||
return None
|
||||
|
||||
name = helper_name
|
||||
name = property(get_name)
|
||||
|
||||
|
||||
class _CM_KEY_NODE(objects.Struct):
|
||||
"""Extension to allow traversal of registry keys"""
|
||||
|
||||
@property
|
||||
def helper_volatile(self) -> bool:
|
||||
def get_volatile(self) -> bool:
|
||||
if not isinstance(self._context.memory[self.vol.layer_name], RegistryHive):
|
||||
raise ValueError("Cannot determine volatility of registry key without an offset in a RegistryHive layer")
|
||||
return bool(self.vol.offset & 0x80000000)
|
||||
@@ -114,8 +111,7 @@ class _CM_KEY_NODE(objects.Struct):
|
||||
if node.vol.type_name.endswith(constants.BANG + '_CM_KEY_VALUE'):
|
||||
yield node
|
||||
|
||||
@property
|
||||
def helper_name(self) -> interfaces.objects.ObjectInterface:
|
||||
def get_name(self) -> interfaces.objects.ObjectInterface:
|
||||
"""Since this is just a casting convenience, it can be a property"""
|
||||
return self.Name.cast("string", max_length = self.NameLength, encoding = "latin-1")
|
||||
|
||||
@@ -124,15 +120,14 @@ class _CM_KEY_NODE(objects.Struct):
|
||||
# Using the offset adds a significant delay (since it cannot be cached easily)
|
||||
# if self.vol.offset == reg.get_node(reg.root_cell_offset).vol.offset:
|
||||
if self.vol.offset == reg.root_cell_offset + 4:
|
||||
return self.helper_name
|
||||
return reg.get_node(self.Parent).get_key_path() + '\\' + self.helper_name
|
||||
return self.get_name()
|
||||
return reg.get_node(self.Parent).get_key_path() + '\\' + self.get_name()
|
||||
|
||||
|
||||
class _CM_KEY_VALUE(objects.Struct):
|
||||
"""Extensions to extract data from CM_KEY_VALUE nodes"""
|
||||
|
||||
@property
|
||||
def helper_name(self) -> interfaces.objects.ObjectInterface:
|
||||
def get_name(self) -> interfaces.objects.ObjectInterface:
|
||||
"""Since this is just a casting convenience, it can be a property"""
|
||||
self.Name.count = self.NameLength
|
||||
return self.Name.cast("string", max_length = self.NameLength, encoding = "latin-1")
|
||||
@@ -168,15 +163,15 @@ class _CM_KEY_VALUE(objects.Struct):
|
||||
self_type = RegValueTypes(self.Type)
|
||||
if self_type == RegValueTypes.REG_DWORD:
|
||||
if len(data) != struct.calcsize("<L"):
|
||||
raise ValueError("Size of data does not match the type of registry value {}".format(self.helper_name))
|
||||
raise ValueError("Size of data does not match the type of registry value {}".format(self.get_name()))
|
||||
return struct.unpack("<L", data)[0]
|
||||
if self_type == RegValueTypes.REG_DWORD_BIG_ENDIAN:
|
||||
if len(data) != struct.calcsize(">L"):
|
||||
raise ValueError("Size of data does not match the type of registry value {}".format(self.helper_name))
|
||||
raise ValueError("Size of data does not match the type of registry value {}".format(self.get_name()))
|
||||
return struct.unpack(">L", data)[0]
|
||||
if self_type == RegValueTypes.REG_QWORD:
|
||||
if len(data) != struct.calcsize("<Q"):
|
||||
raise ValueError("Size of data does not match the type of registry value {}".format(self.helper_name))
|
||||
raise ValueError("Size of data does not match the type of registry value {}".format(self.get_name()))
|
||||
return struct.unpack("<Q", data)[0]
|
||||
if self_type in [RegValueTypes.REG_SZ, RegValueTypes.REG_EXPAND_SZ, RegValueTypes.REG_LINK]:
|
||||
# truncate after \x00\x00 to ensure it can
|
||||
@@ -192,5 +187,5 @@ class _CM_KEY_VALUE(objects.Struct):
|
||||
return ''
|
||||
|
||||
# Fall back if it's something weird
|
||||
vollog.debug("Unknow registry value type encountered: {}", self.Type)
|
||||
vollog.debug("Unknown registry value type encountered: {}", self.Type)
|
||||
return self.Data.cast("string", max_length = self.DataLength, encoding = "latin-1")
|
||||
|
||||
Reference in New Issue
Block a user