Is it possible to read binary in ruby file and execute it directly in memory?
for example something like this:
x = IO.read('/bin/ls')
execute(x)
I tried system(x)
but it gives:
ArgumentError: string contains null byte
Is it possible to read binary in ruby file and execute it directly in memory?
for example something like this:
x = IO.read('/bin/ls')
execute(x)
I tried system(x)
but it gives:
ArgumentError: string contains null byte
system() and exec() both pass the command string to the OS to have it load and launch an external command, which isn't what you're asking.
Something could be written in C, as that is how Ruby is extended. Lots of information on Google:
I don't think you're going to be able to do that. When an executable starts, the dynamic linker needs to do quite a lot of fixing links up.
The simplest solution is to write the executable to a temporary disk file somewhere, and execute that.