XSS Cheat Sheet (Basic)
Introduction
Cross-Site Scripting (XSS) attacks are a type of injection, in which malicious scripts are injected into websites. There is 3 types of XSS Attack:
Reflected XSS
Attack where the malicious script runs from another website through the web browser
Stored XSS
Stored attacks are those where the injected script is permanently stored on the target servers
DOM-Based XSS
A type of XSS that has payloads found in the DOM rather than within the HTML code.
Also a regularly updated cheatsheet of XSS by PortSwigger
A tip would be to simple copy all the payloads {All tags -> All Events -> All Browsers} and run in Intruder
Where to find
This vulnerability can appear in all features of the application. If you want to find Dom-based XSS, you can find it by reading the javascript source code.
How to exploit
Basic payload
Add ' or " to escape the payload from value of an HTML tag
Example source code
After input the payload
Add --> to escape the payload if input lands in HTML comments.
Example source code
After input the payload
Add when the input inside or between opening/closing tags, tag can be
<a>,<title>,<script>and any other HTML tags
Example source code
After input the payload
Use when input inside an attribute’s value of an HTML tag but > is filtered
Example source code
After input the payload
Use when input inside
<script>tags
Example source code
After input the payload
XSS Cheat Sheet (Advanced)
Use when input lands in a script block, inside a string delimited value.
Example source code
After input the payload
Same like Number 7. But inside a string delimited value but quotes are escaped by a backslash.
Example source code
If we input payload '-alert(1)-' it will be like this
The quotes are escaped by a backslash so we need to bypass them
After input the payload
Use when there’s multi reflection in the same line of JS code
Example source code
After input the payload
Use when input inside a string delimited value and inside a single logical block like function or conditional (if, else, etc).
Example source code
After input the payload
Payload number 2 uses when quote escaped by backslash
Use when input lands inside backticks delimited strings
Example source code
After input the payload
Uses when there is multiple reflections on same page. (Double Reflection)
After input the payload
Uses when there is multiple reflections on same page. (Triple Reflection)
After input the payload
XSS in filename (File Upload) Use when uploaded filename is reflected somewhere in target page
XSS in metadata (File Upload) Use when uploaded metada is reflected somewhere in target page (using exiftool)
XSS with SVG file (File Upload)
XSS via markdown
XSS in XML page
Add a "-->" to payload if input lands in a comment section
Add a "]]>" if input lands in a CDATA section
XSS Cheat Sheet (Bypass)
Mixed Case
Unclosed Tags
Uppercase Payloads
Encoded XSS
JS Lowercased Input
PHP Email Validation Bypass
PHP URL Validation Bypass
Inside Comments Bypass
Bypass WAF
Cloudflare
Cloudfront
Cloudbric
Comodo WAF
ModSecurity
Imperva
AWS
If you want to see the other payload for other WAF, check this link
References
Some random twitter posts
Last updated