Stored XSS and stealing session cookies
In this module, we exploit the XSS vulnerability in the exercise target, so you can start the task below and repeat the steps at your own pace. The task uses the BurpSuite tool.
XSS vulnerabilities can be found practically anywhere, where the application allows the user to input something that the application will return back to the browser at some point. The first step in searching for such vulnerability is to send an input to the application and search the HTML code for a place where the input is reflected.
Let's start by sending a message to the chat and finding it in the HTML response.

You can, for example, use the search field provided by BurpSuite when searching for your message from the HTML code.

Next, HTML-formatted input will be sent to the application. If the application is not vulnerable, it will convert HTML characters such as < and > into a secure format < and >. However, if the application is vulnerable, the characters will remain as is in the HTML response, giving you the opportunity to make arbitrary modifications to the application's HTML code.
In the image below, we enter <b>hello</b> and find that the application is vulnerable. Note that the input is URL-encoded.


This allows us to conclude that this website is vulnerable. Next, we will attempt to exploit this vulnerability and steal the main user's session cookies.
Adding JavaScript code to the page
First, let's ensure that we can input JavaScript code into the page using the traditional <script> element. For example, in security audits, a common Proof of Concept (PoC) is to display a JavaScript alert as follows:
1<script>alert(1)</script>When you see the alert box on the page, you have verified the vulnerability as well as your ability to use JavaScript code in an attack. Next, let's see how the vulnerability can be exploited.
Learn to hack — start here
Hundreds of interactive courses, virtual labs and CTF challenges in your browser. Start a free trial — no card required.