Execute binary code

Jorgen Grahn grahn+nntp at snipabacken.dyndns.org
Thu Jan 11 12:53:42 CET 2007


On Wed, 10 Jan 2007 10:31:50 -0600, Chris Mellon <arkanes at gmail.com> wrote:
> On 10 Jan 2007 08:12:41 -0800, sturlamolden <sturlamolden at yahoo.no> wrote:
>>
>> Chris Mellon wrote:
>>
>> > This works fine if the binary data is "pure" asm, but the impresssion
>> > the OP gave is that it's a compiled binary, which you can't just "jump
>> > into" this way.
>>
>> You may have to offset the function pointer so the entry point becomes
>> correct.
>>
>
> That won't be enough. You basically would have to re-implement the OS
> loading process, handling relocations and loading any linked
> libraries. Possible, in theory, but very non-trivial.

Yeah, that was implicitly my thinking a bit up in the thread. If all you
have is an executable file (COFF/ELF/...) as a string, and you have no
os.exec(string) or similar, then you're in trouble.

At least if it has to work.

/Jorgen

-- 
  // Jorgen Grahn <grahn@        Ph'nglui mglw'nafh Cthulhu
\X/     snipabacken.dyndns.org>  R'lyeh wgah'nagl fhtagn!



More information about the Python-list mailing list