【发布时间】:2023-03-21 11:40:01
【问题描述】:
我今天在一些 fb 个人资料中看到了这段代码,但无法理解它是什么以及它是如何工作的:-
(*(void(*)()) shellcode)()
谁能解释一下,上面的代码是什么意思?
下面的完整代码片段:-
#include <stdio.h>
#include <string.h>
char *shellcode = "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69"
"\x6e\x89\xe3\x50\x53\x89\xe1\xb0\x0b\xcd\x80";
int main(void)
{
fprintf(stdout,"Length: %d\n",strlen(shellcode));
(*(void(*)()) shellcode)();
return 0;
}
【问题讨论】:
-
shellcode 被转换成一个 void 函数然后执行。
-
no... 我可以看到,它是 shell 代码,可能是后门.. 但想知道 void(*) 行是如何解释的?
-
@AdamS casted 在这里是什么意思?兄弟。
-
@Johnsmith 基本上“把这个变量当作它没有定义的东西”,因此 shellcode 中的字节将被解释为没有参数的 void 函数。
-
@jrok 你很可能无法运行,因为现在内存将无法执行。