Overview
This example demonstrates how to build a simple ROP chain that sets register values usingset_regs(). This is one of the most fundamental operations in ROP chain construction.
Basic Register Setting
1
Initialize angrop
Load your binary and create a ROP analysis object:
2
Find gadgets
Search for ROP gadgets in the binary:This analyzes the binary and identifies useful ROP gadgets that can be chained together.
3
Build the chain
Create a chain that sets specific register values:
4
Print the payload
Generate exploit code ready to copy into your script:
Complete Example
Expected Output
Understanding the Chain
-
First gadget (
0xf5e2): Pops values intorbx,r12, andrbp. We use this to setrbxto0x42424242. -
Second gadget (
0x812f): Pops a value intorsi. We use this to temporarily store0x41414141inrsi. -
Third gadget (
0x169dd): Moves the value fromrsiintorax, achieving our goal of settingraxto0x41414141.