ROP class is angrop’s primary interface for semantic-aware ROP gadget discovery and chain building. It extends angr’s Analysis class and provides methods for finding gadgets, managing them, and building exploit chains.
Class Definition
Constructor
If true, skip blocks that are not near ret instructions. This significantly speeds up gadget finding.
Limits the size of blocks considered. Longer blocks are less likely to be good ROP gadgets.
Maximum number of symbolic memory accesses to allow in a gadget.
When True, skip gadgets with conditional branches, floating point operations, and jumps. Allows smaller gadget size. If None, automatically decides based on binary size.
Deprecated. This parameter is no longer used in angrop.
Execute ROP chain in ARM Thumb mode. Only affects ARM architecture. angrop does not switch modes within a chain.
Find kernel mode gadgets instead of user mode gadgets.
Maximum allowable stack change for gadgets. Max stack_change = stack_gsize * arch.bytes.
Whether to support conditional branches. This option significantly impacts gadget finding speed.
Maximum basic block count to consider in gadgets.
Attributes
After callingfind_gadgets(), find_gadgets_single_threaded(), or load_gadgets(), the following attributes are populated:
List of gadgets used for ROP operations (e.g.,
pop rax; ret).List of gadgets used for stack pivoting (e.g.,
mov rsp, rbp; ret).List of gadgets used for invoking system calls (e.g.,
syscall; ret or int 0x80; ret).List of bytes that should not appear in generated ROP chains.
Integer value used when popping useless registers. If None, symbolic values are used.
Architecture object from the gadget finder.
Gadget Discovery Methods
find_gadgets
Whether to run chain_builder.optimize(). This may take time but makes the chain builder more powerful.
Number of processes to use for parallel gadget analysis.
Whether to display a progress bar during gadget finding.
find_gadgets_single_threaded
Whether to display a progress bar.
Whether to run chain_builder.optimize().
analyze_gadget
Address to analyze.
analyze_addr
Address to analyze.
analyze_gadget_list
List of addresses to analyze.
Number of processes to use.
Whether to show progress bar.
Whether to optimize the chain builder.
Gadget Management Methods
save_gadgets
Path to the file where gadgets will be stored.
load_gadgets
Path to the file containing saved gadgets.
Whether to optimize the chain builder after loading.
Configuration Methods
set_badbytes
List of 8-bit integers representing bad bytes (e.g.,
[0x00, 0x09] for null and tab).get_badbytes
set_roparg_filler
Integer value to use as filler, or None to use symbolic values (constraint solver will choose, usually 0).
Chain Building Methods
All public methods from ChainBuilder are automatically exposed through the ROP instance after gadgets are found. These include:set_regs()- Set register valuesmove_regs()- Move values between registerswrite_to_mem()- Write data to memoryfunc_call()- Call a function with argumentsdo_syscall()- Invoke a system callexecve()- Execute execve syscallpivot()- Perform stack pivot- And more…
Example Usage
Internal Properties
Property that returns the ChainBuilder instance. Created lazily on first access. All ChainBuilder public methods are copied to the ROP instance.