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 Joker.
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 Joker, is retired.
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 Joker machine IP is 10.10.10.21.
- We will adopt the usual methodology of performing penetration testing to begin. Let’s start with enumeration in order to learn as much information about the machine as possible.
- As usual, let’s start with the nmap scan to learn more about the services running on this machine.
- As we can see, port 22 and proxy is running on this machine on 3128. [CLICK IMAGES TO ENLARGE]
<<nmap -sC -sV -oA Joker 10.10.10.21>>
- We’ll run a full UDP port scan on this machine as well.
<<nmap -sU -T4 10.10.10.21>>
- This also reveals a lot of other ports. TFTP looks especially interesting among them.
Now we know that squid proxy is running on this machine and its default password location is at /etc/squid/passwords, we’ll log in and extract that.
- We run john on this password.
<<john –wordlist=/usr/share/wordlists/rockyou.txt passwords>>
- We got the password! Now let’s move onto the next enumeration. Since squid is running on this machine, let’s change the browser proxy to point to the same.
- As soon we change that and try to access the page, we are asked to enter a username and password. Doing so, it gives us a hint: “kalamari.”
- Entering the username and password discovered above, we get the page below.
- We tried to enumerate this page, but it looks like we hit a dead end. We’ll go back to enumeration to brute-force the directories via proxy.
<<dirb http://127.0.0.1 -p 10.10.10.21:3128 -P kalamari:ihateseafood -r>>
- We got a hit on the console page. Browsing that gives us a Python Interpreter page. This strikes to get a reverse shell directly via Python Interpreter. After trying for a bit, I was not able to get a TCP shell back on a nc listener.
After much enumeration and looking into tables, it looks like TCP outbound is blocked. So we switch to get back a UDP via socat listener, as shown below.
- We got the shell back, but we need to elevate in order to get the user flag. Checking the sudo permissions for the user, it looks like we can run sudoedit as user alekos. The interesting thing is the wild cards in the path.
- Exploiting the wildcard vulnerability created a directory named lhm under /var/www/testing and created the page default.html. We then make a symbolic link to the key of user alekos so that we can overwrite it with our own generated key.
<<ln -s /home/alekos/.ssh.authorized_keys layout.html>>
- We now generate our own key.
- We run the elevated sudoedit command and paste the generated public key.
<<sudoedit -u alekos /var/www/testing/lhm/layout.html>>
- After that, we can login with user alekos via the private key we created above.
- We enumerate to grab user.txt.
- Now enumerating under this, we can see there are two directories, Backup and Development. Backup is actually taking backups of the Development directory!
- Since it has been executed as root but owned by our user, we can try it to take a backup of the root directory instead.
- We rename the development directory and configure a symbolic link of root to Development.
- After five minutes, it gives us a new compressed folder which is of the actual root directory. We enumerate to grab the root flag.
This is a nice machine with a lot of emphasis on deep enumeration and how to exploit elevated permissions with wildcards.
We’ll be continuing this series with more in the way of interesting machines.