目錄
源碼在這里
需要的模塊
準備一個密碼本和需要破解的ZIP文件
一行一行地從密碼文件中讀取每個密碼。
核心部分
注意,需要修改上段代碼注釋里的這段具有編碼問題的代碼:
源碼在這里
https://github.com/Wist-fully/Attack/tree/cracker
需要的模塊
from tqdm import tqdm
import zipfile
import pyzipper
準備一個密碼本和需要破解的ZIP文件
passwordfile = "PasswordFile.txt"
zip_file = "zzipp.zip"
一行一行地從密碼文件中讀取每個密碼。
n_words = len(list(open(passwordfile,"rb")))
print("總密碼共有: ",n_words)
核心部分
使用 tqdm 顯示一個進度條,讓你知道已經試了多少個密碼。
使用 pyzipper 嘗試用這個密碼去解壓 ZIP 文件。
如果密碼正確,就顯示成功并輸出正確的密碼;如果不對,就跳過繼續試下一個。
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:continueelse:print("[+] password found:",word.decode().strip())exit(0)
print("[!] password not found,try other wordlist")
注意,需要修改上段代碼注釋里的這段具有編碼問題的代碼:
zip_file.extractall(pwd=pwd)