Full Buffer Developer
~# cat Question
Do you have what it takes to become a full STACK developer?
nc challs.nusgreyhats.org 55432
full_buffer_developer.c
Once again, we needed to exploit a buffer overflow vulnerability to execute the win
function and print the contents of flag.txt
.
Understanding the script
Vulnerability: The
main
function declares a buffername
with a size of0x10
bytes (16 bytes). However, it reads up to0x20
bytes (32 bytes) into this buffer usingfgets
, causing a buffer overflow.Objective: The objective is to overwrite the return address of the
main
function on the stack with the address of thewin
function, so that whenmain
returns, it jumps to thewin
function instead.
Exploit
Overview:
The exploit script connects to the remote server
challs2.nusgreyhats.org
on port55432
.It constructs a payload that overflows the
name
buffer and overwrites the return address with the address of thewin
function (0x00000000004011bb
in this case).
Sending the payload:
The script sends the payload to the server using
p.sendline(payload)
.When the server receives the payload and overflows the
name
buffer, it overwrites the return address on the stack with the address of thewin
function.
Executing the win function:
After overwriting the return address, when the
main
function tries to return, it instead jumps to thewin
function.The
win
function is executed, printing "Good job :)" and the contents offlag.txt
, which is the flag for the CTF challenge.
In summary, this challenge involved a buffer overflow vulnerability in the program. By sending a specially crafted input, the return address of the main function is overwritten, causing the program to jump to a "win" function that prints the flag.
Flag: flag{y0u_4r3_n0w_fu11_st4ck_d3v_h3h3}
Last updated