Museum

Directory Traversal + SSRF

On visiting the page, I was given a catalog page.

The submit button is a dead end. Visiting any "artifacts" gave me an URL with filename as a parameter.

http://challenge.nahamcon.com:30930/browse?artifact=angwy.jpg

Given the use of filename to fetch files, I believe this page is vulnerable to Directory Traversal.

Basically, the difference is that with a file inclusion vulnerability, the resource is loaded and executed in the context of the current application. A directory traversal vulnerability on the other hand, only gives you the ability to read the resource.

Trying some simple payloads like ../ returns no result. Then I tried fuzzing using the LFI-Jhaddix wordlists from SecLists and got some interesting results.

Visiting the site with the given payload, we got the output of /etc/passwd:

We also got the app's source code. (I read /proc/self/cmdline to get the file path)

Analyzing this source code, it is obvious that flag.txt is blacklisted to avoid direct read of that file. I also have 2 hidden routes private_submission and private_submission fetch which uses urllib.request.urlretrieve to download a webpage and store to a file.

urllib.request.urlretrieve(url, filename=None, reporthook=None, data=None)

Copy a network object denoted by a URL to a local file. If the URL points to a local file, the object will not be copied unless filename is supplied. Return a tuple (filename, headers) where filename is the local file name under which the object can be found, and headers is whatever the info() method of the object returned by urlopen()arrow-up-right returned (for a remote object).

The private_submission_fetch function is a little bit limited, since it only fetches a website but not storing it anywhere; while private_submission allows to save the webpage to a specific files, but that route is only accessible from localhost.

Therefore, the idea here is to access the private_submission_fetch route from the private_submission, fetch the flag file and save it to another file not named flag.txt.

Final payload:

Last updated