得到这个简单的脚本来尝试来自 txt 的所有密码,直到它工作,得到那个错误:
import zipfile
def extractFile(zfile, password):
try:
zfile.extractall(pwd=password)
return password
except:
return
zfile = zipfile.ZipFile('geschenk.zip')
passFile = open('rockyou.txt')
for line in passFile.readlines():
password = line.strip('\n')
guess = extractFile(zfile, password)
if guess:
print('Password is ' + password)
break
错误:
Traceback(最近一次调用最后):文件“crack.py”,第 14 行,在 passFile.readlines() 中的 for 行:文件“C:\Users\Galax\AppData\Local\Programs\Python\Python38\lib\encodings \cp1252.py",第 23 行,解码返回 codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 3149: character maps to
修复:添加errors="ignore"
到open()