问题描述
我试图通过漏洞利用缓冲区溢出来执行 shell。
这是我试图运行的代码。
task2_exploit.c
task2_stack.c
我试图在 buf
数组中获取 shellcode 部分的地址:
这里,shellcode 似乎从 0xffd563
开始,表示为蓝色框,所以我在 task2_exploit.c
中实现了它,它显示在 RET
部分的红色框中。
当我运行这样的程序时,实现shellcode的确切地址,它成功调用了shell。但是,当我在 buf
数组中实现 nop Slide 部分的地址之一(例如 ffffd480
)时,它会发生段错误而不是滑动到 shell 代码部分并调用新的 shell。我尝试了很多次,但从未成功。我不明白为什么会发生这种情况。请帮忙。
这里是编译和运行程序的命令。
将 shell 更改为 zsh
并停用 ASLR:
sudo rm /bin/sh
sudo ln -s /bin/zsh /bin/sh
sudo sysctl -w kernel.randomize_va_space=0
编译 task2_stack.c
并更改所有权,授予 set-uid 权限:
gcc -m32 -z execstack -fno-stack-protector task2_stack.c -o task2_stack
sudo chown root task2_stack
sudo chmod 4755 task2_stack
编译task2_exploit.c
:
gcc -m32 task2_exploit.c -o task2_exploit
执行程序:
./task2_exploit
./task2_stack
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)