题目信息
nc pwn2.jarvisoj.com 9882
64位elf,只开了NX

img
静态分析
IDA F5,明显溢出

img

img
其他地方和level2没什么区别,只是64位和32位栈的区别
在32位程序运行中,函数参数直接压入栈中
- 调用函数时栈的结构为:调用函数地址->函数的返回地址->参数n->参数n-1->···->参数1
在64位程序运行中,参数传递需要寄存器
64位参数传递约定:前六个参数按顺序存储在寄存器rdi, rsi, rdx, rcx, r8, r9中
参数超过六个时,从第七个开始压入栈中
exploit
所以我们将”/bin/sh”作为system函数参数的话需要一个pop rdi的gadget,直接使用ROPGadget查找

img
之后构造exp即可
构造exp
1 | from pwn import * |
getflag

img