Post

Pwninit Template

Template for pwninit

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3

from pwn import *
#import time
#from termcolor import colored
#from tqdm import tqdm

{bindings}
rop = ROP(elf)

context.binary = {bin_name}
context.terminal = ["alacritty", "-e", "sh", "-c"]
dbginit = """
b main
"""


def find_offset():
    r = process({proc_args})
    gdb.attach(r)
    p = cyclic(1000)
    r.sendline(p)
    r.interactive()


def conn():
    if args.REMOTE:
        r = remote("addr", 1337)
    elif args.GDB:
        r = gdb.debug({proc_args}, gdbscript=dbginit)
    else:
        r = process({proc_args})
    return r


def main():
    r = conn()

    sl  = lambda a   : r.sendline(a)
    sla = lambda a,b : r.sendlineafter(a,b)
    ru  = lambda a   : r.recvuntil(a)
    rud = lambda a   : r.recvuntil(a,drop=True)

    # r.interactive()
    

if __name__ == "__main__":
    main()
This post is licensed under CC BY 4.0 by the author.