XSS Attack
XSS Attack
In this practical we will learn how to perform a standard XSS attack using html-based queries that we will
send back to the vulnerable web app. For this practical we will use our bwapp vulnerable VM. Start the
machine, log in to the web app and select Cross-site-Scripting — Reflected GET challenge.
Once the webpage for the challenge opens we will see two input fields. We will start by placing a=our
names or any other data in these fields and observe the URL after we submit the data. Here we can see
that both values we entered are now shown in the URL in web browsers address bar. The fact that the
value of a variable is now a part of the URL is an indicator that we can input non expected values for a
variable and inject Javascript code.
So we can now try and write some basic html syntax into the fields in the page and check the behavior of
this web app <b>student
xss
If we look at the output on the screen we can see that the first name value (student) is displayed in bold
letter and that in the URL we can find the HTML code <b> r. The fact that the app was actually accepting
and decoding HTML code instead of rejecting or displaying it as plain text (instead of rendering it and
showing student) is a clear sign that we can execute code through these fields.
As we alredy know that the fields will accept entries with < & > tag instead of bold letter we will
inject <script> tag into the field.
<script>alert( 'hacked' )</script> (you can put this in one or both fields)
As you can see the web page displayed a pop up window with the exact text that we wrote!