What is (XSS) Cross site scripting Types of XSS how to explore Them

Cross site scripting





what is Cross site scripting and What is use of cross site scripting XSS

What is Cross Site Scripting

*Cross site scripting is a client side code injection attack.

*The Attacker aims is to execute malicious script in websites of the victim by including malicious code.

*The Attacker Occurs when the victim vists web sites that executes the malicious code. 

*Cross site scripting attacks is possible in VBScript, ActiveX, Flash, and CSS also, But most common in JavaScript because is fundamental to most browsing experiences.


How It Work

*Cross site scripting works by manipulating a vulnerable website so that it returns malicious JavaScript to users.

* When the malicious code executes inside a victim's browser, the attacker can fully compromise their interaction with the application.


Types of XSS attacks

1)Reflected XSS:

   Reflected XSS is the simplest variety of cross site scripting. It arises when an application receives data in an HTTP request  and includes that data within the immediate response in an unsafe way.

   Reflected XSS attacks also known as non-persistent attacks, When a malicious script is reflected on websites to the victim' browser.

Read More About Reflected XSS Attack 

Reflected XSS attack Example

while visiting a forum site that requires users to log in to their account a perpetrtor executes this

search query :

<script type=’text/javascript’>alert(‘xss’);</script> 


1) ('XSS'):The Query produces an alert box saying.

2) <script type=’text/javascript’>alert(‘xss’);</script>: The Websites page Displays

3) https://.............................?q=<script type=’text/javascript’>alert(‘xss’);</script>: The websites pages URL reads


2)Stored XSS

   Stored XSS attack the vulnerable websites Supplied input from untrusted sources and stores it.

   This malicious content also gets included in the later HTTP responses sent by the server. To perform a Stored XSS attack, hackers only need to identify a security vulnerability within the backend application that allows executing malicious requests.

 

  The impact of a successful attack ranges from mild to full-blown compromise depending on the privileges assigned to the valid affected user. Some Consequences of successful XSS attacks include.


1)Session Hijacking Attacks

2)Disclosure of user files/data

3)Installation of malware/Trojan Programs

4)web content spoofing

                                          Read More About Stored XSS Attack

Stores XSS differs from reflected XSS. In Reflected XSS the server executes the malicious content and includes it only in the immediate HTTP response. In stored XSS the arbitrary code gets stored.


Stored XSS Payloads


Image XSS javascript

<IMG SRC="javascript:alert('XSS');">

Bypassing HTML Encoding

<IMG SRC=javascript:alert(&quot;XSS&quot;)>

Improper Img Tags

<IMG """><SCRIPT>alert("XSS")</SCRIPT>"\>


3)DOM XSS

  DOM XSS (Document Object Model) is a programming interface that defines hoe to create modify or erase in HTML or XML documents.

A DOM model represents each element as a node with in a tree like system, enabling easler programmatic access and Management of elements

Dom based XSS is a cross site scripting vulnerability that enables attackers to inject a malicious payload into a web page by manipulating the client browser

DOM based XSS attacks can only be seen by checking the document object model and client side scripts at runtime.

Fundamentally, attackers perform DOM-based Cross-site scripting attacks on applications with an executable path for data to travel from a source to a sink. Sources are JavaScript properties that can act as the location of malicious input. These include document.URL, document referrer, location search, and location. hash among others. A sink is a location or function that executes the malicious function in an HTML rendering. Example of sinks include: eval, setTimeout, setInterval and element innerHTML among others

                                            Read More About DOM XSS Attack

DOM XSS Attack 

Using JavaScript Frameworks

JavaScript frameworks such as React and AngularJS are built with security best practices that eliminate ad-hoc HTML construction, making it harder for developers to include loopholes that allow adversaries to embed malicious user input into web Document Object models.

div>{{dynamicContent}}</div> 

Binding content in ReactJS within curly braces also enables automatic escaping

render() {

  return <div>{dynamicContent}</div>

}

1)Attack Based on Vulnerable content

<HTML>

<TITLE>Welcome!</TITLE>

Hi

<SCRIPT>

var pos=document.URL.indexOf("name=")+5;

document.write(document.URL.substring(pos,document.URL.length));

</SCRIPT>

<BR>

Welcome

</HTML>



Attacker Use XSS be Used for 


*Redirecting a user to a malicious website

*Capturing the keystrokes of a user

*Running web browser–based exploits

*Inject trojan functionality into the web site.

*Perform virtual defacement of the web site.

*Read any data that the user is able to access.

*Carry out any action that the user is able to perform.