Pwn - babypwn2
Second part of babypwn.
Last updated
Second part of babypwn.
Last updated
This is one another pwn challenge but here there is no direct secret()
function to call.
a vulnerable_function()
where the fgets()
function allows an overflow due to no bounds check.
stack address is leaked (printf("Stack address leak: %p\n", buffer)
).
buffer size is 64 bytes, but fgets()
reads up to 128 bytes from the input.
no protection mechanisms like stack canaries or ASLR.
The exploit script uses the stack address leak to craft a payload that spawns a shell and gains access to the system.
the challenge leaks the stack address of the buffer. This allows easy calculation of where to overwrite the return pointer.
the solve script includes a shellcode payload for spawning a shell. This is a typical x86_64 shellcode:
This shellcode spawns a /bin/sh
shell when executed.
payload consists of 72 bytes of padding ("A" * 72
) to fill the buffer up to retr addr, return address calculated as the leaked stack address (addr + 80
) and the shellcode appended at end of the payload.