gpt4 book ai didi

c - C程序中的Shellcode

转载 作者:太空狗 更新时间:2023-10-29 16:35:44 37 4
gpt4 key购买 nike

Demystifying the Execve Shellcode解释了一种编写 execve shellcode 的方法:

#include<stdio.h>
#include<string.h>

unsigned char code[] =
"\x31\xc0\x50\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3\x50\x89\xe2\x53\x89\xe1\xb0\x0b\xcd\x80";

main()
{

printf("Shellcode Length: %d\n", strlen(code));

int (*ret)() = (int(*)())code;

ret();
}

int (*ret)() = (int(*)())code; 是做什么的?

最佳答案

  int (*ret)() = (int(*)())code;
~~~~~~~~~~~~ ~~~~~~~~~~~~~~
1 2

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3
  1. 它将ret 定义为一个指向函数的指针,该函数没有参数() 并返回int。所以,那些 () 表示函数参数的定义。

  2. 它用于将 code 转换为指向没有参数 () 并返回 int 的函数的指针。

  3. code 转换为函数并将其分配给 ret。之后您可以调用 ret();

unsigned char code[] =  "\x31\xc0\x50\x68\x6e\x2f\...

它是由十六进制值表示的机器指令序列。它将作为函数注入(inject)到代码中。

关于c - C程序中的Shellcode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16626857/

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