Skip to content

AoC3 Day 5: Cross-site Scripting


If you are new to TryHackMe, I recommend checking out their Tutorial room to see how the platform works and how you can access the target machine(s). I also highly recommend using your own “attack box”, be it a Kali, Parrot, or some other pentesting oriented Linux distro (in the form of a VM), as opposed to the browser based solution TryHackMe provides. I’ve found that the browser based VM is a lot slower, though others seem to have no issues with it. The only thing using your own attack VM entails is connecting it to THM’s network through VPN, but this is incredibly easy as TryHackMe will supply you with your own OpenVPN configuration file and is outlined below.

Types of Challenges

The TryHackMe platform has multiple types of challenges, each potentially having its own requirements for accessing and completing it. You can identify the type of challenge by looking at the icon on the right-hand side of the collapsible bar for that particular challenge:


Challenges using the “server rack” icon include the use of a deployable machine, and are the most common. Pressing the “Start Machine” button will launch a virtual machine that you have two ways of accessing: using THM’s “attack box”, found at the top of your browser window:

Or, you can instead opt to use your own virtual machine connected to the THM network, which is done (on Linux) by clicking your user icon, “Access”, and then “Download My Configuration File”.

Clicking “Save File”

And by running the following command in a terminal (I might suggest you move the download to another folder, such as “Documents”):

Once you see “Initialization Sequence Completed”, you’ll know you’ve successfully connected to THM’s network. Keep this terminal window open (you can minimize it, however). Return to it and press “Ctrl” + “C” twice once you are ready to disconnect.

After you’ve chosen between THM’s attack box or your own virtual machine, you’ll need the IP address of the target machine, which is what was deployed earlier with the green “Start Machine” button. That information can be seen in a banner at the top of your browser window, or in more detail at the top of the page:

In many cases you’ll be copying that IP address into your attack box/VM’s browser’s address bar, but in other cases you might be accessing it through SSH, RDP, etc. You’ll notice that you can add time to it if needed, or terminate it if you finish early – opening up more resources for other THM users.

Challenges using the “browser” icon will require interaction with a simulated website that can be accessed by pressing the “View Site” seen after expanding the challenge. These challenges will need to be completed from within your browser, and cannot be accessed through a VPN on your own machine due to the fact that they are not true websites.

Challenges with the “download” icon include files – in many cases packet captures (pcaps) or log files to be parsed through using a specific type of software. Where you would like to do this examining is up to you, but you will not be able to use one of TryHackMe’s machines. For examining something like a .pcap file, you will want to install Wireshark on one of your own computers or VMs.

Challenges without an icon focus on either reading material and answering questions, or will include a link to a publicly accessible website that doesn’t require connection to THM’s network, and therefore can be completed from any computer you choose.


TryHackMe; Advent of Cyber 3; Day 5 Walkthrough

Day 5 is geared towards XSS (cross-site scripting), how we can identify sites that may be vulnerable to it, and how attackers might use it in a real-world situation.

The first step after launching the target machine will be to visit it through our web browser, which will bring us to the “Elf Forum”. Click “Login”.

Enter the credentials “McSkidy” and “password” as stated in the challenge description, and click “Login”.

Now click “Settings”

Type in a new password for “McSkidy”, and click “Update”. After hitting submit, we’ll see the URL update to include a “new_password” parameter, containing the value in plaintext.

Now we can return to the “Elf Forum”, click any one of the topics, and then click the thread within.

Now we’ll be checking how the forum handles inputs and whether or not it’s sanitized. We’ll start out with something basic, such as a simple “underline” HTML tag. Click “Leave Comment” once you are done.

The comment is reflected on the forum with the underlined text, which is a good indicator that it may accept other HTML elements, such as a script.

We’ll try leaving the following script in a comment on the same thread, in an effort to execute malicious code on “visitors” to the site. This script will send an HTTP request to the “Settings” page we visited earlier, and change the user’s password to “pass123”. Click “Leave Comment”, and refresh the page.

We’ll see the comment successfully posted, but it contains no text. That’s another good indicator that the comment function on this site is rendering our code truly as code, and not treating it as text. We’ll validate this by viewing the page’s source.

Yep! We can see the syntax highlighting through our browser’s “inspect” tools, so we know it is actually being interpreted as an HTML script element.

Per the challenge description, we’ll want to wait at least a minute to wait for the “Grinch” to visit the forum thread and allow the script to change his password. We’ll click “Logout” at the top of our thread, then “Login”, supply “grinch” and “pass123” (or whatever password you may have specified) and click “Login”.

We’ll click “Settings” again, and this time have an added option of disabling the malicious plugin that the “Grinch” implemented on the website.

Now we are presented with our flag!