Pwn - babypwn
A basic binary exploitation.
Last updated
A basic binary exploitation.
Last updated
The challenge hosted a remote service accessible via nc 34.162.142.123 5000
, and the objective was to exploit the binary and execute a hidden function (secret
) to retrieve the flag.
the function secret()
prints a message and executes /bin/cat flag.txt
using execve()
. This is the goal function, but it is not called directly in the program.
fixed buffer of 64 bytes (char buffer[64]
) is declared, but fgets()
reads up to 128 bytes, which can lead to potential buffer overflow. This allows overwriting the return address of the function.
since the address of the secret()
function is printed at runtime, the exploitation straightforward.
So to overwrite the return addr of vulnerable_function()
with the address of secret()
i just calculated the offset needed to overwrite the retr addr.
addr of the secret()
function (0x401166
) is leaked when the program starts, simplifying the exploit.
the payload consists of 72 bytes of padding ('A' * 72
) to fill the buffer and overwrite the saved retr addr, followed by the addr of secret()
.
once the function pointer is overwritten, the program flow jumps to secret().