我正在尝试使用 ubuntu 12 上的终端编译它:
#include <stdio.h>
#include <stdlib.h>
main()
{
/*declare argument array*/
char *args[2];
args[0] = “/bin/bash”;
args[1] = NULL;
execve(args[0], args, NULL);
exit(0);
}
我在 http://www.securitytube.net/video/235 上找到了这个例子这也恰好是 Aleph One 在“粉碎堆栈以获得乐趣和利润”中使用的那个。我知道自那时以来发生了很大变化。在我使用的更简单的示例中:
gcc -ggdb -mpreferred-stack-boundary=2 -fno-stack-protector filename filename.c
其他时候我可能会包含静态实用程序。它一直在工作,直到我尝试编译上面的 C 代码。我从终端收到的消息是:
ss@ss-laptop:~$ gcc -static -mpreferred-stack-boundary=2 -fno-stack-protector -o shell shell.c
shell.c: In function ‘main’:
shell.c:9:2: error: stray ‘\342’ in program
shell.c:9:2: error: stray ‘\200’ in program
shell.c:9:2: error: stray ‘\234’ in program
shell.c:9:15: error: expected expression before ‘/’ token
shell.c:9:15: error: stray ‘\342’ in program
shell.c:9:15: error: stray ‘\200’ in program
shell.c:9:15: error: stray ‘\235’ in program
ss@ss-laptop:~$
我知道这是一个非常简单的例子,这个错误可能是由 linux 中当前的标准安全措施引起的,但我想绕过它们来练习这个例子,并在未来进行更多练习。如果有人能提供帮助,那将是“粉碎”。
干杯
最佳答案
你的字符串文字周围有“智能”引号,
“/bin/bash”;
尝试使用普通引号 "
。
关于c - 如何从终端编译这个简单的 shellcode c 程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11334454/