gpt4 book ai didi

编译ShellCode程序出现C错误

转载 作者:行者123 更新时间:2023-11-30 16:58:03 25 4
gpt4 key购买 nike

我目前正在阅读一本有关 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com