XSS or cross site scripting is a type of a computer security vulnerability found in web applications. In XSS, a code is injected to the remote server so it can also be called as Client Side Scripting. According to statistics, 68% website on internet are open to this attack and its varieties and this became the most popularly used attack with the information security researchers in 2007.
There are mainly two type of XSS attacks.
1. Non-persistent XSS attack
In this kind of vulnerability, attacker required the user to run a specifically crafted link so that vulnerability can be exploit when the browser runs it. The delivery method for such attack can be anything ranging from an email to a simple message on facebook. This is the more common type of XSS vulnerability present and because of this commoness it is generally rated as a beginner level XSS attack by the security researchers but even this can have dangerous outcomes.
2. Persistent XSS attack
The persistent(or stored) cross scripting attack is a very devastating attack simply because when the attack is successfully pulled off by an attacker, the provided by him is saved on the server and then it is permanently displayed on the pages that normal users land on in the normal course of browsing. The classic delivery system for such attack are the message boards where a user is allowed to post HTML formatted messages for the other users to read.
Today, we are going to have a look at how to pull off a very simple yet effective non-persistent XSS attack.
Step 1: Use a free web hosting service, like heliohost.org, x10hosting.com, 110mb.com, 000webhost.com, my3gb.com) to create a website whose domain name doesn’t create much suspicion even if looked carefully.
For the purpose of explaing, i managed to create a domain ht1234a.my3gb.com . On these websites, generally the username you provide while registration is used as a subdomain for your URL.
Advice: Don’t use your regular email for this purpose as you might become a target of another attacker or a “security researcher”. I made a dummy email email@example.com for this guide’s purpose.
Step 2: Now in your computer, open notepad and write the following code in the file exactly the way it is given.
Step 3: Save the following code as index.php.
[Like/Tweet/G+ to Unlock the code]
Step 4: Now go to the File Manager of your hosting service and upload this index.php file we just created to the root directory of your domain so that it looks like subdomain.hosting.com/index.php . So mine looks like ht1234a.my3gb.com/index.php .
Step 5: Now create an empty text file for the above web application to store the stolen cookies. As in the script we have used log the empty file should be log.txt . After creating it, upload it also to the root directory of the subdomain.
Now, preparation for the attack is done and all we got to do is create a crafty link for our victim to run. In the link the web application link is given as subdomain.hosting.com/index.php and so we can use ht1234a.my3gb.com/index.php for the guide purpose.
The best way to save yourself from such attacks is by only opening links from reliable sources and by carefully examining every unknown link you open.