执行二进制代码 [英] Execute binary code

查看:177
本文介绍了执行二进制代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以执行存储在python脚本中的二进制字符串

作为可执行代码?


脚本在Windows下运行,二进制文件代码(完整的可执行文件

文件)存储在脚本中的变量中。


我知道我可以使用os.system()或os.popen ()运行一个外部文件,但是这些函数将一个字符串作为命令行来计算。


我也知道我可以保存二进制文件代码作为临时文件,执行

然后删除它,但这不是替代方案。


谢谢。

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.

推荐答案

ci*******@yahoo.com 写道:

是否可以执行存储在python脚本中的二进制字符串

作为可执行代码?


脚本在Windows下运行,二进制代码(完整的可执行文件

文件)存储在脚本中的变量中。


我知道我可以使用os.system()或os.popen()来运行外部文件,但是

这些函数将一个字符串作为参数作为命令行进行评估。


我也知道我可以将二进制代码保存为临时文件,执行

它然后删除它,但这不是另一种选择。


谢谢。
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.



你问的是病毒/ trojanlike程序。没有理由

你不应该把代码编写到TEMP目录并执行它。


-Larry

What you are asking is a virus/trojan "like" program. There''s no reason
you shouldn''t be able to write the code to TEMP directory and execute it.

-Larry



ci ******* @ yahoo.com 写道:

是否可以执行存储在python脚本中的二进制字符串

作为可执行代码?


脚本在Windows下运行,二进制代码(完整的可执行文件
文件)存储在脚本中的变量中。


我知道我可以使用os.system()或os.popen()来运行外部文件,但

这些函数将一个字符串作为参数计算为命令行。


我也知道我可以将二进制代码保存为临时文件,执行

然后将其删除,但这不是替代方案。


谢谢。
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.



这并非不可能,这基本上就是我在较小规模上所做的事情。

pyasm:

http://mysite.verizon.net/olsongt/


小型C-stub执行arbirary asm,最初构建为

字符串。对你来说困难的部分是将所有引用的

..dll加载到内存中并修补来自源

COFF文件的所有重定位。这将是一种痛苦,但并非完全不可能。

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.


Larry Bates写道:
Larry Bates wrote:

你所问的是病毒/木马喜欢程序。没有理由

你不应该把代码编写到TEMP目录并执行它。


-Larry
What you are asking is a virus/trojan "like" program. There''s no reason
you shouldn''t be able to write the code to TEMP directory and execute it.

-Larry



不,这不是木马,但我想尝试

说服你是没有意义的。


这不是关于能够将代码编写到TEMP目录并且

执行它,它是不想这样做的。


-Cornelius


No, it is not about a trojan, but I guess it''s pointless to try to
convince you otherwise.

It''s not about being able to write the code to TEMP directory and
execute it, it''s about not wanting to do so.

-Cornelius


这篇关于执行二进制代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆