我正在尝试编写一个非常简单的暴力破解程序来尝试破解受密码保护的 zip 文件。该文件的密码是“红色”。
import zipfile;
zfile = zipfile.ZipFile('password_archive.zip')
words = open('/usr/share/dict/words')
for word in words.readlines():
try:
password = word.strip('/n')
zfile.extractall(pwd=password)
print "Password found: "+ password
exit(0)
except Exception, e:
print e
安慰:
('Bad password for file', <zipfile.ZipInfo object at 0x1004ca500>)
('Bad password for file', <zipfile.ZipInfo object at 0x1004ca500>)
('Bad password for file', <zipfile.ZipInfo object at 0x1004ca500>)
('Bad password for file', <zipfile.ZipInfo object at 0x1004ca500>)
('Bad password for file', <zipfile.ZipInfo object at 0x1004ca500>)
('Bad password for file', <zipfile.ZipInfo object at 0x1004ca500>)
('Bad password for file', <zipfile.ZipInfo object at 0x1004ca500>)
('Bad password for file', <zipfile.ZipInfo object at 0x1004ca500>)
Password found: Abasgi
不太确定这里发生了什么。Abasgi 不是正确的密码,但脚本似乎因密码错误而失败,并且似乎找到了正确的密码。我想我已经在循环中的正确位置设置了密码变量。