I'm here to ask if anyone here can help me. I have been doing the following:
- Copy bytes from file
- Encrypt and convert bytes to string by using base64
- Write the string to a program with a binary writer
- The program will pick up on the string and store it in a variable
- The program will now convert it back to a byte array and decrypt it
- Now I tried to get the program to run the bytes with assembly.load (where it goes wrong)
System.BadImageFormatException: Could not load file or assembly
If you need any other details please ask.
NOTE: I want to be able to do this with any program (so any architecture, native or not), I don't want to write the bytes to a file and run the new file, I want everything to be done within memory and not on the storage device after execution.
Thanks to everyone in advance.
Example of running the byte array:
Assembly exeAssembly = Assembly.Load(decryptedBuffer);
object[] parameters = new object[1];
exeAssembly.EntryPoint.Invoke(null, parameters);
[SOLUTION] I used RunPE to self inject the bytes into the stub. Works fine, thanks to everyone who helped!