Is it possible to run a Windows executable stored in memory?

Asked

Viewed 51 times

0

I have an executable that is not an . NET Framework Assembly stored in a byte[], and I intend to run it without creating a file dedicated to it for security reasons.

The reason you don’t want to create a temporary file, store the bytes and then run is because Executable contains sensitive information as well as being encrypted, and can be easily circumvented and accessed by the user when opening the created file.

So I’ve tried that method:

byte[] assemblyFiles = Decrypt(assemblyBytes);
Assembly executeable = Assembly.Load(assemblyFiles); 
executeable.GetEntryPoint().Invoke();

However, when using the Assembly.Load() it gives error and says that the executable is not valid for . Net Framework.

I needed to do this in C#, preferably within the application itself, without needing a file dedicated to this operation.

I’ve tried to use this class another answer in Stackoverflow English, but I didn’t understand how to use the argument hostProcess. So I was unsuccessful.

  • 1

    It’s even possible, but this doesn’t provide any security. If you have sensitive information and nothing you do will provide security. And you can’t use the . NET to click on something that was not done for it. The path would be that of Soen’s question.

  • Any tips on how to implement this? I tried injecting into the executable itself with Assembly.GetExecutingAssembly().Location but what I did get was to crash the system with more than 500 processes from the same Assembly.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.