angr.misc¶
- class angr.misc.HookSet
Bases:
objectA HookSet is a static class that provides the capability to apply many hooks to an object.
- static install_hooks(target, **hooks)
Given the target target, apply the hooks given as keyword arguments to it. If any targeted method has already been hooked, the hooks will not be overridden but will instead be pushed into a list of pending hooks. The final behavior should be that all hooks call each other in a nested stack.
- Parameters:
target – Any object. Its methods named as keys in hooks will be replaced by HookedMethod objects.
hooks – Any keywords will be interpreted as hooks to apply. Each method named will hooked with the corresponding function value.
- static remove_hooks(target, **hooks)
Remove the given hooks from the given target.
- Parameters:
target – The object from which to remove hooks. If all hooks are removed from a given method, the HookedMethod object will be removed and replaced with the original function.
hooks – Any keywords will be interpreted as hooks to remove. You must provide the exact hook that was applied so that it can it can be identified for removal among any other hooks.
- static copy_hooks(source, target, domain)
Copy the hooks from source onto target.
If the current callstack includes hooked methods from source, the already-called methods will not be included in the copy.
domainis a list of names that might be hooked.
- class angr.misc.Loggers
Bases:
objectImplements a loggers manager for angr.
- __init__(default_level=30)
- default_level
- profiling_enabled
- handler
- IN_SCOPE = ('angr', 'claripy', 'cle', 'pyvex', 'archinfo', 'tracer', 'driller', 'rex', 'patcherex', 'identifier')¶
- load_all_loggers()
A dumb and simple way to conveniently aggregate all loggers.
Adds attributes to this instance of each registered logger, replacing ‘.’ with ‘_’
- enable_root_logger()
Enable angr’s default logger
- disable_root_logger()
Disable angr’s default logger
- static setall(level)
- class angr.misc.PicklableLock
Bases:
objectNormal thread-locks are not pickleable. This provides a pickleable lock by mandating that the lock is unlocked during serialization.
- __init__(*args, **kwargs)
- acquire(*args, **kwargs)
- locked()
- release()
- class angr.misc.PluginHub
Bases:
GenericA plugin hub is an object which contains many plugins, as well as the notion of a “preset”, or a backer that can provide default implementations of plugins which cater to a certain circumstance.
Objects in angr like the SimState, the Analyses hub, the SimEngine selector, etc all use this model to unify their mechanisms for automatically collecting and selecting components to use. If you’re familiar with design patterns this is a configurable Strategy Pattern.
Each PluginHub subclass should have a corresponding Plugin subclass, and perhaps a PluginPreset subclass if it wants its presets to be able to specify anything more interesting than a list of defaults.
- __init__()
- Return type:
None
- classmethod register_default(name, plugin_cls, preset='default')
- classmethod register_preset(name, preset)
Register a preset instance with the class of the hub it corresponds to. This allows individual plugin objects to automatically register themselves with a preset by using a classmethod of their own with only the name of the preset to register with.
- Return type:
- Parameters:
name (str)
preset (PluginPreset[P])
- property plugin_preset: PluginPreset[P] | None
Get the current active plugin preset
- property has_plugin_preset: bool
Check whether or not there is a plugin preset in use on this hub right now
- use_plugin_preset(preset)
Apply a preset to the hub. If there was a previously active preset, discard it.
Preset can be either the string name of a preset or a PluginPreset instance.
- Return type:
- Parameters:
preset (str | PluginPreset[P])
- discard_plugin_preset()
Discard the current active preset. Will release any active plugins that could have come from the old preset.
- Return type:
- get_plugin(name)
Get the plugin named
name. If no such plugin is currently active, try to activate a new one using the current preset.
- has_plugin(name)
Return whether or not a plugin with the name
nameis currently active.
- register_plugin(name, plugin)
Add a new plugin
pluginwith namenameto the active plugins.
- class angr.misc.PluginPreset
Bases:
GenericA plugin preset object contains a mapping from name to a plugin class. A preset can be active on a hub, which will cause it to handle requests for plugins which are not already present on the hub.
Unlike Plugins and PluginHubs, instances of PluginPresets are defined on the module level for individual presets. You should register the preset instance with a hub to allow plugins to easily add themselves to the preset without an explicit reference to the preset itself.
- __init__()
- Return type:
None
- activate(hub)
This method is called when the preset becomes active on a hub.
- deactivate(hub)
This method is called when the preset is discarded from the hub.
- add_default_plugin(name, plugin_cls)
Add a plugin to the preset.
- list_default_plugins()
Return a list of the names of available default plugins.
- request_plugin(name)
Return the plugin class which is registered under the name
name, or raise NoPlugin if the name isn’t available.
- copy()
Return a copy of self.
- Return type:
PluginPreset[TypeVar(P)]
Submodules
These classes perform some python magic that we use to implement the nesting of exploration technique methods. |
|