我有一个包含十六进制的exe文件。我在python中读过这个文件,但是没有运行这个.exe文件。 任何形式的帮助都会得到认可。。。在
塔克斯
import binascii
def getExeFile():
file1=input("Enter an exe file name(path):")
with open(file1, 'rb') as f:
content1 = f.read()
bucket1=open("f1.txt", 'w')
bucket1.write(str(binascii.hexlify(content1)))
print(binascii .hexlify(content1))
bucket1.close()
def getNonExeFile():
file2=input("Enter a non-exe file name(path):")
with open(file2, 'rb') as f:
content2 = f.read()
bucket2=open("f2.txt", 'w')
bucket2.write(str(binascii.hexlify(content2)))
print(binascii .hexlify(content2))
bucket2.close()
getExeFile()
getNonExeFile()
print("End")
将其转储到临时文件中;更改其权限,使其可执行,并在子进程中运行它
示例:
当然,我在这里假设您在某种UNIX机器上执行此操作,在本例中“EXE”意味着某种ELF/A.OUT/COFF可执行文件!然而,相同的原则和代码(稍作调整)可能适用于其他paltforms;例如Windows。在
参见:
Python 3.4: 这是我的代码,创建一个简单的txt文件有十六进制和exe和一个txt文件。 现在我希望我的程序采取十六进制文件,运行exe文件,并打开txt文件。在
导入binascii
谢谢。。。!在
相关问题 更多 >
编程相关推荐