Warmup - Babyflow
Last updated
Last updated
In this writeup, we'll walk through solving the "Warmup" PWN challenge step by step. The goal is to exploit a buffer overflow vulnerability to bypass a password check and reveal the flag.
We start by running binary ninja to decompile the file.
We examine the decompiled code snippet:
The program asks for a password input and checks it using strncmp
against the hardcoded string "SuPeRsEcUrEPaSsWoRd123"
.
If the password is correct, it checks the value of var_c
.
If var_c
is still 0
, it prints a message asking if you are the admin.
If var_c
is non-zero, it reveals the flag.
We need to:
Input the correct password to pass the check.
Overflow the buffer to modify var_c
and set it to a non-zero value, which will reveal the flag.
Buffer Overflow:
The buffer size is 50 bytes, and the password takes up the first 22 bytes.
That leaves 28 bytes for padding and overflow.
We need to overflow into var_c
(a 4-byte integer) and set it to 1
.
Now, let's write a Python script to send the payload to the server.
Once the script is ready, simply run it using:
If the exploit is successful, the program will print the flag:
This challenge demonstrates a classic buffer overflow attack. We bypass the password check by inputting the correct password, then overflow the buffer to manipulate a local variable (var_c
). When var_c
is changed from 0
to 1
, the program reveals the flag.
By following these steps, we successfully exploited the vulnerability and obtained the flag. This writeup covers the basic principles of exploiting buffer overflows in C programs and how to automate the process using Python.