我很难弄清楚为什么在解密后有效负载不工作example2.cpp
,当使用命令'example2.exe > out.txt'执行编译的exe时,我得到了有效的shellcode并且不会导致任何问题example.cpp
因为我可以看到输出是hello world
(至少在我的情况下)
example.cpp
unsigned char out[] = "\x00\x00...";
int main()
{
void *exec = VirtualAlloc(0, sizeof(out), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
memcpy(exec, out, sizeof(out));
((void(*)())exec)();
}
example2.cpp
void decrypt_run(){
std::vector<unsigned char> decrypted(encrypted.size());
// the encrypted cipher get decrypted and the vector decrypted is filled with unsigned chars
unsigned char buf[decrypted.size()];
// converting the vector to an unsigned char buffer to be passed to memcopy
std::copy(decrypted.begin(), decrypted.end(), buf);
size_t shellcodesize = sizeof(buf);
cout << buf << endl; // prints the shellcode to the screen
//void *exec = VirtualAlloc(0, shellcodesize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
//memcpy(exec, buf, shellcodesize);
//((void(*)())exec)();
}
int main()
{
decrypt_run();
return 0;
}
当取消注释程序中的最后三行时,decrypt_run()
除了它自己的 shellcode 之外没有任何输出
out.txt
再次使用与中相同的 shellcode,example.cpp
它可以完美运行,但不能与example2.cpp