我有以下代码:运行可执行程序混淆解析/ OS
#!/usr/bin/python
import sys
import subprocess
import random
import time
if len(sys.argv) != 7:
print "Usage: " + sys.argv[0] + " <executable> r m n p a"
sys.exit(1)
myexecutable = sys.argv[1]
r = int(sys.argv[2])
list_m = map(int, sys.argv[3].split(","))
list_n = map(int, sys.argv[4].split(","))
list_p = map(float, sys.argv[5].split(","))
list_a = map(int, sys.argv[6].split(","))
r1 = random.Random()
for m in list_m:
for n in list_n:
for p in list_p:
for a in list_a:
if a <= m:
for i in range(r):
print '%04.3f' % (r1.randint(1, 100))
seed = time.time()
r1 = random.Random(seed)
print m, n, p, a, i
command = myexecutable + " -seed "+ str(r1) + " -m "+ str(m) + " -n "+ str(n) +" -p "+ str(p) +" -a "+ str(a)
f = open("seed_" + str(r1) + "-m_" + str(m) + "-n_" + str(n) + "-p_" + str(p) + "-a_" + str(a)+ "-i_" + str(i) + ".xml", "w")
subprocess.call(command, shell=True, stdout=f)
f.close()
“Myexecutable”是用C++编写,不调用任何复杂的图书馆,除了提升选项的工作简单的程序。一切似乎都很好。
当我运行
python generate.py
下面的代码我得到的奇特,不可思议的错误:
/bin/sh: 1: cannot open random.Random: No such file
如果我评论随机相关线路,并把一个固定值R1然后我得到indendation错误以下(笑):
f = open("-s_" + str(r1) + "-m_" + str(m) + "-n_" + str(n) + "-p_" + str(p) + "-a_" + str(a)+ "-i_" + str(i) + ".xml", "w") ^IndentationError: unexpected indent
箭头指向-a_所以它不可能是一个IND因为它在线的中间对吗?
因此,我清理我的项目,复制到不同的目录,重拍,然后我重新运行脚本。现在,循环正常运行(控制台输出和创建的文件),但可执行似乎并没有运行(文件为空),并在每个循环迭代我仍然得到错误:
/bin/sh: 1: cannot open random.Random: No such file
AMO 如果我再次提出评论,如上所述,我得到了! :
Error: the argument ('eed') for option '--seed' is invalid
那么这是一个明显的内存泄漏(缓冲液/堆栈溢出)由C++可执行?
如果你说'FNAME会发生什么= “seed_” + STR(R1)+ “-m_” + STR(M)+“-n_ “+ str(n)+”-p_“+ str(p)+”-a_“+ str(a)+”-i_“+ str(i)+”.xml“;打印fname;打开(fname,“w”);' –
我没有通读你的python代码,但我真的*怀疑它是一个“内存泄漏”或堆栈/缓冲区溢出或其他任何与C++你正在调用的代码。 – yzt