我正在编写一个简单的模糊器,用于基于Charlie Miller代码的Windows应用程序,这些代码来自于一群猴子的谈话。但是我一直收到错误
Traceback (most recent call last):
File "D:/Python27/fuzzer.py", line 29, in <module>
process=subprocess.Popen([app_choice,fuzz_output])
File "D:\Python27\lib\subprocess.py", line 679, in __init__
errread, errwrite)
File "D:\Python27\lib\subprocess.py", line 896, in _execute_child
startupinfo)
WindowsError: [Error 5] Access is denied
有谁知道如何绕过这个?我真的很难过,因为我不太熟悉Windows 7权限或Python 2.7。完整代码
#List of file names (all located in the python folder)
fuzz_files=[ "slides_algo-guiding.pdf", "slides_algo-intro-annotated- final.pdf","slides_algo-merge1.pdf"]
apps=["C:\Program Files (x86)\Adobe\Reader 9.0\Reader"
]
#Creates an output file in the Python folder
fuzz_output="fuzz.pdf"
FuzzFactor=50
num_tests=1000
import math
import string
import random
import subprocess
import time
for i in range(num_tests):
file_choice=random.choice(fuzz_files)
app_choice=random.choice(apps)
buf=bytearray(open(file_choice,'rb').read())
#Charlie Miller code
numwrites=random.randrange(math.ceil((float(len(buf))/FuzzFactor)))+1
for j in range(numwrites):
rbyte=random.randrange(256)
rn=random.randrange(len(buf))
buf[rn]="%c"%(rbyte)
#End Charlie miller code
#Write code
open(fuzz_output,'wb').write(buf)
process=subprocess.Popen([app_choice,fuzz_output])
time.sleep(1)
crashed=process.poll()
if not crashed:
process.terminate()
答案 0 :(得分:1)
我认为C:\Program Files (x86)\Adobe\Reader 9.0\Reader
是文件夹的路径,而不是可执行文件。因此,尝试使用Popen
运行它是没有意义的。
此外,在编写Windows路径r"C:\Program Files (x86)\Adobe\Reader 9.0\Reader\AcroRd32.exe"
或使用斜杠而不是"C:/Program Files (x86)/Adobe/Reader 9.0/Reader/AcroRd32.exe"
时,您应该使用原始字符串。你很幸运,路径中没有任何有效的转义序列。