今天突然发现自己以前的压缩包密码忘了,网上很多的破解软件又要收费,怎么办,自己用python写一个压缩包密码暴力破解程序把。
在本教程中,您将编写一个简单的Python脚本,尝试使用Dictionary Attack破解zip文件的密码。
我们将使用Python的内置zipfile模块和第三方tqdm库来快速打印进度条:
pip3 install tqdm
如前所述,我们将使用字典攻击,这意味着我们将需要一个词表来暴力破解此受密码保护的zip文件。在本教程中,我们将使用较大的rockyou单词表(大小约为133MB),如果您使用的是Kali Linux,则可以在/usr/share/wordlists/rockyou.txt.gz路径下找到它。否则,下载地址为https://github.com/brannondorsey/naive-hashcat/releases/download/data/rockyou.txt。import zipfile from tqdm import tqdm
# the password list path you want to use, must be available in the current directory wordlist = "rockyou.txt" # the zip file you want to crack its password zip_file = "secret.zip"
# initialize the Zip File object zip_file = zipfile.ZipFile(zip_file) # count the number of words in this wordlist n_words = len(list(open(wordlist, "rb"))) # print the total number of passwords print("Total passwords to test:", n_words)
with open(wordlist, "rb") as wordlist: for word in tqdm(wordlist, total=n_words, unit="word"): try: zip_file.extractall(pwd=word.strip()) except: continue else: print("[+] Password found:", word.decode().strip()) exit(0) print("[!] Password not found, try other wordlist.")
root@bfw:~# gunzip /usr/share/wordlists/rockyou.txt.gz
root@bfw:~# python3 zip_cracker.py secret.zip /usr/share/wordlists/rockyou.txt
Total passwords to test: 14344395
3%|▉ | 435977/14344395 [01:15<40:55, 5665.23word/s]
[+] Password found: abcdef12345
网友评论0