© 2018 Caendra Inc. - Hera For Waptv3 - Cross Site Scripting
© 2018 Caendra Inc. - Hera For Waptv3 - Cross Site Scripting
Once you are connected in VPN to the lab environment, all the web applications will be
available at the following URL: http://info.xss.site/.
There are three main sections for each type of lab: Video, Lab, Challenges.
• Video section contains web applications used during video lessons. Therefore, if
you need any information about the scenario, the attacks and so on, please refer to
the corresponding video.
• Labs section contains web application where you can practice the techniques of the
specific module and have solutions. You can find them later in this manual
• Challenges labs do not have solutions; otherwise, why call them challenges? If you
study the course and think like a penetration tester, you will achieve the goal!
The best tool is, as usual, your brain. Then you may need of:
• Web Browser
• Burp Suite
Once you have your virtual network ready, configure the following IP address as default
DNS: 10.100.13.37
• WINDOWS: change the property of the TAP network device, adding as first DNS
server of the IP of the server.
• LINUX: add an entry into /etc/resolv.conf file with the IP address of the server
In this lab, you will find the vulnerable parameter and perform an XSS injection attack.
Find the vulnerable parameters, build a malicious link and show an alert window to anyone
who clicks on it.
You will find a vulnerable parameter and perform an XSS injection attack.
In this lab, you will find the vulnerable parameter and perform an XSS injection attack.
Find the vulnerable parameters, build a malicious link, and show an alert window to
anyone who clicks on it.
They have put up a website where they can share with the world their reading
preferences, preferred authors, and photos.
The club has a Vice President of Bookshelf and a Club President. They are the sagest and
blessed members and live a life of books, introspection, and asceticism.
You want to check out if any of the website features is poorly coded and presents any
cross-site scripting.
Since XSS is an input validation attack, you should first determine which pages accept user
input. Not all of these are subject to XSS, but it is a good subset to begin with.
Then, try to insert HTML tags as probes to verify if any XSS is present. Make sure to
understand what kind of code you can inject, if HTML or also JavaScript.
They have put up a website where they can share with the world their reading preferences,
preferred authors, and photos.
The club has a Vice President of Bookshelf and a Club President. They are the sagest and
blessed members and live a life of books, introspection, and asceticism.
You want to find out if the latest improvements in security that Poema reading club has put
in place are effective.
You should prove them wrong and demonstrate how you can still run JavaScript code in
one of the vulnerable user input channels.
They have put up a website where they can share with the world their reading
preferences, preferred authors, and photos.
The club has a Vice President of Bookshelf and a Club President. They are the sagest and
blessed members and live a life of books, introspection, and asceticism.
The reading club webmaster is proud to announce a secure commenting feature. You
should find two different persistent XSS in the commenting pages.
As a proof of concept of the hack, you want to change the web page tag line from “Reading
club for introspective people with social issues” to “Reading club for introspective people
with social and XSS issues.”
Please refer to this page to know how to manipulate an HTML page with DOM for superb
XSS defacements:
• http://www.w3schools.com/js/js_htmldom.asp
You can achieve the above exploiting any of the two vulnerabilities.
This type of vulnerability is different from reflected XSS because the user input is
processed by DOM functions before being printed out in the response HTML. In reflected
XSS, the input is immediately reflected on the page.
Start Burp proxy and set the target scope. From now on, all of the HTTP requests made by
your browser to that target will appear in the Site map tab.
Come back to Burp proxy and go to the Site Map tab to analyze the requests made by your
browser; your parameters will appear here. The web application performs a GET HTTP
request to the page getLuckyNumber.php with the parameter name. This is the
parameter you will follow up on in the next steps.
In the next task, you will analyze the HTTP response message to study the insertion point
of the input data.
In your browser, your input data appears between the word Hello and the words ‘your
lucky number is.’
The input data (James in our case) does not appear between the words. In fact, they do not
appear in any part of the response message. You can conclude from this that your input is
not reflected in the response message.
The answer is simple: it is printed via the DOM API. If you inspect the response message,
you will find the following JavaScript code:
window.onload = function() {
var site=document.location.href;
var index = site.indexOf("=", 0);
name="";
if(index != -1) {
name=site.substr(index+1);
}
name=decodeURIComponent(name);
document.getElementById('name').innerHTML=name;
}
• Reads the current location from the location object and stores it in the site
variable. In our case site is:
http://1.lab.xss.site/getLuckyNumber.php?name=James
• Extracts the name parameter from the current location and stores it into the
variable name. In our case name is:
James
• Replaces each escape sequence in the name with the character that it represents (by
calling the DOM API decodeURIComponent()). This code has most likely been
inserted by the developer to correctly display non- alphanumerical characters (like
the space or some other characters). But, this is a security issue because it will even
decode encoded characters (for example the html reserved chars < > )
• Inserts the name as content of the html tag <span name=”name”>. This is the
insertion point.
The third action ensures that your input will be stored into the name variable without any
changes or filtering.
The fourth action ensures that your input will be interpreted as HTML code.
You can conclude that the input is handled completely on the client- side. Your input will be
processed via JavaScript and will be handled without any filtering or encoding.
You can conclude from all of this that the web application is definitely vulnerable to XSS in
the parameter name and that the XSS is a DOM XSS.
As previously stated, the input is managed completely on the client-side. Moreover, there is
not any filtering or encoding; you can now start the exploitation process.
This HTML code will try to insert an image into the current page. The image has been
intentionally inserted with an incorrect path for the sole reason of triggering the onError
event. The code related to the onError event contains the malicious code.
http://1.lab.xss.site/getLuckyNumber.php? name=<img
src='nevermind' onerror="alert('XSS');" />
When your victim opens the previous link, his browser will run your XSS code showing the
classic XSS alert window.
1. The attacker inserts malicious input via a page of the web application (for
example, through a form or within the URL)
2. The input is not filtered or replaced and appears reflected in the response.
3. The input is stored (for example on a DBMS or server storage) and will be shown
to all viewers of that page from now on.
This type of attack is said to be persistent because the malicious user input will be put in
persistent storage and will be shown to each visitor of the page. There is no need to send a
malicious link to your victims.
Enable Burp proxy to intercept all HTTP requests from your browser and the responses
sent by the web server.
• name
• site
• message
Now you should note where in the HTML response input data is inserted. Forward the
intercepted request and wait for the response:
• name
o as content of the HTML element a
o <a . . . >Polite user</a>
• site
o as content of the attribute href of the HTML element a
o <a href="http://yesiam.apoliteuser.com" >
• message
o As content of the HTML element span
o <span . . . >I'm a polite user and I don't want to
inject HTML/Javascript code</span>
First, try to inject your XSS payload via parameters name and message. So you need a
payload like this:
If filtering occurs, you will try injection through the other parameter. In the next step, you
will check whether the web application filters the user input in all the previous parameters.
To check if the parameters name, message, and site are filtered, you will send a test
payload and observe if and how they have been filtered or replaced by the web server.
For each input parameter, your test payload will be: < > / ;
These characters are special characters for HTML syntax. If the web application does not
filter them, they will be interpreted as HTML code and not as text.
To send the test payload, go to Burp suite, select the previous request (that performed the
sending operation) from the Site Map and send it to Burp Repeater. (Burp Repeater is a
simple tool for manually manipulating and then re-sending individual HTTP requests.)
As previously stated, the parameters message and name can be exploited by using a
payload like this:
For example, you can fill in the web form with the following data:
This type of attack is said to be reflected because the user input appears reflected in the
response and it is interpreted as HTML code.
Start Burp Proxy and set the target scope. From now on, all of the HTTP requests made by
your browser to that target will appear in the Site map tab.
After asking for your lucky number, you will get the answer from the oracle:
The web application performs an HTTP request to the page getLuckyNumber.php with
the parameter name. This is the parameter you need to check in the next steps.
In the next task, you will analyze the HTTP response to determine the insertion point of
your input data.
You must pay critical attention to where your input data is placed in the response.
This information is necessary to build a working XSS payload and it becomes critical in case
the server is filtering the input.
Now you need to analyze the response of your previous HTTP request. In this case, the user
input is reflected within the HTML paragraph element p:
For this insertion point, you should use a payload like this:
Now you should check whether the web application filters or changes (for example by
replacing characters) the previous values.
The easiest method to use is to check whether the web application filters the following
characters: < > /
Go to Burp Proxy, select the previous request from the Site Map and send to the Burp
Repeater. Burp Repeater is a simple tool for manually manipulating and reissuing
individual HTTP requests.
Go to the Repeater tab, select the request and change the parameter name from the old
value to the test payload above (< > / ).
The special characters are not filtered by the web application. You have found and are
ready to exploit this XSS vulnerability.
<script>alert('XSS')</script>
http://3.lab.xss.site/getLuckyNumber.php?
name=<script>alert('XSS')</script>
When your victim opens the previous link, his browser will run your XSS code showing the
classic XSS alert window.