我如何从终端编译这个简单的shellcode c程序?

问题描述:

我正在尝试使用ubuntu 12上的终端进行编译:

I am trying to compile this using the terminal on 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在砸碎堆栈以获取乐趣和利润中使用的一个'。我知道从那以后发生了很多变化。在更简单的示例中,我使用了:

I found this example on http://www.securitytube.net/video/235 which also happened to be the one Aleph One used in 'Smashing the Stack for Fun and Profit'. I am aware that much has changed since then. In more simple examples I have used:

gcc -ggdb -mpreferred-stack-boundary = 2 -fno-stack-protector filename filename.c

gcc -ggdb -mpreferred-stack-boundary=2 -fno-stack-protector filename filename.c

其他时候,我可能包括static实用程序。在我尝试编译上面的C代码之前,它已经奏效了。我从终端收到的消息是:

Other times I may include the static utility. It has worked up until I have tried to compile the C code above. The message I receive from the terminal is:

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中当前的标准安全措施引起的,但是我想让他们绕开这个例子,并在以后进行更多的练习。如果有人可以帮助,那将是粉碎。

I understand that this is a very simple example and that this error is probably caused by current standard security measures in linux but I would like to get around them to practise with this example and more in the future. If anyone can help, it would be 'smashing'.

欢呼声

您在字符串文字周围有聪明的引号,

You have "smart" quotes around your string literal,

"/bin/bash";

尝试使用普通引号