编译ShellCode程序出现C错误

标签 c shellcode

我目前正在阅读一本有关 shellcoding 的书,并且在其中一个示例中遇到了一些问题。我正在尝试编译下面的代码,但我不断收到有关杂散“\”的错误。由于“\”,我必须以某种方式输入字符吗?

// shellcode.c

char shellcode[] =
“\xeb\x1a\x5e\x31\xc0\x88\x46\x07\x8d\x1e\x89\x5e\x08\x89\x46”
“\x0c\xb0\x0b\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\xe8\xe1”
“\xff\xff\xff\x2f\x62\x69\x6e\x2f\x73\x68”;

int main(){

    int *ret;
    ret = (int *)&ret + 2;
    (*ret) = (int)shellcode;
}

最佳答案

\x 表示十六进制字符转义。从 C99 6.4.4.4 开始:

The hexadecimal digits that follow the backslash and the letter x in a hexadecimal escape sequence are taken to be part of the construction of a single character for an integer character constant or of a single wide character for a wide character constant.

EXAMPLE 3 Even if eight bits are used for objects that have type char, the construction '\x123' specifies an integer character constant containing only one character, since a hexadecimal escape sequence is terminated only by a non-hexadecimal character. To specify an integer character constant containing the two characters whose values are '\x12' and '3', the construction '\0223' may be used, since an octal escape sequence is terminated after three octal digits. (The value of this two-character integer character constant is implementation-defined.)

关于编译ShellCode程序出现C错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39117386/

相关文章:

C 程序查找两个单词是否是字谜(我的代码在里面)

c - 段错误(核心转储)Codelite ubuntu

assembly - 如何重新编程我的 shellcode 片段以避免空字节?

c++ - 在函数指针内转换 shellcode

go - 如何在 GoLang 中执行 native 指令?

python - x86_64 执行 Shellcode 失败 :

C:允许将任何数组分配给指向不完整类型数组的指针

c - 为什么我总是得到字符串数组的最后一个元素?

c++ - python的版本检查

linux - x64 linux 上的 Shellcode 注入(inject)