Capture the flag (CTF)

Hack the Box (HTB) machines walkthrough series — ServMon

Security Ninja
August 10, 2020 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 ServMon.

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 ServMon, 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 ServMon machine IP is
  3. We will adopt our usual methodology of performing penetration testing. 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 around the services running on this machine.
  5. As we can see, multiple ports are listed. As a best practice, I always do a full port scan to see if there are more ports that got discovered. In this case, there were and we found basic ports such as 21 and 80 on the full port sweep. [CLICK IMAGES TO ENLARGE]

    <<nmap -sC -sV -oA ServMon>>

  6. Let’s start with port 21 to see if we can make an anonymous connection.
  7. As can be seen above, we can log in anonymously. We got two user directories.
  8. Looking into them, we got two files. Let’s download them to a local box.
  9. Below are the contents of these files, which give tons of information.
  10. Let’s move onto port 80. Here, we’ve gotten the NVMS website. Looking into exploits for this software, I got a directory traversal one.
  11. I’m going to use the directory traversal exploit to see the passwords on Nathan’s desktop. Below, it can be seen in action. As a result, we got multiple passwords.
  12. Let’s use them for user Nadine and try to SSH to the box, since port 22 is enabled on this. And … we’re in.
  13. We grab the user.txt flag.
  14. Now, going back to the notes file recovered during FTP phase, there is NSClient also that the user has worked on. We got a hit for the same from the Nmap scan on port 8443.
  15. Now NSClient++ also has an exploit available, and we will try to follow the same.
  16. First, the admin password for NSClient can be available in nsclient.ini. We’re confirming the same below.
  17. Now let’s browse the NSClient++ UI with this information and enter the password found above. (Note: Accessing directly on server port 8443 was very unstable, so I port-forwarded to my local machine).
  18. The password worked and we are in. Next, we’re following the next steps on the exploit to upload the nc.exe into the machine and execute a reverse shell as a part of a script. We then trigger the script via a query.
  19. We will all do this since we have the admin password also.
  20. I tried to do this via a PowerShell one-liner and a download cradle, but it seems like AMSI is protecting it. I disabled the AMSI in the Nadine prompt, but still, it was only working for her prompt and not as a system level setting.
  21. Circling back, we uploaded the nc.exe to the machine.
  22. And now, uploading the ‘hlm.bat’ script and giving it the command to spawn a reverse shell. And then executing the uploaded script.
  23. We got a privileged shell back as soon as the script was executed.

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.

This was one of the simplest boxes HTB has to offer. FTP, followed by two services with working exploits, is simple and straightforward to follow and exploit. However, I would still like to do it with a PS cradle.

We will continue this series with more examples of interesting HTB machines.

Security Ninja
Security Ninja