1

I am currently working on a project where i can encrypt and decrypt files. I am developing it in Java.

This is how it works (simplified):

  1. First I read the file and convert it to a byte array
  2. Then I encrypt the byte array and write it back to a file

When I want to run the encrypted file, I do the opposite, so like this:

  1. I read encrypted file and convert it to byte array
  2. Then I decrypt the byte array and write it back to a file.

So the file is converted back to its original form.

My problem is, I do not want to write the decrypted byte array as a file to the disk.

Is there a way to do this? I want to run the decrypted byte array directly in memory. By "running" it, I mean executing it, because it is a Win32 executable crypter.

Thanks in advance, Onur

1
  • Hi, I hate to bring up a dead topic but if you could share the code you described (especially the conversion to the byte[]) you'd save me a great deal of time :) please share. Commented Aug 21, 2012 at 10:27

3 Answers 3

1

I'd say that your options are limited here, because you are dependent on Windows starting the process. Java, being cross-platform, probably doesn't have the ability to hook into Windows in the way you want.

Straying outside the realms of pure Java, you could create a ramdisk and write the EXE to the Ramdisk, or perhaps bridge across to .NET, as described in this answer (and question links inside that answer).

Sign up to request clarification or add additional context in comments.

1 Comment

Does Windows allow you to execute any old chunk of bytes that you wrote to RAM? If so, that seems like a gaping security hole.
0

Maybe Java NIO framework will suit you. Look at ByteBuffer and FileChannel

1 Comment

That doesn't help with executing the EXE.
0

I saw the example in c#, this is exactly what i want, but mixing 2 languages is not on option for this project.

I've heard about JNA library that does some win32 native stuff. Maybe i should look at it.

Thank you all for your help, but i still hope someone will post my solution here.

Onur

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.