AttributeError: 'str' object has no attribute 'extractall' extracting zip from brute force
AttributeError: 'str' object has no attribute 'extractall' extracting zip from brute force
我不确定为什么会出现以下错误,我在早些时候暴力破解后知道密码,但不允许我提取文件。
需要将我的文件解压到目录/tmp
那么我是不是漏掉了任何明显的东西?
输出错误:
Traceback (most recent call last):
File "/tmp/usercode.py", line 45, in <module>
myZip.extractall("/tmp",pwd = str(password))
AttributeError: 'str' object has no attribute 'extractall'
代码:
import zipfile
from zipfile import ZipFile
import zipfile
zf = zipfile.ZipFile('/tmp/myfile.zip')
for x in range(0,139):
#Legacy for loop now
password = "past"
print(password)
for filename in [ 'textinhere.txt' ]:
myZip = "textinhere.txt"
try:
myZip.extractall("/tmp",pwd = str(password))
except KeyError:
print 'ERROR: Did not find %s in zip file' % filename
else:
print filename, ':'
print repr(data)
您在这里定义了一个字符串:
myZip = "textinhere.txt"
exctractall
是ZipFile
class的一个方法。所以你需要先构造一个 ZipFile
的实例,假设这个名称是你希望用作 ZipFile 实例路径的文件:
myZip = ZipFile("textinhere.txt")
...只有这样才能调用myZip.extractall(...
我不确定为什么会出现以下错误,我在早些时候暴力破解后知道密码,但不允许我提取文件。
需要将我的文件解压到目录/tmp
那么我是不是漏掉了任何明显的东西?
输出错误:
Traceback (most recent call last):
File "/tmp/usercode.py", line 45, in <module>
myZip.extractall("/tmp",pwd = str(password))
AttributeError: 'str' object has no attribute 'extractall'
代码:
import zipfile
from zipfile import ZipFile
import zipfile
zf = zipfile.ZipFile('/tmp/myfile.zip')
for x in range(0,139):
#Legacy for loop now
password = "past"
print(password)
for filename in [ 'textinhere.txt' ]:
myZip = "textinhere.txt"
try:
myZip.extractall("/tmp",pwd = str(password))
except KeyError:
print 'ERROR: Did not find %s in zip file' % filename
else:
print filename, ':'
print repr(data)
您在这里定义了一个字符串:
myZip = "textinhere.txt"
exctractall
是ZipFile
class的一个方法。所以你需要先构造一个 ZipFile
的实例,假设这个名称是你希望用作 ZipFile 实例路径的文件:
myZip = ZipFile("textinhere.txt")
...只有这样才能调用myZip.extractall(...