Mango just retired today. I had lots of fun solving it and I finally learned about NoSQL injections. Its IP address is ‘10.10.10.162’ and I added it to ‘/etc/hosts’ as ‘mango.htb’. Without further ado, let’s jump right in!
Scanning & Sub-Domain Enum
As always, a light nmap scan was enough to get me started:
When I tried accessing port 80, I got a 403 error:
However, port 443 returned a funny clone of Google called ‘Mango’:
Before testing this app for vulnerabilities, I mad sure the HTTPS certificate couldn’t be used to find other domains:
The script discovered a sub-domain, so I tied accessing it. However, the page was identical to the one I got before:
After searching round for a bit, I realized I haven’t accessed the new sub-domain via HTTP yet. I did that and discovered a new sub-domain:
Exploiting MongoDB
Since the machine name is Mango, I though that the backend database engine is almost certainly MongoDB. I used this cheatsheet to test for a possible NoSQL injection, and I found one :). I then tried logging in with multiple usernames and found that ‘mango’ was a valid one. The script below gave me the password for that user:
After letting it run for a few minutes, I got the user’s password:
I used ‘h3mXK8RhU~f{]f5H’ to log in to the application and I got the following page:
I tried seeing if there is any user named ‘admin’, and there was. His password might come in handy, so I used the same script to get his password (I just changed the username variable from “mango” to “admin”):
However, the admin page looked exactly the same:
Getting user.txt
After a bit of playing around, I tried to log in with SSH using the website credentials. It worked, but only for the mango user:
There was no ‘user.txt’ file, so I enumerated the users on the machine:
There was an user called admin, so I tried using su to pivot to his account (I used admin’s web platform password):
The user proof starts with ’79’ 😉
Exploiting jjs to get root
Once I submitted the user proof, I started enumerating the machine again. While reading through the SUID binaries, one stood out:
I didn’t know what ‘jjs’ was, so I searched Google and I found the following explanation on Oracle’s site:
The jjs command-line tool is used to invoke the Nashorn engine. You can use it to interpret one or several script files, or to run an interactive shell.
Link
Helpful, as always :
. Fortunately, I also found the jjs binary on GTFOBins. The basic idea is that an attacker can execute a specially crafted Java program that executes bash commands.
The first two characters of the root proof are ‘8a’ 😉