angr.misc

class angr.misc.HookSet

Bases: object

A 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.

domain is a list of names that might be hooked.

class angr.misc.Loggers

Bases: object

Implements 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: object

Normal 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: Generic

A 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')
Return type:

None

Parameters:
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:

None

Parameters:
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:

None

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:

None

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.

Return type:

TypeVar(P)

Parameters:

name (str)

has_plugin(name)

Return whether or not a plugin with the name name is currently active.

Return type:

bool

Parameters:

name (str)

register_plugin(name, plugin)

Add a new plugin plugin with name name to the active plugins.

Return type:

TypeVar(P)

Parameters:
  • name (str)

  • plugin (P)

release_plugin(name)

Deactivate and remove the plugin with name name.

Return type:

None

Parameters:

name (str)

class angr.misc.PluginPreset

Bases: Generic

A 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.

Return type:

None

Parameters:

hub (PluginHub[P])

deactivate(hub)

This method is called when the preset is discarded from the hub.

Return type:

None

Parameters:

hub (PluginHub[P])

add_default_plugin(name, plugin_cls)

Add a plugin to the preset.

Return type:

None

Parameters:
list_default_plugins()

Return a list of the names of available default plugins.

Return type:

list[str]

request_plugin(name)

Return the plugin class which is registered under the name name, or raise NoPlugin if the name isn’t available.

Return type:

type[TypeVar(P)]

Parameters:

name (str)

copy()

Return a copy of self.

Return type:

PluginPreset[TypeVar(P)]

Submodules

ansi

autoimport

bug_report

hookset

These classes perform some python magic that we use to implement the nesting of exploration technique methods.

loggers

picklable_lock

plugins

telemetry

testing

ux