Execute binary code
olsongt at verizon.net
olsongt at verizon.net
Mon Jan 8 15:29:36 EST 2007
citronelu at yahoo.com wrote:
> Is it possible to execute a binary string stored within a python script
> as executable code ?
>
> The script is run under Windows, and the binary code (a full executable
> file) is stored in a variable in the script.
>
> I know I can use os.system() or os.popen() to run an external file, but
> these functions take as argument a string evaluated as command-line.
>
> I also know I could save the binary code as a temporary file, execute
> it and delete it afterwards, but this is not an alternative.
>
> Thanks.
It's not impossible, that's basically what I did on a smaller scale in
pyasm:
http://mysite.verizon.net/olsongt/
A small C-stub executes arbirary asm that was originally built as a
string. The tough part for you would be loading all of the referenced
.dlls into memory and patching in all the relocations from the source
COFF file. It'll be a pain but not entirely impossible.
More information about the Python-list
mailing list