RopEffect and encapsulate gadget properties, transitions, and behaviors.
RopGadget
The base class for all ROP gadgets.Class Definition
Constructor
Address where the gadget starts.
Attributes
Address of the gadget.
Reference to the angr project.
Type of gadget transition:
"pop_pc"- Returns via ret,jmp [sp+X],pop pc, orretn(self-contained)"jmp_reg"- Jumps to a register value (requires prior register setting)"jmp_mem"- Jumps to a memory location (requires prior memory setup)
For
pop_pc gadgets: offset from stack pointer to PC value. For ret instructions, this is stack_change - arch.bytes.For
jmp_reg gadgets: name of the register that contains the jump target.For
jmp_mem gadgets: memory location that contains the jump target.Inherited Attributes from RopEffect
RopGadget inherits many attributes fromRopEffect that describe the gadget’s behavior:
Change in stack pointer after gadget execution.
Set of registers modified by the gadget.
Dictionary mapping registers to their pop offsets from the stack.
List of register-to-register moves performed by the gadget.
Dictionary showing which registers each output register depends on.
Dictionary showing which registers directly control each output register.
List of memory write operations performed.
List of memory read operations performed.
List of memory modification operations (add, sub, xor, etc.).
Whether the gadget contains conditional branches.
Whether the gadget is an “out-of-place” gadget (non-standard behavior).
List of basic block addresses that make up the gadget.
Properties
self_contained
- It has no conditional branches
- Its transit type is
"pop_pc" - It’s not an out-of-place (oop) gadget
Methods
dstr
"pop rax; pop rbx; ret".
pp
copy
__str__
- Address
- Stack change
- Changed/popped registers
- Register moves
- Register dependencies and controllers
- Memory operations (reads, writes, changes)
__repr__
"<Gadget 0x400123>".
PivotGadget
Represents a stack pivot gadget that can arbitrarily control the stack pointer.Class Definition
Constructor
Address where the pivot gadget starts.
Additional Attributes
Stack pointer change before the pivot occurs.
Stack pointer change after the pivot occurs.
Set of registers that control the new stack pointer value.
Set of stack values that control the new stack pointer.
Properties
sp_controllers
sp_reg_controllers and sp_stack_controllers.
Returns: Complete set of stack pointer controllers.
Methods
__str__
__repr__
"<PivotGadget 0x400789>".
copy
SyscallGadget
Represents a system call gadget.Class Definition
- With return:
syscall; ret - Without return:
syscall; xxxx
Constructor
Address where the syscall gadget starts.
Additional Attributes
Optional prologue gadget that executes before the syscall.
Properties
can_return
transit_type is not None).
Returns: Whether the gadget returns after the syscall.
Methods
__str__
__repr__
"<SyscallGadget 0x400456>".
copy
FunctionGadget
Represents a function call gadget.Class Definition
Constructor
Address of the function.
Symbol name of the function.
Additional Attributes
Name/symbol of the function.
Methods
dstr
"<system>" or "<func_0x400123>" if no symbol.