volatility3.framework.automagic.stacker module
This module attempts to automatically stack layers.
This automagic module fulfills TranslationLayerRequirement
that are not already fulfilled, by attempting to
stack as many layers on top of each other as possible. The base/lowest layer is derived from the
“automagic.general.single_location” configuration path. Layers are then attempting in likely height order, and
once a layer successfully stacks on top of the existing layers, it is removed from the possible choices list
(so no layer type can exist twice in the layer stack).
- class LayerStacker(*args, **kwargs)[source]
Bases:
AutomagicInterface
Builds up layers in a single stack.
This class mimics the volatility 2 style of stacking address spaces. It builds up various layers based on separate
StackerLayerInterface
classes. These classes are built up based on a stack_order class variable each has.This has a high priority to provide other automagic modules as complete a context/configuration tree as possible. Upon completion it will re-call the
ConstructionMagic
, so that any stacked layers are actually constructed and added to the context.Basic initializer that allows configurables to access their own config settings.
- build_configuration()
Constructs a HierarchicalDictionary of all the options required to build this component in the current context.
Ensures that if the class has been created, it can be recreated using the configuration built Inheriting classes must override this to ensure any dependent classes update their configurations too
- Return type:
- property config: HierarchicalDict
The Hierarchical configuration Dictionary for this Configurable object.
- property context: ContextInterface
The context object that this configurable belongs to/configuration is stored in.
- create_stackers_list()[source]
Creates the list of stackers to use based on the config option
- Return type:
- exclusion_list = []
A list of plugin categories (typically operating systems) which the plugin will not operate on
- find_requirements(context, config_path, requirement_root, requirement_type, shortcut=True)
Determines if there is actually an unfulfilled Requirement waiting.
This ensures we do not carry out an expensive search when there is no need for a particular Requirement
- Parameters:
context (
ContextInterface
) – Context on which to operateconfig_path (
str
) – Configuration path of the top-level requirementrequirement_root (
RequirementInterface
) – Top-level requirement whose subrequirements will all be searchedrequirement_type (
Union
[Tuple
[Type
[RequirementInterface
],...
],Type
[RequirementInterface
]]) – Type of requirement to findshortcut (
bool
) – Only returns requirements that live under unsatisfied requirements
- Return type:
- Returns:
A list of tuples containing the config_path, sub_config_path and requirement identifying the unsatisfied Requirements
- classmethod find_suitable_requirements(context, config_path, requirement, stacked_layers)[source]
Looks for translation layer requirements and attempts to apply the stacked layers to it. If it succeeds it returns the configuration path and layer name where the stacked nodes were spliced into the tree.
- classmethod get_requirements()[source]
Returns a list of RequirementInterface objects required by this object.
- 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:
- priority = 10
An ordering to indicate how soon this automagic should be run
- stack(context, config_path, requirement, progress_callback)[source]
Stacks the various layers and attaches these to a specific requirement.
- Parameters:
context (
ContextInterface
) – Context on which to operateconfig_path (
str
) – Configuration path under which to store stacking datarequirement (
RequirementInterface
) – Requirement that should have layers stacked on itprogress_callback (
Optional
[Callable
[[float
,str
],None
]]) – Function to provide callback progress
- Return type:
- classmethod stack_layer(context, initial_layer, stack_set=None, progress_callback=None)[source]
Stacks as many possible layers on top of the initial layer as can be done.
WARNING: This modifies the context provided and may pollute it with unnecessary layers Recommended use is to: 1. Pass in context.clone() instead of context 2. When provided the layer list, choose the desired layer 3. Build the configuration using layer.build_configuration() 4. Merge the configuration into the original context with context.config.merge() 5. Call Construction magic to reconstruct the layers from just the configuration
- Parameters:
context (
ContextInterface
) – The context on which to operateinitial_layer (
str
) – The name of the initial layer within the contextstack_set (
List
[Type
[StackerLayerInterface
]]) – A list of StackerLayerInterface objects in the order they should be stackedprogress_callback (
Optional
[Callable
[[float
,str
],None
]]) – A function to report progress during the process
- Returns:
A list of layer names that exist in the provided context, stacked in order (highest to lowest)
- 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: