此脚本尝试使用words.txt中的单词打开受密码保护的文件arch.zip,该单词是476k English words的列表。密码是"密码"我已将这两次添加到words.txt中,一次在开头附近,一次作为文件的最后一个单词。
with open("words.txt", "r") as the_text:
for entry in the_text.readlines():
password = entry.strip('\n')
try:
with zipfile.ZipFile('arch.zip', 'r') as zf:
zf.extractall(pwd=password)
print '[+] Found password = ' + password + '\n'
except:
pass
这会尝试每一行,即使它与密码匹配,我知道这很糟糕,但它显示了问题 - 在脚本以最终正确匹配结束之前,几个非密码字匹配。
我很容易修复此问题(在try / except中使用exit(0))但我很好奇为什么不正确的匹配?
[+] Found password passwordy
[+] Found password flashtubes
[+] Found password hecatontarchy
[+] Found password Judette
[+] Found password kiss-me-quick
[+] Found password miriness
[+] Found password pre-earthly
[+] Found password tenositis
[+] Found password unconsolable
[+] Found password passwordy