💣 P0wn3d
A detailed write-up of the Pwn challenge 'P0wn3d' from WolvCTF - 2025
📊 Challenge Overview
Category Details Additional Info 🏆 Event WolvCTF - 2025 Event Link 🔰 Category Pwn 💣 💎 Points 50 Out of 500 total ⭐ Difficulty 🟢 Easy Personal Rating: 0/10 👤 Author Didkd Profile 🎮 Solves (At the time of flag submission) 6 solve rate 📅 Date 23-03-2025 WolvCTF - 2025 🦾 Solved By mH4ck3r0n3 Team: QnQSec
📝 Challenge Information
Author: Didkd An introduction to pwn challenges. This is to protect the babies from last year!
🎯 Challenge Files & Infrastructure
Provided Files
Files:
🔍 Initial Analysis
First Steps
This is the first challenge in the
P0wn3d
series. While reviewing the attached files, I noticed that the source file inC
was included, so I skipped runningchecksec
on theELF (Executable And Linkable Format)
.Analyzing the code, it is a
Buffer Overflow
with a guard:
1 2 3 4
struct __attribute__((__packed__)) data { char buf[32]; int guard; };
A structure is declared as
packed
, which ensures that there is no padding betweenbuf
andguard
in the stack. This means we will find32 bytes
(forbuf
) followed immediately by4 bytes
(forguard
, asint
is 4 bytes).Continuing to read, I found a
get_flag
function that reads from theflag.txt
file and prints its content. In themain
function, we find the actual vulnerability:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
struct data first_words; ignore(); /* ignore this function */ printf("Hello little p0wn3r. Do you have any first words?\n"); fgets(first_words.buf, 64, stdin); sleep(2); puts("Man that is so cute"); sleep(2); puts("I remember last year people were screaming at the little p0wn3rs.. like AAAAAAAAAAAAAAAAAAAAAAAAAAAAA!"); sleep(2); puts("Don't worry little one. I won't let them do that to you. I've set up a guard"); if (first_words.guard == 0x42424242) { get_flag(); }
The vulnerability lies in the use of
fgets()
. As we can see, it reads64 bytes
from standard input and stores them in the variablebuf
, which we previously determined to be only32 bytes
in size.Therefore, if we input more than
32 bytes
, we will overwrite data beyond the allocated buffer forbuf
. Since the next variable in the stack isguard
, writing4 bytes
beyondbuf
will overwrite its value.Now, let’s move on to the exploitation phase.
🔬 Vulnerability Analysis
Potential Vulnerabilities
- Buffer Overflow
🎯 Solution Path
Exploitation Steps
Initial setup
To call the
get_flag()
function, we need to enter theif
statement that checks whether theguard
variable is equal to0x42424242
.Converting this value (
0x42
) to an ASCII character gives us:Since
0x42
repeats a total of4
times, our payload must includeB*4
.
Exploitation
To construct the final payload, we first need to fill the buffer of the
buf
variable, which we determined to be32 bytes
, and then overwrite theguard
variable withB*4
to enter theif
statement and triggerget_flag
. Since each character occupies1 byte
, we can directly write a payload like this:
1
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBB
That is,
A*32
(to fill thebuf
buffer) and fourB
s to overwriteguard
and enter theif
statement. Since this payload is quite simple, I sent it directly using Bash:
1
python3 -c "print('A'*32 + 'B' * 4)" | nc p0wn3d.kctf-453514-codelab.kctf.cloud 1337
redirecting the output of
python
via|
directly tonetcat
. This way, when input is requested and expected instdin
, it is automatically sent asAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBB
(the output from Python). Doing this, I obtained the flag.
Flag capture
🛠️ Exploitation Process
Approach
The exploit simply connects to the server and first sends a padding of
A*32
, followed byB*4
to bypass the guard and call the function to obtain the flag.
🚩 Flag Capture
Flagwctf{pwn_1s_l0v3_pwn_1s_l1f3}
Proof of Execution
🔧 Tools Used
Tool Purpose Python Exploit GDB Dynamic Analysis
💡 Key Learnings
Skills Improved
- Binary Exploitation
- Reverse Engineering
- Web Exploitation
- Cryptography
- Forensics
- OSINT
- Miscellaneous
📚 References & Resources
Similar Challenges
Learning Resources
📊 Final Statistics
Metric | Value | Notes |
---|---|---|
Time to Solve | 00:03 | From start to flag |
Global Ranking (At the time of flag submission) | 7/428 | Challenge ranking |
Points Earned | 50 | Team contribution |
Created: 23-03-2025 • Last Modified: 23-03-2025 Author: mH4ck3r0n3 • Team: QnQSec