我一直在关注一些有关缓冲区溢出利用的教程。但是我的问题是,我无法打开根外壳程序,而是总会得到一个普通的用户外壳程序。我检查了以下几点
我重新验证了以下各项,但仍然无法实现实际的root shell:
有人知道可能是什么问题吗?为什么我仍然无法获得root shell?
在此先感谢您的任何建议和提示。最好的Zaphoxx
易受攻击的C代码:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void shell(){
system("/bin/sh");
exit(0);
}
int vuln(){
char buf[4];
ssize_t l=0;
printf("[+] input: ");
l=read(0,buf,128);
printf("[+] recv: ");
write(1,buf,l);
return 0;
}
int main(){
//setbuf(stdout,0);
setuid(0);
seteuid(0);
vuln();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
python利用脚本创建有效负载: …
我正在试验管道.所以我创建了一个简单的批处理文件(dos/windows),如下所示:
@echo off
echo [+] starting batch file
:start
set /p msg="[+] enter msg: "
echo [+] Your message: %msg%
IF "%msg%"=="x" (
echo [x] end loop
goto exit
) ELSE (
goto start
)
:exit
echo [+] bye
Run Code Online (Sandbox Code Playgroud)
只要我从命令行调用它,这个工作正常:
> showAll.bat
S:\80_personalFolder\81_lab\python\ghoul>showAll.bat
[+] starting batch file
[+] enter msg: hello
[+] Your message: hello
[+] enter msg: x
[+] Your message: x
[x] end loop
[+] bye
S:\80_personalFolder\81_lab\python\ghoul>
Run Code Online (Sandbox Code Playgroud)
但是一旦我尝试将输入传递给它,它将在一个无限循环中运行:
> echo hello | showAll.bat
Run Code Online (Sandbox Code Playgroud)
将导致:
[...]
[+] enter msg: …Run Code Online (Sandbox Code Playgroud)