Contents

🌐 Forbidden Paths

A detailed write-up of the Web challenge 'Forbidden Paths' from PicoCTF - 2022

/images/PicoGym/PicoCTF-2022/ForbiddenPaths/challenge_presentation.png
Challenge Presentation

📊 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

1
Files: None

🔍 Initial Analysis

First Steps

Initially, the website appears as follows:

/images/PicoGym/PicoCTF-2022/ForbiddenPaths/site_presentation.png
Site Presentation

The listing of the directory /usr/share/nginx/html is displayed, as suggested by the challenge description, and given the title and context of the challenge, a Path Traversal immediately 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 file flag.txt as 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 file flag.txt is located right in the root directory, we won’t be able to send just /flag.txt as 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 the dot refers to the current directory we are in, and dotdot refers 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 the flag.txt file, since we are currently in the /usr/share/nginx/html directory, 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 the flag.txt file. 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

/images/PicoGym/PicoCTF-2022/ForbiddenPaths/manual_flag.png
Manual Flag

🛠️ Exploitation Process

Approach

The automatic exploit simply sends a POST request to /read.php, sending ../../../flag.txt to exploit the Path Traversal vulnerability. Then, it extracts the flag from the response using a regex.

🚩 Flag Capture

Flag

Proof of Execution

/images/PicoGym/PicoCTF-2022/ForbiddenPaths/automated_flag.png
Automated Flag
Screenshot of successful exploitation

🔧 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: *