I have a decrypted binary in the memory that i want to execute. How can turn the memory buffer that holds the decrypted binary into a file descriptor in order to execute it using fexecve
? Is this the appropriate way to execute a binary residing in the memory?
Asked
Active
Viewed 60 times
0

alexandros
- 77
- 8
-
2If the memory is executable and the code is relocatable, you can just jump to it's start in the memory. – Eugene Sh. Dec 29 '15 at 15:11
-
7Take a look [here](http://stackoverflow.com/questions/13690454/how-to-compile-and-execute-from-memory-directly) – Eugene Sh. Dec 29 '15 at 15:15
-
Given all that it takes to turn an executable file into a runnable address space (executable and data mappings and relocations, loading of required shared objects,...)? I'd just write the data to a file. Then execute that file. – Andrew Henle Dec 29 '15 at 15:21
-
@EugeneSh.: I think this question is really a duplicate of the question you linked, not just related; the fact that the file in memory was decrypted is irrelevant to the problem at hand after all, it's really just "how to run a program from a memory buffer". – ShadowRanger Dec 29 '15 at 17:59
-
@ShadowRanger The fact the that file is decrypted is highly relevant because i want to avoid exposing the contents of the binary on the hard drive. The idea is that a binary decrypts another binary which is then executed directly in the memory – alexandros Dec 30 '15 at 06:53
-
@AlexH:The reason you want to do it is (mostly) irrelevant; if the other question answers _how_ to do it, it doesn't really matter if your data came from decrypting, or if your real primary goal is to reduce power usage by avoiding spinning up the hard drive. – ShadowRanger Dec 30 '15 at 12:55