Pwn - really obnoxious problem
140 points | 234 solves
Last updated
140 points | 234 solves
Last updated
You know the drill.
Didn't manage to solve this during the CTF but I should have.
The program is quite straightforward,
We have a buffer overflow in gets()
because there is no boundary check. We shall use a cyclic pattern to find out what is the offset required to control rip
.
msf-pattern_create -l 200
to generate the cyclic pattern:
Using gdb
, we find out what is in the ret address:
msf-pattern_offset -l 200 -q 6341356341346341
to find the offset.
Now we have control over rip
, it is time to find the "win" function and conveniently we have the flag()
function available.
To "win", we need to pass in 2 arguments before calling the function and this can be done with a ROP chain. In Linux x64 calling convention, the function arguments are passed via rdi
, rsi
, rdx
, rcx
, r8
, r9
registers.
ROPgadget --binary ./really_obnoxious_problem --ropchain
to find the ROP gadgets.
We have found 2 useful gadgets, pop rdi; ret
and pop rsi; pop r15; ret
.
Next we want to find the address of "bobby" which we want to populate the second argument with. This can be done from Ghidra itself.
Now that we have everything we need, let's try to craft the exploit.
Flag: actf{so_swe3t_so_c0ld_so_f4ir_7167cfa2c019}
Instead of doing all the hard work of finding the ROP gadgets and stuff pwntools
can actually do most of the heavy lifting for us.