Return Oriented Programming - ROP
Last updated
Last updated
Return Oriented Programming (ROP) is a technique that allows an attacker to execute arbitrary code in a program by chaining together small fragments of code, known as "gadgets", that are already present in the program's memory.
One of the key features of ROP is that it does not require to inject new code into the program's memory.. This makes ROP attacks difficult to detect and prevent, as the attacker is not introducing any new code that can be identified and blocked.
There is multiple tool that can list available gadget for a binary such as and
So, there is the stack state after a buffer overflow in order to run the rop chain :
When the gagdet 1 return, the process will POP EIP
and because there is the next gadget address, the process will chain with it.
When a function ends and calls the RET
instruction, it is actually a POP EIP
that is performed, followed by a JMP EIP
. The POP EIP
takes the value that is on top of the stack and stores it in the EIP
register. Since this value is controled (using a or for example), the JMP EIP
is controled.
If there is a gadget, such as int 0x80
, there is a notable syscall : the execve
syscall, which executes the program passed in argument.
There is multiple tool that can create ROP chain that call an execve
with available gadget for a binary such as and