split

Analysis

Functions available to us were pwnme, main, and usefulFunction.

pwndbg> disassemble usefulFunction 
Dump of assembler code for function usefulFunction:
   0x08048649 <+0>:     push   ebp
   0x0804864a <+1>:     mov    ebp,esp
   0x0804864c <+3>:     sub    esp,0x8
   0x0804864f <+6>:     sub    esp,0xc
   0x08048652 <+9>:     push   0x8048747
   0x08048657 <+14>:    call   0x8048430 <system@plt>
   0x0804865c <+19>:    add    esp,0x10
   0x0804865f <+22>:    nop
   0x08048660 <+23>:    leave  
   0x08048661 <+24>:    ret    
End of assembler dump.
wndbg> x/s 0x8048747
0x8048747:      "/bin/ls"

So the parameter the system function is calling is not that useful to us as it just list out the files. Which will not get us flag in any case.

So I ran strings on the binary to see what all strings do we have to work with.

So it turns out that our binary contains the string that we want, which will get us the flag we want. So now we'll get the offset, call the system function and pass the address of the string as the parameter and we'll be good to go.

32 bit

The offset of the buffer was at 44 bytes. So let's find all the addresses we need to construct our exploit.

Let's construct the final payload and get the flag.

64 bit

In 64 bit architecture the parameter to the functions is not passed from stack instead the parameters are passed using the registers. So we'll have to find a ROP chain to put the address of the string into the RDI register [The first parameter register] and the call the function as usual.

The offset to RIP was 40 bytes.

Let's find all the important addresses.

So let's construct the final exploit

Last updated

Was this helpful?