HackTheBox - ServMon
ServMon is an easy Windows box where the initial access is achieved with the help of a directory traversal vulnerability. The privilege escalation to NT AUTHORITY\SYSTEM requires exploiting a service monitoring agent called NSClient++. The privilege escalation proof of concept gave me some pain, but I managed to figure it out in the end. Fun box!
Nmap results
FTP enumeration
Like the nmap scan says, the FTP server allows anonymous login.
There we have two files: Confidential.txt
and Notes to do.txt
.
Confidential.txt:
Notes to do.txt:
So we have two usernames, Nathan and Nadine. We also now know that Nathan has a Passwords.txt file on his Desktop folder. The path for this is most likely C:\Users\Nathan\Desktop\Passwords.txt.
Website enumeration
On port 80 we are redirected to http://10.10.10.184/Pages/login.htm
where we have a NVMS-1000
login page.
Using searchsploit nvms
we see that NVMS-1000 is vulnerable to a directory traversal.
The proof of concept for this shows directory traversal is possible with the following payload:
Let’s intercept the HTTP request with Burp Suite by refreshing the NVMS-1000 login page and change the GET request to:
With this we get a list of passwords. I saved these to a file called pass.txt and started brute forcing.
Brute forcing the FTP server did not give any results, but the SSH matched a password to user Nadine:
Privilege Escalation
Logging in as Nadine via SSH and enumerating the host I found a program called NSClient++
.
Inside the NSClient++ install folder we have file nsclient.ini
which has a password and states
that only allowed hosts are the localhost.
Looking at the open ports with netstat -ano
I saw port 8443
was listening on the localhost.
This port was not detected by the nmap scan.
I decided to create a reverse SSH tunnel to see what is the deal with this port:
-L
= create a local SSH tunnel
8443
= the port we want to use on our machine (can be any port)
127.0.0.1:8443
= connect to port 8443 on the local machine (target machine)
nadine@10.10.10.184
= establish the tunnel as user Nadine
Now we can open the site on our machine: https://127.0.0.1:8443
I used the password found in nsclient.ini
file to log in. After this my goal was to
find the version of the install NSClient++. The web interface did not leak this, so
I took a look inside the install folder where there was changelog.txt
with last update in
early 2018. This meant we probably are dealing with an old ass version, which more than likely
is vulnerable to something.
Researching this I found a privilege escalation from 2019.
The PoC has you doing all kind of funky stuff on the web interface scheduling external scripts and what not.
I had no success replicating this via the GUI, so I decided to take a different route.
Digging through the NSClient++ documentation, we see that we can do this with the API. We can list the available scripts:
I created a simple .bat-file reverse shell script that I would upload and run.
ebin.bat:
For this we need to upload a nc.exe
binary to the target host.
Kali most likely has nc.exe on there by default (locate -i nc.exe
), but you can also download it for example from packetstormsecurity.
Navigate to C:\Temp folder on the target host and download the file:
Back on our machine, upload the script to NSClient++ and setup a listener to catch that reverse shell:
Now we can go to the web GUI console (https://127.0.0.1:8443/index.html#/console
) and run the script by
just typing ebin
and pressing Run.
We get a reverse shell as NT AUTHORITY\SYSTEM on our port 8808 listener.
Rooted :)
Don’t forget to remove the script.
Thank you for reading!