angr provides two main CFG recovery analyses: CFGFast for fast, static analysis and CFGEmulated for accurate, symbolic execution-based analysis.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/angr/angr/llms.txt
Use this file to discover all available pages before exploring further.
CFGFast
CFGFast performs fast control-flow graph recovery by using light-weight analysis combined with heuristics. It does not perform expensive data-flow analysis or symbolic execution.
Constructor
The binary to recover CFG on. By default the main binary is used.
A list of objects to recover the CFG on. By default all loaded objects are analyzed.
A list of tuples
(start_address, end_address) describing memory regions that the CFG should cover.Get function beginnings from symbols in the binary.
Scan the binary for function prologues and use those positions as function beginnings. Defaults to
True for non-.NET binaries.Try to resolve indirect jumps. This is necessary to resolve jump targets from jump tables.
Perform a complete scan on the binary and maximize the number of identified code blocks.
Enables the collection of references to data used by individual instructions.
Whether CFGFast should collect cross-references from the entire program. This performs constant propagation on the entire program and may be slower and consume more memory. Implies
data_references=True.Normalize the CFG as well as all function graphs after CFG recovery.
Begin CFG recovery at the entry point of the project.
A list of extra function starting points. CFGFast will try to resume scanning from each address in the list.
Enable aggressive tail-call optimization detection.
A state to use as a backer for all memory loads.
Retrieve function starts from the
.eh_frame of ELF binaries or exception records of PE binaries.A custom list of indirect jump resolvers. If None or empty, default indirect jump resolvers specific to this architecture and binary types will be loaded.
Properties
The control flow graph as a NetworkX DiGraph.
The function manager containing all identified functions.
A mapping of addresses to
MemoryData objects representing data in memory.A mapping of addresses to jump table information.
A mapping of addresses to
IndirectJump objects.Example Usage
CFGEmulated
CFGEmulated performs accurate control-flow graph recovery using symbolic execution. It is slower than CFGFast but provides more precise results.
Constructor
The level of context-sensitivity of this CFG. Ranges from 0 to infinity. Higher values track more calling context.
A collection of starting points to begin analysis. Can contain:
- Integer addresses
- 2-tuples of
(address, jumpkind) SimStateinstances
A list of runs to avoid during analysis.
Whether to use function hints (constants that might be used as exit targets).
How deep in the call stack to trace.
None means no limit.An initial state to use to begin analysis.
Whether to keep the SimStates for each CFGNode.
Whether to enable the indirect jump resolvers for resolving indirect jumps.
If the CFG as well as all Function graphs should be normalized.
The maximum number of iterations that each basic block should be “executed”. Larger numbers are required for complex analyses like loop analysis.
A basic control flow graph to follow. CFG recovery will strictly follow nodes and edges shown in the graph.
The optimization level of VEX IR (0, 1, 2). The default level will be used if
None.The maximum number of basic blocks to recover for the longest path from each start before pausing.
Properties
The control flow graph as a NetworkX DiGraph.
The function manager containing all identified functions.
Get all CFGNodes that have an out-degree of 0.
Get those SimRuns that have non-resolvable exits.
Methods
copy()
Make a copy of the CFG.resume(starts=None, max_steps=None)
Resume a paused or terminated control flow graph recovery.A collection of new starts to resume from. If
None, resume from where it was paused.The maximum number of blocks on the longest path starting from each start before pausing.
get_function_subgraph(start, max_call_depth=None)
Get a sub-graph of a certain function.The function start address.
Call depth limit.
None indicates no limit.Example Usage
CFGNode
Both CFGFast and CFGEmulated create CFGNode objects representing basic blocks in the control flow graph.Properties
The address of this node.
The size of this node in bytes.
The address of the function this node belongs to.
The Block object for this node.
Addresses of all instructions in this node.
List of successor CFGNodes.
List of predecessor CFGNodes.