🌐 Forbidden Paths
A detailed write-up of the Web challenge 'Forbidden Paths' from PicoCTF - 2022
📊 Challenge Overview
Category Details Additional Info 🏆 Event PicoGym Event Link 🔰 Category Web 🌐 💎 Points Out of 500 total ⭐ Difficulty 🟡 Medium Personal Rating: 0/10 👤 Author LT ‘syreal’ Jones Profile 🎮 Solves (At the time of flag submission) 25.552 solve rate 📅 Date 13-02-2025 PicoGym 🦾 Solved By mH4ck3r0n3 Team:
📝 Challenge Information
Can you get the flag? We know that the website files live in /usr/share/nginx/html/ and the flag is at /flag.txt but the website is filtering absolute file paths. Can you get past the filter to read the flag?
🎯 Challenge Files & Infrastructure
Provided Files
1Files: None
🔍 Initial Analysis
First Steps
Initially, the website appears as follows:
The listing of the directory
/usr/share/nginx/htmlis displayed, as suggested by the challenge description, and given the title and context of the challenge, aPath Traversalimmediately comes to mind. An application affected by this vulnerability allows an attacker to read arbitrary files located on the web server (in fact, we are interested in reading the fileflag.txtas defined in the challenge description). Additionally, we are told that the site filters absolute paths. An absolute path is defined as such when the location of an element is specified starting from the root (/) of the filesystem. Therefore, since the fileflag.txtis located right in the root directory, we won’t be able to send just/flag.txtas a payload, due to the filter on the absolute path. Let’s move on to the exploitation.
🔬 Vulnerability Analysis
Potential Vulnerabilities
- Path Traversal
🎯 Solution Path
Exploitation Steps
Initial setup
Once we understand that the filter doesn’t allow us to directly access
flag.txt, we need to find a solution for this. To navigate the file system via CLI (Command Line Interface), we can also use.or.., where thedotrefers to the current directory we are in, anddotdotrefers to the parent directory (which we can call the mother directory).
Exploitation
Once this is understood, to navigate back to the root directory
/and extract theflag.txtfile, since we are currently in the/usr/share/nginx/htmldirectory, we need to go back exactly 3 directories. This is because:
- With the first
../we will reach/usr/share/nginx,- With the second, we will reach
/usr/share,- With the third, we will reach
/.So, by specifying the path
../../.., we correctly reach the root directory/and can access theflag.txtfile. To summarize, the payload to send will be../../../flag.txt, with which we will bypass the filter on the absolute path and retrieve the file content, where the flag is written inside.
Flag capture
🛠️ Exploitation Process
Approach
The automatic exploit simply sends a POST request to
/read.php, sending../../../flag.txtto exploit thePath Traversalvulnerability. Then, it extracts the flag from the response using a regex.
🚩 Flag Capture
Flag
Proof of Execution
🔧 Tools Used
Tool Purpose Python Exploit
💡 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:00 | From start to flag |
| Global Ranking (At the time of flag submission) | Challenge ranking | |
| Points Earned | Team contribution |
Created: 13-02-2025 • Last Modified: 13-02-2025 *Author: mH4ck3r0n3 • Team: *