我试图对我丢失了密码的zip文件进行强力攻击,我知道开头是肯定的,结局是[0-9] [a-zA-Z] {3}所以我尝试从START +“0aaa”到START +“9ZZZ”的密码。生成工作正常,但是当我尝试解压缩归档时,我收到一个错误:
zlib.error: Error -3 while decompressing data: invalid code lengths set
这是暴力攻击逻辑代码:
from zipfile import ZipFile
START="..." #start of the password
DIR="path/to/dir"
# shiftKey function, tested and perfectly working
def shiftKey(key): ...
if __name__ == "__main__":
with ZipFile(DIR+"folder.zip") as zf:
key="0aaa"
while True :
encoded=(START+key).encode()
try:
zf.extractall(DIR+"out", pwd=encoded) # error launched here
print("Key was: %s" % key)
break
except RuntimeError:
pass #wrong password
if key == "9ZZZ":
print("never matched")
break
key=shiftKey(key)
尝试使用空启动时,它始终停在“0aeR”,并且在非空启动时更快,而且错误更改现在是:zlib.error: Error -3 while decompressing data: invalid stored block lengths
在我看来,编码方法有限制容量或配置错误,所以有没有办法扩大它或解决方法使其工作?