mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-07 02:07:39 +02:00
Python 3 has a sane super() implementation (no arguments), so convert to using that.
This commit is contained in:
@@ -56,8 +56,7 @@ class DtbTest(validity.ValidityRoutines):
|
||||
|
||||
class DtbTest32bit(DtbTest):
|
||||
def __init__(self):
|
||||
DtbTest.__init__(self,
|
||||
layer_type = layers.intel.Intel,
|
||||
super().__init__(layer_type = layers.intel.Intel,
|
||||
ptr_size = 4,
|
||||
ptr_struct = "I",
|
||||
ptr_reference = 0x300,
|
||||
@@ -66,8 +65,7 @@ class DtbTest32bit(DtbTest):
|
||||
|
||||
class DtbTest64bit(DtbTest):
|
||||
def __init__(self):
|
||||
DtbTest.__init__(self,
|
||||
layer_type = layers.intel.Intel32e,
|
||||
super().__init__(layer_type = layers.intel.Intel32e,
|
||||
ptr_size = 8,
|
||||
ptr_struct = "Q",
|
||||
ptr_reference = 0x1ED,
|
||||
@@ -76,8 +74,7 @@ class DtbTest64bit(DtbTest):
|
||||
|
||||
class DtbTestPae(DtbTest):
|
||||
def __init__(self):
|
||||
DtbTest.__init__(self,
|
||||
layer_type = layers.intel.IntelPAE,
|
||||
super().__init__(layer_type = layers.intel.IntelPAE,
|
||||
ptr_size = 8,
|
||||
ptr_struct = "Q",
|
||||
ptr_reference = 0x3,
|
||||
@@ -98,7 +95,7 @@ class PageMapScanner(interfaces.layers.ScannerInterface):
|
||||
tests = [DtbTest32bit, DtbTest64bit, DtbTestPae]
|
||||
|
||||
def __init__(self, tests):
|
||||
interfaces.layers.ScannerInterface.__init__(self)
|
||||
super().__init__()
|
||||
for value in tests:
|
||||
self._check_type(value, DtbTest)
|
||||
self.tests = tests
|
||||
@@ -119,6 +116,7 @@ class PageMapOffsetHelper(automagic_interface.AutomagicInterface):
|
||||
priority = 20
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.tests = [DtbTest32bit(), DtbTest64bit(), DtbTestPae()]
|
||||
|
||||
def branch_leave(self, node, config_path):
|
||||
|
||||
@@ -57,7 +57,7 @@ class TranslationLayerRequirement(config_interface.ConstructableRequirementInter
|
||||
:param layer_name: String detailing the expected name of the required layer, this can be None if it is to be randomly generated
|
||||
:return:
|
||||
"""
|
||||
config_interface.ConstructableRequirementInterface.__init__(self, name, description, default, optional)
|
||||
super().__init__(name, description, default, optional)
|
||||
|
||||
# TODO: Add requirements: acceptable OSes from the address_space information
|
||||
# TODO: Add requirements: acceptable arches from the available layers
|
||||
@@ -150,7 +150,7 @@ class ChoiceRequirement(config_interface.RequirementInterface):
|
||||
"""Allows one from a choice of strings"""
|
||||
|
||||
def __init__(self, choices, *args, **kwargs):
|
||||
config_interface.RequirementInterface.__init__(self, *args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
if not isinstance(choices, list) or any([not isinstance(choice, str) for choice in choices]):
|
||||
raise TypeError("ChoiceRequirement takes a list of strings as choices")
|
||||
self._choices = choices
|
||||
@@ -166,7 +166,7 @@ class ChoiceRequirement(config_interface.RequirementInterface):
|
||||
|
||||
class ListRequirement(config_interface.RequirementInterface):
|
||||
def __init__(self, element_type, max_elements, min_elements, *args, **kwargs):
|
||||
config_interface.RequirementInterface.__init__(self, *args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
if isinstance(element_type, ListRequirement):
|
||||
raise TypeError("ListRequirements cannot contain ListRequirements")
|
||||
self.element_type = self._check_type(element_type, config_interface.RequirementInterface)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from volatility.framework import interfaces, symbols, layers
|
||||
from volatility.framework import interfaces, layers, symbols
|
||||
from volatility.framework.configuration import HierarchicalDict
|
||||
|
||||
__author__ = 'mike'
|
||||
@@ -21,7 +21,7 @@ class Context(interfaces.context.ContextInterface):
|
||||
:param natives: Defines the native types such as integers, floats, arrays and addresses.
|
||||
:type natives: interfaces.symbols.NativeTableInterface
|
||||
"""
|
||||
interfaces.context.ContextInterface.__init__(self)
|
||||
super().__init__()
|
||||
self._symbol_space = symbols.SymbolSpace(natives)
|
||||
self._memory = layers.Memory()
|
||||
self._config = HierarchicalDict()
|
||||
|
||||
@@ -17,7 +17,7 @@ class InvalidAddressException(VolatilityException):
|
||||
"""Thrown when an address is not valid in the space it was requested"""
|
||||
|
||||
def __init__(self, layer_name, invalid_address, *args, **kwargs):
|
||||
VolatilityException.__init__(self, *args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.invalid_address = invalid_address
|
||||
self.layer_name = layer_name
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ class AutomagicInterface(validity.ValidityRoutines, metaclass = ABCMeta):
|
||||
|
||||
priority = 10
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
@abstractmethod
|
||||
def __call__(self, context, config_path, configurable):
|
||||
"""Runs the automagic over the configurable"""
|
||||
|
||||
@@ -17,7 +17,7 @@ class RequirementInterface(validity.ValidityRoutines, metaclass = ABCMeta):
|
||||
"""Class to distinguish configuration elements from everything else"""
|
||||
|
||||
def __init__(self, name, description = None, default = None, optional = False):
|
||||
validity.ValidityRoutines.__init__(self)
|
||||
super().__init__()
|
||||
self._check_type(name, str)
|
||||
if CONFIG_SEPARATOR in name:
|
||||
raise ValueError("Name cannot contain the config-hierarchy divider (" + CONFIG_SEPARATOR + ")")
|
||||
@@ -88,7 +88,7 @@ class ClassRequirement(RequirementInterface):
|
||||
"""Requires a specific class"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
RequirementInterface.__init__(self, *args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self._cls = None
|
||||
|
||||
@property
|
||||
@@ -114,7 +114,7 @@ class ClassRequirement(RequirementInterface):
|
||||
|
||||
class ConstructableRequirementInterface(RequirementInterface):
|
||||
def __init__(self, *args, **kwargs):
|
||||
RequirementInterface.__init__(self, *args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.add_requirement(ClassRequirement("class", "Class of the translation layer"))
|
||||
self._current_class_requirements = set()
|
||||
|
||||
@@ -171,7 +171,7 @@ class ConfigurableInterface(validity.ValidityRoutines):
|
||||
|
||||
def __init__(self, config_path):
|
||||
"""Basic initializer that allows configurables to access their own config settings"""
|
||||
validity.ValidityRoutines.__init__(self)
|
||||
super().__init__()
|
||||
self._config_path = self._check_type(config_path, str)
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -68,8 +68,7 @@ class DataLayerInterface(configuration.ConfigurableInterface, validity.ValidityR
|
||||
provides = {"type": "interface"}
|
||||
|
||||
def __init__(self, context, config_path, name):
|
||||
configuration.ConfigurableInterface.__init__(self, config_path)
|
||||
validity.ValidityRoutines.__init__(self)
|
||||
super().__init__(config_path)
|
||||
self._context = context
|
||||
self._check_type(name, str)
|
||||
self._name = name
|
||||
|
||||
@@ -44,10 +44,10 @@ class ObjectInformation(ReadOnlyMapping):
|
||||
self._check_type(offset, int)
|
||||
if parent:
|
||||
self._check_type(parent, ObjectInterface)
|
||||
ReadOnlyMapping.__init__(self, {'layer_name': layer_name,
|
||||
'offset': offset,
|
||||
'member_name': member_name,
|
||||
'parent': parent})
|
||||
super().__init__({'layer_name': layer_name,
|
||||
'offset': offset,
|
||||
'member_name': member_name,
|
||||
'parent': parent})
|
||||
|
||||
|
||||
class ObjectInterface(validity.ValidityRoutines, metaclass = ABCMeta):
|
||||
@@ -124,6 +124,7 @@ class Template(validity.ValidityRoutines):
|
||||
def __init__(self, type_name, **arguments):
|
||||
"""Stores the keyword arguments for later use"""
|
||||
# Allow the updating of template arguments whilst still in template form
|
||||
super().__init__()
|
||||
self._vol = collections.ChainMap(arguments, {'type_name': type_name})
|
||||
|
||||
@property
|
||||
|
||||
@@ -26,8 +26,7 @@ class PluginInterface(configuration_interface.ConfigurableInterface, validity.Va
|
||||
"""Class that defines the interface all Plugins must maintain"""
|
||||
|
||||
def __init__(self, context, config_path):
|
||||
validity.ValidityRoutines.__init__(self)
|
||||
configuration_interface.ConfigurableInterface.__init__(self, config_path)
|
||||
super().__init__(config_path)
|
||||
self._context = self._check_type(context, context_interface.ContextInterface)
|
||||
# self.validate()
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class Intel(interfaces.layers.TranslationLayerInterface):
|
||||
}
|
||||
|
||||
def __init__(self, context, config_path, name, page_map_offset, memory_layer, swap_layer = None):
|
||||
interfaces.layers.TranslationLayerInterface.__init__(self, context, config_path, name)
|
||||
super().__init__(context, config_path, name)
|
||||
self._base_layer = self._check_type(memory_layer, str)
|
||||
self._page_map_offset = self._check_type(page_map_offset, int)
|
||||
# All Intel address spaces work on 4096 byte pages
|
||||
@@ -155,7 +155,7 @@ class IntelPAE(Intel):
|
||||
priority = 35
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
Intel.__init__(self, *args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# These can vary depending on the type of space
|
||||
self._entry_format = "<Q"
|
||||
@@ -175,7 +175,7 @@ class Intel32e(Intel):
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
Intel.__init__(self, *args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# These can vary depending on the type of space
|
||||
self._entry_format = "<Q"
|
||||
|
||||
@@ -30,7 +30,7 @@ class LimeLayer(interfaces.layers.TranslationLayerInterface):
|
||||
_header_struct = struct.Struct('<IIQQQ')
|
||||
|
||||
def __init__(self, context, config_path, name, base_layer):
|
||||
interfaces.layers.TranslationLayerInterface.__init__(self, context, config_path, name)
|
||||
super().__init__(context, config_path, name)
|
||||
|
||||
self._base_layer = base_layer
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ Created on 6 May 2013
|
||||
|
||||
import os.path
|
||||
|
||||
from volatility.framework import interfaces, exceptions
|
||||
from volatility.framework import exceptions, interfaces
|
||||
from volatility.framework.configuration import requirements
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class BufferDataLayer(interfaces.layers.DataLayerInterface):
|
||||
priority = 10
|
||||
|
||||
def __init__(self, context, config_path, name, buffer):
|
||||
interfaces.layers.DataLayerInterface.__init__(self, context, config_path, name)
|
||||
super().__init__(context, config_path, name)
|
||||
self._buffer = self._check_type(buffer, bytes)
|
||||
|
||||
@property
|
||||
@@ -64,7 +64,7 @@ class FileLayer(interfaces.layers.DataLayerInterface):
|
||||
priority = 20
|
||||
|
||||
def __init__(self, context, config_path, name, filename):
|
||||
interfaces.layers.DataLayerInterface.__init__(self, context, config_path, name)
|
||||
super().__init__(context, config_path, name)
|
||||
|
||||
# FIXME: Add "+" to the mode once we've determined whether write mode is enabled
|
||||
mode = "rb"
|
||||
|
||||
@@ -3,7 +3,7 @@ from volatility.framework.interfaces import layers
|
||||
|
||||
class BytesScanner(layers.ScannerInterface):
|
||||
def __init__(self, needle):
|
||||
layers.ScannerInterface.__init__(self)
|
||||
super().__init__()
|
||||
self.needle = self._check_type(needle, bytes)
|
||||
|
||||
def __call__(self, data, data_offset):
|
||||
|
||||
@@ -35,11 +35,10 @@ class PrimitiveObject(interfaces.objects.ObjectInterface):
|
||||
_struct_type = int
|
||||
|
||||
def __init__(self, context, type_name, object_info, struct_format):
|
||||
interfaces.objects.ObjectInterface.__init__(self,
|
||||
context = context,
|
||||
type_name = type_name,
|
||||
object_info = object_info,
|
||||
struct_format = struct_format)
|
||||
super().__init__(context = context,
|
||||
type_name = type_name,
|
||||
object_info = object_info,
|
||||
struct_format = struct_format)
|
||||
self._struct_format = struct_format
|
||||
|
||||
def __new__(cls, context, type_name, object_info, struct_format, **kwargs):
|
||||
@@ -89,11 +88,10 @@ class Bytes(PrimitiveObject, bytes):
|
||||
_struct_type = bytes
|
||||
|
||||
def __init__(self, context, type_name, object_info, length = 1):
|
||||
interfaces.objects.ObjectInterface.__init__(self,
|
||||
context = context,
|
||||
type_name = type_name,
|
||||
object_info = object_info,
|
||||
struct_format = str(length) + "s")
|
||||
super().__init__(context = context,
|
||||
type_name = type_name,
|
||||
object_info = object_info,
|
||||
struct_format = str(length) + "s")
|
||||
self._vol['length'] = length
|
||||
|
||||
def __new__(cls, context, type_name, object_info, length = 1, **kwargs):
|
||||
@@ -117,11 +115,10 @@ class String(PrimitiveObject, str):
|
||||
_struct_type = str
|
||||
|
||||
def __init__(self, context, type_name, object_info, max_length = 1, encoding = "utf-8", errors = None):
|
||||
PrimitiveObject.__init__(self,
|
||||
context = context,
|
||||
type_name = type_name,
|
||||
object_info = object_info,
|
||||
struct_format = str(max_length) + 's')
|
||||
super().__init__(context = context,
|
||||
type_name = type_name,
|
||||
object_info = object_info,
|
||||
struct_format = str(max_length) + 's')
|
||||
self._vol["max_length"] = max_length
|
||||
self._vol['encoding'] = encoding
|
||||
self._vol['errors'] = errors
|
||||
@@ -151,8 +148,7 @@ class Pointer(Integer):
|
||||
|
||||
def __init__(self, context, type_name, object_info, struct_format, target = None):
|
||||
self._check_type(target, templates.ObjectTemplate)
|
||||
Integer.__init__(self,
|
||||
context = context,
|
||||
super().__init__(context = context,
|
||||
object_info = object_info,
|
||||
type_name = type_name,
|
||||
struct_format = struct_format)
|
||||
@@ -208,7 +204,7 @@ class BitField(PrimitiveObject, int):
|
||||
return cls._struct_type.__new__(cls, (value >> start_bit) & ((1 << end_bit) - 1))
|
||||
|
||||
def __init__(self, context, type_name, object_info, struct_format, target = None, start_bit = 0, end_bit = 0):
|
||||
PrimitiveObject.__init__(self, context, type_name, object_info, struct_format)
|
||||
super().__init__(context, type_name, object_info, struct_format)
|
||||
self._vol['target'] = target
|
||||
self._vol['start_bit'] = start_bit
|
||||
self._vol['end_bit'] = end_bit
|
||||
@@ -238,10 +234,9 @@ class Array(interfaces.objects.ObjectInterface, collections.Sequence):
|
||||
|
||||
def __init__(self, context, type_name, object_info, count = 0, target = None):
|
||||
self._check_type(target, templates.ObjectTemplate)
|
||||
interfaces.objects.ObjectInterface.__init__(self,
|
||||
context = context,
|
||||
type_name = type_name,
|
||||
object_info = object_info)
|
||||
super().__init__(context = context,
|
||||
type_name = type_name,
|
||||
object_info = object_info)
|
||||
self._vol['count'] = self._check_type(count, int)
|
||||
self._vol['target'] = target
|
||||
|
||||
@@ -298,12 +293,11 @@ class Struct(interfaces.objects.ObjectInterface):
|
||||
"""
|
||||
|
||||
def __init__(self, context, type_name, object_info, size, members):
|
||||
interfaces.objects.ObjectInterface.__init__(self,
|
||||
context = context,
|
||||
type_name = type_name,
|
||||
object_info = object_info,
|
||||
size = size,
|
||||
members = members)
|
||||
super().__init__(context = context,
|
||||
type_name = type_name,
|
||||
object_info = object_info,
|
||||
size = size,
|
||||
members = members)
|
||||
self._check_members(members)
|
||||
self._concrete_members = {}
|
||||
|
||||
|
||||
@@ -18,9 +18,7 @@ class ObjectTemplate(interfaces.objects.Template, validity.ValidityRoutines):
|
||||
"""
|
||||
|
||||
def __init__(self, object_class = None, type_name = None, **arguments):
|
||||
interfaces.objects.Template.__init__(self,
|
||||
type_name = type_name,
|
||||
**arguments)
|
||||
super().__init__(type_name = type_name, **arguments)
|
||||
self._check_class(object_class, interfaces.objects.ObjectInterface)
|
||||
self.update_vol(object_class = object_class)
|
||||
|
||||
|
||||
@@ -5,14 +5,14 @@ Created on 10 Apr 2013
|
||||
"""
|
||||
import copy
|
||||
|
||||
from volatility.framework import objects, interfaces
|
||||
from volatility.framework import interfaces, objects
|
||||
|
||||
|
||||
class NativeTable(interfaces.symbols.NativeTableInterface):
|
||||
"""Symbol List that handles Native types"""
|
||||
|
||||
def __init__(self, name, native_dictionary):
|
||||
interfaces.symbols.NativeTableInterface.__init__(self, name, self)
|
||||
super().__init__(name, self)
|
||||
self._native_dictionary = copy.deepcopy(native_dictionary)
|
||||
self._overrides = {}
|
||||
for native_type in self._native_dictionary:
|
||||
|
||||
@@ -46,7 +46,7 @@ class VTypeSymbolTable(interfaces.symbols.SymbolTableInterface):
|
||||
raise TypeError("VType Provider interface cannot be used to fulfill a requirement")
|
||||
vtype_dictionary = getattr(module, vtype_variable)
|
||||
|
||||
interfaces.symbols.SymbolTableInterface.__init__(self, name, native_types)
|
||||
super().__init__(name, native_types)
|
||||
self._vtypedict = vtype_dictionary
|
||||
self._overrides = {}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class WindowsKernelVTypeSymbols(vtypes.VTypeSymbolTable):
|
||||
|
||||
def __init__(self, context, config_path, name, vtype_pymodule, vtype_variable):
|
||||
# FIXME: Make natives another requirement, or in some way hand it in when building the vtype_table
|
||||
vtypes.VTypeSymbolTable.__init__(self, name, vtype_pymodule, vtype_variable, context.symbol_space.natives)
|
||||
super().__init__(name, vtype_pymodule, vtype_variable, context.symbol_space.natives)
|
||||
|
||||
# Set-up windows specific types
|
||||
self.set_type_class('_ETHREAD', extensions._ETHREAD)
|
||||
|
||||
Reference in New Issue
Block a user