In: Computer Science
Write a Python script that performs brute force to extract a password protected zip file named sec2.zip. The password is believed to be associated with one of the dictionary word in the 'wordlist.txt file.
a) Paste your code here
b) What is the password?
pip3 install tqdm
import zipfile
from tqdm import tqdm
# the password list path you want to use, must be there
in the current directory
wordlist = " wordlist .txt"
# the zip file
zip_file = "secret.zip"
# initializing the Zip File object
zip_file = zipfile.ZipFile(zip_file)
# count the no of words in this wordlist
n_words = len(list(open(wordlist, "rb")))
# print the total number of passwords
print("Total passwords: ", 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("[!] Sorry Password not found, try other wordlist.")
root@rockikz:~# gunzip /usr/share/wordlists/rockyou.txt.gz
root@rockikz:~# python3 zip_cracker.py secret.zip
/usr/share/wordlists/ wordlist .txt
Total passwords: 14344395
Password found: abcdef12345