目录
源码在这里
https://github.com/Wist-fully/Attack/tree/cracker
需要的模块
python
from tqdm import tqdm
import zipfile
import pyzipper
准备一个密码本和需要破解的ZIP文件
python
passwordfile = "PasswordFile.txt"
zip_file = "zzipp.zip"
一行一行地从密码文件中读取每个密码。
python
n_words = len(list(open(passwordfile,"rb")))
print("总密码共有: ",n_words)
核心部分
使用 tqdm 显示一个进度条,让你知道已经试了多少个密码。
使用 pyzipper 尝试用这个密码去解压 ZIP 文件。
如果密码正确,就显示成功并输出正确的密码;如果不对,就跳过继续试下一个。
python
with open(passwordfile,"rb") as wordlist:
for word in tqdm(wordlist,total=n_words,unit="word"):
pwd = str(word,'utf-8').replace('\n','')
try:
# 把zip_file.extractall(pwd=pwd),修改为下面这句代码
with pyzipper.AESZipFile(zip_file, 'r', compression=pyzipper.ZIP_DEFLATED, encryption=pyzipper.WZ_AES) as extracted_zip:
extracted_zip.extractall(pwd=str.encode(pwd))
except:
continue
else:
print("[+] password found:",word.decode().strip())
exit(0)
print("[!] password not found,try other wordlist")
注意,需要修改上段代码注释里的这段具有编码问题的代码:
python
zip_file.extractall(pwd=pwd)