COMP6841 Something Awesome

z5418112 (Sam Zheng)

Baby Nginxatsu

By: makelaris

1 hour

Medium
PHP
Path Traversal
Rainbow Table

When first launching this application, we end up on a simple login and registration screen. Just to test out the website a little and see where we end up, I just registered an account and logged in, which landed us on the following page.

The application at hand

The application at hand

Interestingly, we weren't given source code for this particular challenge, so we kind of have to go in blind. I first tried to look into the source code from inspect element, but it unfortunately didn't seem to reveal too many clues as the HTML file itself was difficult to read, and the JS files were all in compiled JS.

Given that the name of this challenge had something to do with Nginx - it probably had something to do with the Nginx configurations that the website was providing. To get a feel for what the website was doing, I requested for a configuration with the default parameters given on the website. A configuration was generated, and I opened the file. This was what I saw:

...
include /etc/nginx/mime.types;
server {
listen 80;
server_name _;
index index.php;
root /www/public;
# We sure hope so that we don't spill any secrets
# within the open directory on /storage
location /storage {
autoindex on;
}
...

"We sure hope so that we don't spill any secrets within the open directory on /storage" Well that's interesting isn't it - the /storage folder is open. This was re-inforced when clicking on the 'Raw Config' button:

From here, we were taking to a URL path that looked something like /storage/nginx.conf. By removing the later part of the URL, we were able to traverse the directory and access the storage directory of the server.

Storage directory accessed

Storage directory accessed

I notice that there was a file called db_backup. Maybe there could be something useful in there for us... Downloading the backup, I needed to first untar the file, which landed me with a SQLite database file. I opened the database file using SQL Viewer in VSCode. The challenge on the page actually gave a little hint in that we were looking to get the credentials to the admin account to get the flag. There's a users table within the database, and it seems like the API token field is a bit of a red herring.

SQLite DB, users table

SQLite DB, users table

One of the user's emails conveniently had 'adm' in it, which I presumed to be the admin account. Of course, the password wasn't just stored in plain-text, because that would be too easy. Instead, it was hashed. My initial thought was to try and brute-force the hash, but then I had an easier thought to try a rainbow table approach first.

Using https://crackstation.net/ , I put in the hash of the password, and lo-and-behold - the password was revealed to be adminadmin1. Logging in with these credentials...

Flag!

Flag!

Reflection and Learnings

Last Writeup

JSCalc

Next Writeup

Pop Restaurant