Road
Road
Room link: https://tryhackme.com/room/road
Scanning
I first conducted a scan using nmap with the -A option.
ajread@aj-ubuntu:~/TryHackMe/practice$ nmap -A -Pn [REDACTED]
Starting Nmap 7.80 ( https://nmap.org ) at 2022-02-24 20:39 EST
Nmap scan report for [REDACTED]
Host is up (0.093s latency).
Not shown: 998 closed ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.2 (Ubuntu Linux; protocol 2.0)
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Sky Couriers
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 21.43 secondsEnumeration
I did some enumeration of the http service using both nikto and gobuster.
I also used feroxbuster(https://github.com/epi052/feroxbuster) to do some more enumeration. But, it didnt reveal anything of note.
The /v2 had a login page that allowed me to register for an account. I registered for an account with creds email@gmail.com:test as well as a random set of numbers for phone number. Looking around the site, I wasnt able to interact much. The Profile page talked about a user named admin with email admin@sky.thm.
With the admin email, I can now try to reset its password using the ResetUser page. When a user requests a new password, it sends a POST request to lostpassword.php with the data below.
Therefore, I can change the uname form-data to be admin@sky.thm.
And, I was able to authenticate with credentials admin@sky.thm:test. Now, I moved over to the profile editor again and uploaded a test txt file to see where it saves the profile picture. Looking in the source code of profile.php, it appears the images are saved at /v2/profileimages/.
Initial Access
I created a php reverse shell using pentest monkey and uploaded it as my profile picture. Then, I opened a netcat listener at port 9999 (the port I chose for the php reverse shell).
And curl'd the location where the images are stored to execute the reverse shell.
I got a shell!
I was also able to read the user flag.
Privilege Escalation
I looked around the machine and found that there is a mongodb user within /etc/passwd.
Therefore, all I had to do was run mongodb in the terminal. When I dropped into the db, I listed the available dbs with show dbs.
From the output of show dbs, I checked to see what collections each DB had. The backup db had a collection called user with credentials for user webdeveloper.
With the credentials, I was able to ssh into the box as user webdeveloper.
The sky_backup_utility doesnt appear to do anything that is useful for privilege escalation. However, it does appear the box is vulnerable to pkexec priv esc. But, there is a twist because this shell doesnt work well with pkexec since it is non-graphical. Therefore, I had to create two ssh sessions with user webdeveloper.
I even tried to run the pkexec priv esc normally (https://github.com/ly4k/PwnKit) and it didnt work.
Therefore, I set up two ssh sessions. In the first one, I checked to see what the PID was using echo $$.
Then, in the second one i ran pkttyagent to authenticate the process that will be requesting pkexec.
Finally, I ran pkexec with a bash shell.
It requested authencation using the pkttyagent in the other session so I input the password for user webdeveloper.
And it dropped me into a root shell in the first session!
The second session also completed authentication.
Assistance
Writeup done with the help of: https://wiki.thehacker.nz/docs/thm-writeups/road-medium/.
Last updated