Warmup (pwn)
Here's something to get you warmed up, spin that gdb up.
Last updated
Here's something to get you warmed up, spin that gdb up.
Last updated
Using the dockerfile, I built the image and ran it. I then extracted the libc.so.6
and ld-linux-x86-64.so.2
binaries.
The given binary file has the following protections:
The decompiled main
function is as follows:
We are given a libc leak via the address of puts. Then, we are prompted to enter an input into a global variable name
. name
is 512 bytes long, and we can only enter 512 bytes into it. Afterwards, we can enter 88 bytes into local_48
, which is a local variable (located in the stack) and can only fit 64 bytes.
After the first 64 bytes we enter for the second input, the next 8 bytes overwrite RSP
, the next 8 bytes overwrite RIP
, and the next 8 bytes could potentially be used for an ROP chain.
Since there is no win function, we cannot simply overwriteRIP
with the address of a function in the binary and hope to get a shell. The only way to get a shell is by using gadgets provided by the binary and libc.
Also note that the memory allocated for our name
global variable is always fixed. As such, memory region 0x404000-0x405000
will always have RW permissions.
Therefore, if we were to pivot from the stack in our second input to this larger region, we would have much more space for our ROP chain. To do so, in our second input we can overwrite RBP
to become 0x404000
, and in the next 8 bytes we can insert a leave ; ret
gadget.
We then add our payload into the name
global variable, which is the first input. The first 8 bytes don't matter since our stack pivoting causes the first 8 bytes in name
to be skipped. I then add an ROP chain to call execve('/bin/sh')
.