【发布时间】:2012-08-09 16:16:52
【问题描述】:
我正在编写一个简单的模糊器,用于 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()
【问题讨论】:
-
我感觉您需要以管理员身份运行它才能访问程序文件。
-
当你运行这个时,你的当前目录是什么目录?请记住,写入 Program Files 下的目录有点类似于尝试写入 UNIX 机器上的 /usr/bin 或类似的系统目录。
-
您的文件名无效,您需要可执行文件的完整路径,而不仅仅是目录才能启动进程。
标签: python windows-7 permissions