Overview
Register control is fundamental to ROP chain construction. angrop provides powerful primitives for setting and moving register values, which can be combined to create complex chains.Setting Registers
Basic set_regs()
Theset_regs() method sets registers to specific values:
Example Output
Moving Registers
Using move_regs()
Themove_regs() method copies values between registers:
Example Output
rdx into rax using intermediate gadgets.
Combining Chains
Complete Example
Preserving Registers
When calling functions, you can preserve specific registers:Output
0x41414141) is ignored because rdi is preserved, so the function will use whatever value is already in rdi.
Avoiding Bad Bytes
You can specify bad bytes to avoid in your chain:Real-World Example: Setting Up Syscall Arguments
Advanced: Register Arithmetic
You can also perform operations on registers:Debugging Tips
Pretty Print
Usepp() to see exactly what each gadget does:
Payload Code
Useprint_payload_code() to get ready-to-paste Python code: