Testing for XSS
XSS Types
Stored (Persistent)
Input stored in DB, displayed to all users (most critical)
Reflected (Non-Persistent)
Input reflected in response (e.g., search, error messages)
DOM-based
Processed client-side via JavaScript, never reaches server
Test ALL Input Fields
IMPORTANT: Always test XSS payloads in ALL input fields, not just the obvious ones. Some fields may have different (or no) filtering.
Fields to Test
Username/login fields
Message/comment body
Phone number - Often unfiltered, expecting only digits
Email address - May allow special characters
Subject/title fields
Search boxes
Hidden form fields
File name fields
Contact form fields (name, company, etc.)
Example: Phone Field XSS
A contact form may filter the message body for XSS but leave the phone number field completely unfiltered:
Tip: If one field is filtered, try the same payload in every other field. Developers often focus filtering on expected attack surfaces and miss unexpected ones.
Test Payloads
Basic Test
Alternatives (if alert blocked)
DOM XSS (when script tags blocked)
XSS Discovery Tools
Reflected XSS Exploitation
Find reflected parameter (check Network tab for GET/POST)
Inject payload in URL parameter
Send malicious URL to victim:
DOM XSS - Source & Sink
Common Sources (user input)
Dangerous Sinks (vulnerable functions)
Stored XSS
Key Logger
Chat Room XSS
Start a netcat listener on your attack box
Take this XSS payload and paste it in the chat room and submit:
Note: Send the payload and then open the listener
Stored XSS Payloads
Stored XSS pop up to display your cookies, good for a POC
Adding HTML to a website
Deface website title. You will need inspect element and find the name of the element you want to change.
thm-titleis the element name in this example.
DOM-Based XSS
Internal Network Scanner
Website Defacing
Change Background
Change Title
Replace Page Content
Remove Element
XSS Phishing
Inject Login Form
Comment Out Remaining HTML
Session Hijacking / Cookie Stealing
Cookie Stealing Payloads
PHP Cookie Logger (steal.php)
Start Listener
Blind XSS Detection
Remote Script Loading (per field)
Blind XSS Payloads
script.js for Cookie Stealing
Common Injection Contexts
Inside <script>
';alert(1)// or ";alert(1)//
HTML attribute
" onmouseover=alert(1)
HTML tag
<img src=x onerror=alert(1)>
URL parameter
javascript:alert(1)
Event handler
'-alert(1)-'
Bypass Techniques
Case Variation
Encoding
No Parentheses
No Quotes
Filter Bypass Payloads
XSS in Markdown
Markdown parsers that allow HTML can be vulnerable to XSS.
Markdown XSS Payloads
Embedded HTML in Markdown
Reference: https://github.com/cujanovic/Markdown-XSS-Payloads/blob/master/Markdown-XSS-Payloads.txt
XSS Data Exfiltration via fetch()
Exfiltrate internal page content when no cookies are available.
Exfiltrate Page Content
Exfiltrate via LFI Parameter
If the target has an LFI vulnerability accessible from XSS context:
Decode Exfiltrated Data
Attack Flow (Stored XSS + LFI Chain)
Upload malicious markdown/content with XSS payload
Get shareable link to stored content
Send link to admin via contact form
Admin views link, XSS executes
Fetch internal page content (messages, config files)
Exfiltrate via base64 to attacker server
Chain with LFI to read sensitive files (Apache config, .htpasswd)
Exfiltrate localStorage
Last updated