Mar 1, 2012 07:58 PM
(This post was last modified: Mar 1, 2012 08:35 PM by Natalie Portman.)
Hello all!
I have seen more than a few threads / posts asking for a tutorial on how to use XSS maliciously, so I thought I would write a tutorial.
First things first.
XSS stands for Cross Site Scripting. It involves injecting code (generally HTML, but also JavaScript) into a webpage, and this code generally having a malicious effect on the target site.
Is the vulnerability reflected or not?
A non-reflected (a.k.a. non-persistent) XSS flaw is frankly, useless. Sure they are cool to find in big websites, but they are not terribly useful, hence, they are everywhere.
An example of reflected XSS is here:
Spoiler (Click to View)
Note how a Java alert box comes up saying "XSS Here!".
This means that we have entered a script code into an input box somewhere on the site. In this case it was a search bar.
If you enter the following into the search bar at Rollingstone.com, you will find that it gives the alert "1".
You can change the 1 in the syntax to whatever you want, and that will hence be alerted also.
However, despite being cool because you can "manipulate the website" you're not actually harming it in any way.
Is not the only XSS string, and many websites have prevented against it, despite the fact that they are useless. Many other strings that are more circumstantial can be found here:
Spoiler (Click to View)
Now, onto the main event. Reflected (a.k.a. persistent XSS).
Reflected XSS is one of the largest flaws in websites, just behind SQLi and LFI. This involves a scenario where rather than just displaying the XSS syntax for you (Like when you input the syntax into a search bar), the syntax is instead stored on the page, meaning that the syntax output occurs for everyone.
This means that you can exploit the full power of XSS.
Examples of things you can do now include, but are not limited to:
- Stealing the cookies of everyone who visits that site.
- Redirecting the user to a webpage, usually a deface page.
- Spamming alerts everywhere which makes the website unviewable.
- Inputting hyperlinks.
An example of a website with a reflected XSS vulnerability is here.
Because of the amount of spam that this guestbook receives, it will constantly be usable for injection, the page is usually filled after only a couple of minutes, and a new page is created.
Spoiler (Click to View)
If you go to this site, you will see that there are many comments, all with hyperlinks. The XSS they have injected is not malicious, but adware. Their code resembles something like this:
This <a> code inputs a hyperlink, but is otherwise harmless.
However, if you input the following string, everyone will get an alert when they view the page saying "Hi! I'm the best!"
You can also use a redirect script to redirect the viewer to your deface page, making the page appear defaced.
That site is my deface page, and that string is what I inject when I find a site such as this.
You could also input something really annoying, like this:
Spoiler (Click to View)
But far more times, which would make the page unviewable due to the massive number of alerts.
Please do not inject that spam string into the website, as I want the guestbook to be available for testing to everyone :).
You can also steal the cookies of everyone who visits that site, for example:
Spoiler (Click to View)
What this will do is redirect the viewer to a site called host.com, to a page called stealer.php, then log their cookies.
What this means is that someone who injects this string into a forum (Luckily HF has very good XSS security) can obtain the username and password of anyone who views the site. :O.
The following google dork (Just paste it into google) can be used to look for vulnerable guestbooks.
You may also want to use on the end of it:
This will only look for sites hosted in Australia, but there are many others. For example:
CA: Canada
UK: United Kingdom
Just do a google search of country site suffixes.
Well guys I hope you have enjoyed my tutorial, and that you put it to good use in the world!
NOTE: Not all sites are vulnerable to XSS, many sites filter their HTML and JavaScript code, so that you cannot do this. Because of this it may take some time to find a vulnerable site, but, if you look hard enough, I assure you that you can easily find some.
Good luck!
- Envyy
I took the time to write this tutorial, please take the time to post a reply!
I have seen more than a few threads / posts asking for a tutorial on how to use XSS maliciously, so I thought I would write a tutorial.
First things first.
XSS stands for Cross Site Scripting. It involves injecting code (generally HTML, but also JavaScript) into a webpage, and this code generally having a malicious effect on the target site.
Is the vulnerability reflected or not?
A non-reflected (a.k.a. non-persistent) XSS flaw is frankly, useless. Sure they are cool to find in big websites, but they are not terribly useful, hence, they are everywhere.
An example of reflected XSS is here:
Spoiler (Click to View)
Note how a Java alert box comes up saying "XSS Here!".
This means that we have entered a script code into an input box somewhere on the site. In this case it was a search bar.
If you enter the following into the search bar at Rollingstone.com, you will find that it gives the alert "1".
Code
';alert("1")//You can change the 1 in the syntax to whatever you want, and that will hence be alerted also.
However, despite being cool because you can "manipulate the website" you're not actually harming it in any way.
Code
';alert("1")//Spoiler (Click to View)
Now, onto the main event. Reflected (a.k.a. persistent XSS).
Reflected XSS is one of the largest flaws in websites, just behind SQLi and LFI. This involves a scenario where rather than just displaying the XSS syntax for you (Like when you input the syntax into a search bar), the syntax is instead stored on the page, meaning that the syntax output occurs for everyone.
This means that you can exploit the full power of XSS.
Examples of things you can do now include, but are not limited to:
- Stealing the cookies of everyone who visits that site.
- Redirecting the user to a webpage, usually a deface page.
- Spamming alerts everywhere which makes the website unviewable.
- Inputting hyperlinks.
An example of a website with a reflected XSS vulnerability is here.
Because of the amount of spam that this guestbook receives, it will constantly be usable for injection, the page is usually filled after only a couple of minutes, and a new page is created.
Spoiler (Click to View)
If you go to this site, you will see that there are many comments, all with hyperlinks. The XSS they have injected is not malicious, but adware. Their code resembles something like this:
Code
Buy Viagra here! <a href=" http://site.com"> Cheap Viagra here now!</a>This <a> code inputs a hyperlink, but is otherwise harmless.
However, if you input the following string, everyone will get an alert when they view the page saying "Hi! I'm the best!"
Code
<script>alert("Hi! I'm the best!")</script>You can also use a redirect script to redirect the viewer to your deface page, making the page appear defaced.
Code
<script>window.location = "http://users11.jabry.com/"</script>That site is my deface page, and that string is what I inject when I find a site such as this.
You could also input something really annoying, like this:
Spoiler (Click to View)
But far more times, which would make the page unviewable due to the massive number of alerts.
Please do not inject that spam string into the website, as I want the guestbook to be available for testing to everyone :).
You can also steal the cookies of everyone who visits that site, for example:
Spoiler (Click to View)
What this will do is redirect the viewer to a site called host.com, to a page called stealer.php, then log their cookies.
What this means is that someone who injects this string into a forum (Luckily HF has very good XSS security) can obtain the username and password of anyone who views the site. :O.
The following google dork (Just paste it into google) can be used to look for vulnerable guestbooks.
Code
allinurl:guestbook.phpCode
site:AUCA: Canada
UK: United Kingdom
Just do a google search of country site suffixes.
Well guys I hope you have enjoyed my tutorial, and that you put it to good use in the world!
NOTE: Not all sites are vulnerable to XSS, many sites filter their HTML and JavaScript code, so that you cannot do this. Because of this it may take some time to find a vulnerable site, but, if you look hard enough, I assure you that you can easily find some.
Good luck!
- Envyy
I took the time to write this tutorial, please take the time to post a reply!
![[Image: q2bcziS.jpg]](https://i.imgur.com/q2bcziS.jpg)



