volatility3.framework.contexts package
A Context maintains the accumulated state required for various plugins and framework functions.
This has been made an object to allow quick swapping and changing of contexts, to allow a plugin to act on multiple different contexts without them interfering with each other.
- class ConfigurableModule(context, config_path, name)[source]
Bases:
Module
,ConfigurableInterface
Constructs a new os-independent module.
- Parameters:
context (
ContextInterface
) – The context within which this module will existconfig_path (
str
) – The path within the context’s configuration treename (
str
) – The name of the module
- build_configuration()
Builds the configuration dictionary for this specific Module
- Return type:
- property config: HierarchicalDict
The Hierarchical configuration Dictionary for this Configurable object.
- property context: ContextInterface
Context that the module uses.
- get_absolute_symbol_address(name)
Returns the absolute address of the symbol within this module
- Return type:
- classmethod get_requirements()
Returns a list of RequirementInterface objects required by this object.
- Return type:
- get_symbol(name)
Returns a symbol object from the module’s symbol table.
- Return type:
- get_symbols_by_absolute_location(offset, size=0)
Returns the symbols within this module that live at the specified absolute offset provided.
- has_enumeration(name)
Determines whether an enumeration is present in the module’s symbol table.
- Return type:
- has_symbol(name)
Determines whether a symbol is present in the module’s symbol table.
- Return type:
- has_type(name)
Determines whether a type is present in the module’s symbol table.
- Return type:
- classmethod make_subconfig(context, base_config_path, **kwargs)
Convenience function to allow constructing a new randomly generated sub-configuration path, containing each element from kwargs.
- Parameters:
context (
ContextInterface
) – The context in which to store the new configurationbase_config_path (
str
) – The base configuration path on which to build the new configurationkwargs – Keyword arguments that are used to populate the new configuration path
- Returns:
The newly generated full configuration path
- Return type:
- object(object_type, offset=None, native_layer_name=None, absolute=False, **kwargs)
Returns an object created using the symbol_table_name and layer_name of the Module.
- Parameters:
object_type (
str
) – Name of the type/enumeration (within the module) to constructoffset (
int
) – The location of the object, ignored when symbol_type is SYMBOLnative_layer_name (
Optional
[str
]) – Name of the layer in which constructed objects are made (for pointers)absolute (
bool
) – whether the type’s offset is absolute within memory or relative to the module
- Return type:
- object_from_symbol(symbol_name, native_layer_name=None, absolute=False, object_type=None, **kwargs)
Returns an object based on a specific symbol (containing type and offset information) and the layer_name of the Module. This will throw a ValueError if the symbol does not contain an associated type, or if the symbol name is invalid. It will throw a SymbolError if the symbol cannot be found.
- Parameters:
symbol_name (
str
) – Name of the symbol (within the module) to constructnative_layer_name (
Optional
[str
]) – Name of the layer in which constructed objects are made (for pointers)absolute (
bool
) – whether the symbol’s address is absolute or relative to the moduleobject_type (
Union
[str
,ObjectInterface
,None
]) – Override for the type from the symobl to use (or if the symbol type is missing)
- Return type:
- property symbols
Lists the symbols contained in the symbol table for this module
- classmethod unsatisfied(context, config_path)
Returns a list of the names of all unsatisfied requirements.
Since a satisfied set of requirements will return [], it can be used in tests as follows:
unmet = configurable.unsatisfied(context, config_path) if unmet: raise RuntimeError("Unsatisfied requirements: {}".format(unmet)
- Return type:
- class Context[source]
Bases:
ContextInterface
Maintains the context within which to construct objects.
The context object is the main method of carrying around state that’s been constructed for the purposes of investigating memory. It contains a symbol_space of all the symbols that can be accessed by plugins using the context. It also contains the memory made up of data and translation layers, and it contains a factory method for creating new objects.
Other context objects can be constructed as long as they support the
ContextInterface
. This is the primary context object to be used in the volatility framework. It maintains theInitializes the context.
- add_layer(layer)[source]
Adds a named translation layer to the context.
- Parameters:
layer (
DataLayerInterface
) – The layer to be added to the memory- Raises:
volatility3.framework.exceptions.LayerException – if the layer is already present, or has unmet dependencies
- Return type:
- add_module(module)
Adds a named module to the context.
- Parameters:
module (
ModuleInterface
) – The module to be added to the module object collection- Raises:
volatility3.framework.exceptions.VolatilityException – if the module is already present, or has unmet dependencies
- clone()
Produce a clone of the context (and configuration), allowing modifications to be made without affecting any mutable objects in the original.
Memory constraints may become an issue for this function depending on how much is actually stored in the context
- Return type:
- property config: HierarchicalDict
Returns a mutable copy of the configuration, but does not allow the whole configuration to be altered.
- property layers: LayerContainer
A LayerContainer object, allowing access to all data and translation layers currently available within the context.
- module(module_name, layer_name, offset, native_layer_name=None, size=None)[source]
Constructs a new os-independent module.
- Parameters:
module_name (
str
) – The name of the modulelayer_name (
str
) – The layer within the context in which the module existsoffset (
int
) – The offset at which the module exists in the layernative_layer_name (
Optional
[str
]) – The default native layer for objects constructed by the modulesize (
Optional
[int
]) – The size, in bytes, that the module occupies from offset location within the layer named layer_name
- Return type:
- property modules: ModuleContainer
A container for modules loaded in this context
- object(object_type, layer_name, offset, native_layer_name=None, **arguments)[source]
Object factory, takes a context, symbol, offset and optional layername.
Looks up the layername in the context, finds the object template based on the symbol, and constructs an object using the object template on the layer at the offset.
- Parameters:
object_type (
Union
[str
,Template
]) – The name (or template) of the symbol type on which to construct the object. If this is a name, it should contain an explicit table name.layer_name (
str
) – The name of the layer on which to construct the objectoffset (
int
) – The offset within the layer at which the data used to create the object livesnative_layer_name (
Optional
[str
]) – The name of the layer the object references (for pointers) if different to layer_name
- Return type:
- Returns:
A fully constructed object
- property symbol_space: SymbolSpaceInterface
The space of all symbols that can be accessed within this context.
- class Module(context, config_path, name)[source]
Bases:
ModuleInterface
Constructs a new os-independent module.
- Parameters:
context (
ContextInterface
) – The context within which this module will existconfig_path (
str
) – The path within the context’s configuration treename (
str
) – The name of the module
- build_configuration()
Builds the configuration dictionary for this specific Module
- Return type:
- property config: HierarchicalDict
The Hierarchical configuration Dictionary for this Configurable object.
- property context: ContextInterface
Context that the module uses.
- get_absolute_symbol_address(name)
Returns the absolute address of the symbol within this module
- Return type:
- classmethod get_requirements()
Returns a list of RequirementInterface objects required by this object.
- Return type:
- get_symbol(name)
Returns a symbol object from the module’s symbol table.
- Return type:
- get_symbols_by_absolute_location(offset, size=0)[source]
Returns the symbols within this module that live at the specified absolute offset provided.
- has_enumeration(name)
Determines whether an enumeration is present in the module’s symbol table.
- Return type:
- has_symbol(name)
Determines whether a symbol is present in the module’s symbol table.
- Return type:
- has_type(name)
Determines whether a type is present in the module’s symbol table.
- Return type:
- classmethod make_subconfig(context, base_config_path, **kwargs)
Convenience function to allow constructing a new randomly generated sub-configuration path, containing each element from kwargs.
- Parameters:
context (
ContextInterface
) – The context in which to store the new configurationbase_config_path (
str
) – The base configuration path on which to build the new configurationkwargs – Keyword arguments that are used to populate the new configuration path
- Returns:
The newly generated full configuration path
- Return type:
- object(object_type, offset=None, native_layer_name=None, absolute=False, **kwargs)[source]
Returns an object created using the symbol_table_name and layer_name of the Module.
- Parameters:
object_type (
str
) – Name of the type/enumeration (within the module) to constructoffset (
int
) – The location of the object, ignored when symbol_type is SYMBOLnative_layer_name (
Optional
[str
]) – Name of the layer in which constructed objects are made (for pointers)absolute (
bool
) – whether the type’s offset is absolute within memory or relative to the module
- Return type:
- object_from_symbol(symbol_name, native_layer_name=None, absolute=False, object_type=None, **kwargs)[source]
Returns an object based on a specific symbol (containing type and offset information) and the layer_name of the Module. This will throw a ValueError if the symbol does not contain an associated type, or if the symbol name is invalid. It will throw a SymbolError if the symbol cannot be found.
- Parameters:
symbol_name (
str
) – Name of the symbol (within the module) to constructnative_layer_name (
Optional
[str
]) – Name of the layer in which constructed objects are made (for pointers)absolute (
bool
) – whether the symbol’s address is absolute or relative to the moduleobject_type (
Union
[str
,ObjectInterface
,None
]) – Override for the type from the symobl to use (or if the symbol type is missing)
- Return type:
- property symbols
Lists the symbols contained in the symbol table for this module
- classmethod unsatisfied(context, config_path)
Returns a list of the names of all unsatisfied requirements.
Since a satisfied set of requirements will return [], it can be used in tests as follows:
unmet = configurable.unsatisfied(context, config_path) if unmet: raise RuntimeError("Unsatisfied requirements: {}".format(unmet)
- Return type:
- class ModuleCollection(modules=None)[source]
Bases:
ModuleContainer
Class to contain a collection of SizedModules and reason about their contents.
- add_module(module)
Adds a module to the module collection
This will throw an exception if the required dependencies are not met
- Parameters:
module (
ModuleInterface
) – the module to add to the list of modules (based on module.name)- Return type:
- deduplicate()[source]
Returns a new deduplicated ModuleCollection featuring no repeated modules (based on data hash)
All 0 sized modules will have identical hashes and are therefore included in the deduplicated version
- Return type:
- get(k[, d]) D[k] if k in D, else d. d defaults to None.
- get_module_symbols_by_absolute_location(offset, size=0)[source]
Returns a tuple of (module_name, list_of_symbol_names) for each module, where symbols live at the absolute offset in memory provided.
- get_modules_by_symbol_tables(symbol_table)
Returns the modules which use the specified symbol table name
- items() a set-like object providing a view on D's items
- keys() a set-like object providing a view on D's keys
- property modules: ModuleCollection
A name indexed dictionary of modules using that name in this collection.
- values() an object providing a view on D's values
- class SizedModule(context, config_path, name)[source]
Bases:
Module
Constructs a new os-independent module.
- Parameters:
context (
ContextInterface
) – The context within which this module will existconfig_path (
str
) – The path within the context’s configuration treename (
str
) – The name of the module
- build_configuration()
Builds the configuration dictionary for this specific Module
- Return type:
- property config: HierarchicalDict
The Hierarchical configuration Dictionary for this Configurable object.
- property context: ContextInterface
Context that the module uses.
- get_absolute_symbol_address(name)
Returns the absolute address of the symbol within this module
- Return type:
- classmethod get_requirements()
Returns a list of RequirementInterface objects required by this object.
- Return type:
- get_symbol(name)
Returns a symbol object from the module’s symbol table.
- Return type:
- get_symbols_by_absolute_location(offset, size=0)[source]
Returns the symbols within this module that live at the specified absolute offset provided.
- has_enumeration(name)
Determines whether an enumeration is present in the module’s symbol table.
- Return type:
- has_symbol(name)
Determines whether a symbol is present in the module’s symbol table.
- Return type:
- has_type(name)
Determines whether a type is present in the module’s symbol table.
- Return type:
- property hash: str
Hashes the module for equality checks.
The mapping should be sorted and should be quicker than reading the data We turn it into JSON to make a common string and use a quick hash, because collisions are unlikely
- classmethod make_subconfig(context, base_config_path, **kwargs)
Convenience function to allow constructing a new randomly generated sub-configuration path, containing each element from kwargs.
- Parameters:
context (
ContextInterface
) – The context in which to store the new configurationbase_config_path (
str
) – The base configuration path on which to build the new configurationkwargs – Keyword arguments that are used to populate the new configuration path
- Returns:
The newly generated full configuration path
- Return type:
- object(object_type, offset=None, native_layer_name=None, absolute=False, **kwargs)
Returns an object created using the symbol_table_name and layer_name of the Module.
- Parameters:
object_type (
str
) – Name of the type/enumeration (within the module) to constructoffset (
int
) – The location of the object, ignored when symbol_type is SYMBOLnative_layer_name (
Optional
[str
]) – Name of the layer in which constructed objects are made (for pointers)absolute (
bool
) – whether the type’s offset is absolute within memory or relative to the module
- Return type:
- object_from_symbol(symbol_name, native_layer_name=None, absolute=False, object_type=None, **kwargs)
Returns an object based on a specific symbol (containing type and offset information) and the layer_name of the Module. This will throw a ValueError if the symbol does not contain an associated type, or if the symbol name is invalid. It will throw a SymbolError if the symbol cannot be found.
- Parameters:
symbol_name (
str
) – Name of the symbol (within the module) to constructnative_layer_name (
Optional
[str
]) – Name of the layer in which constructed objects are made (for pointers)absolute (
bool
) – whether the symbol’s address is absolute or relative to the moduleobject_type (
Union
[str
,ObjectInterface
,None
]) – Override for the type from the symobl to use (or if the symbol type is missing)
- Return type:
- property symbols
Lists the symbols contained in the symbol table for this module
- classmethod unsatisfied(context, config_path)
Returns a list of the names of all unsatisfied requirements.
Since a satisfied set of requirements will return [], it can be used in tests as follows:
unmet = configurable.unsatisfied(context, config_path) if unmet: raise RuntimeError("Unsatisfied requirements: {}".format(unmet)
- Return type: