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

标签 c security buffer-overflow shellcode execve

我正在尝试使用 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/

相关文章:

security - 已设置 SSL 时是否需要 HttpOnly?

c - Linux 上是否有替代 gcc 堆栈保护器/强化源功能的库?

c - 棘手的C函数测试知识静态、全局、局部变量和指针

c - glib 的 g_atomic_int_get 的目的是什么?

security - SSL 为 Web 应用程序做了什么

windows - 如何判断我的 web 服务在 Visual Studio 2005 中运行的帐户

c - 以下程序中用于字符串比较的段错误

c - 缓冲区溢出问题

c - 使用 PCRE 正则表达式的奇怪答案

c - 如何以 clang 格式对齐函数参数名称?