【发布时间】:2018-01-16 10:26:09
【问题描述】:
我正在尝试在 cpp 中运行 shellcode(shellcode 来自用户,因此程序应该是动态的) 当我尝试运行我的程序时,我遇到了一个异常,我认为它告诉我无法从数据部分运行代码。 之后我尝试创建一个新的可执行部分并将我的数据放在那里,但它没有用
#pragma section(".shell",read,execute)
__declspec(allocate(".shell"))
unsigned char code[] =
"\xB8\x04\x00\x00\x00";
// Function pointer points to the address of function.
int(*shell)(); //Function pointer
// Initializing a function pointer with the address of a shellcode
shell = ((int(*)())&code);
// Execute shellcode
int a = shell();
有人可以向我解释我做错了什么吗?
【问题讨论】:
-
您能提供确切的症状吗?
-
用
char数组初始化unsigned char数组不是一个好主意。 -
这是异常 - ClientSide.exe 中 0x0113F005 处的未处理异常:0xC0000005:访问冲突写入位置 0x81D9BAC0。如果有这个异常的处理程序,程序可以安全地继续。
-
那是因为 DEP(数据执行保护)。如果你真的想执行那个 shellcode,那么禁用 DEP 应该允许你的 shellcode 从数据部分执行
-
是的,但我创建了一个新的可执行部分并将数据存储在它们的(.shell 部分)上
标签: c++ function-pointers shellcode