🌐 Lucky Flag
A detailed write-up of the Web challenge 'Lucky Flag' from LaCTF - 2025
📊 Challenge Overview
Category Details Additional Info 🏆 Event LaCTF - 2025 Event Link 🔰 Category Web 🌐 💎 Points 500 Out of 500 total ⭐ Difficulty 🟢 Easy Personal Rating: 1/10 👤 Author r2uwu2 Profile 🎮 Solves (At the time of flag submission) 531 solve rate 📅 Date 08-02-2025 LaCTF - 2025 🦾 Solved By Azan Shahid Team: QnQSec
📝 Challenge Information
Just click the flag :)
lucky-flag.chall.lac.tf
🎯 Challenge Files & Infrastructure
Provided Files
1Files: None
🔍 Initial Analysis
First Steps
Initially, the website appears as follows:
The first thing I did was explore the source page, and I found a script called
main.js:As we can see, this is where the flag generation code resides, and it appears to be encrypted using an
XORwith the character0x62. As we know,XORis reversible, so let’s jump straight into the exploitation.
🔬 Vulnerability Analysis
Potential Vulnerabilities
- (KPA) Known Plaintext Attack
🎯 Solution Path
Exploitation Steps
Exploitation
The exploitation is quite straightforward: you simply apply the
XORoperation (^0x62) again to the encrypted value to retrieve the original value. So, I wrote a couple of lines inJavaScriptand executed them directly in the console, successfully obtaining the flag:
1 2 3 4 5 6 7let enc = ["\u000e", "\u0003", "\u0001", "\u0016", "\u0004", "\u0019", "\u0015", "V", "\u0011", "=", "\u000b", "U", "=", "\u000e", "\u0017", "\u0001", "\u0009", "=", "R", "\u0010", "=", "\u0011", "\u0009", "\u000b", "SS", "\u001f"]; // Step 1: XOR each character's charCode with 0x62 let decoded = enc.map(char => String.fromCharCode(char.charCodeAt(0) ^ 0x62)); // Step 2: Join the decoded characters let flag = decoded.join(''); console.log(flag);
Flag capture
🛠️ Exploitation Process
Approach
The automated exploit performs the same action as the JavaScript code but in Python. It also handles the case where the character might be Unicode or not:
🚩 Flag Capture
Flag
Proof of Execution
🔧 Tools Used
Tool Purpose Python Exploit ChromeDevTools Web Testing
💡 Key Learnings
Skills Improved
- Binary Exploitation
- Reverse Engineering
- Web Exploitation
- Cryptography
- Forensics
- OSINT
- Miscellaneous
📚 References & Resources
Learning Resources
📊 Final Statistics
| Metric | Value | Notes |
|---|---|---|
| Time to Solve | 00:01 | From start to flag |
| Global Ranking (At the time of flag submission) | 25/665 | Challenge ranking |
| Points Earned | 500 | Team contribution |
Created: 08-02-2025 • Last Modified: 08-02-2025 Author: mH4ck3r0n3 • Team: QnQSec