Skip to content

Commit 03588ef

Browse files
author
Haripriya Baskaran
committed
Add comments in code
1 parent 89b231d commit 03588ef

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Python/Crack_Zip_File/crack_zip.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,26 @@
22
import zipfile
33
import sys
44

5+
# input from user
56
wordlist = input("Enter Words list filename: ")
67
zip_file = input("Enter zip filename: ")
78

9+
# initialize the Zip File object
810
zip_file = zipfile.ZipFile(zip_file)
11+
# count the number of words in this wordlist
912
n_words = len(list(open(wordlist, "rb")))
13+
# print the total number of passwords
1014
print("Total passwords to test:", n_words)
1115
with open(wordlist, "rb") as wordlist:
1216
for word in tqdm(wordlist, total=n_words, unit="word"):
1317
try:
18+
# Check if the current selected password unzips the zip file
1419
zip_file.extractall(pwd=word.strip())
1520
except:
1621
continue
1722
else:
23+
# if password found from the word list,
24+
# exit from program
1825
print("Password found:", word.decode().strip())
1926
exit(0)
2027
print("Password not found, try other wordlist.")

0 commit comments

Comments
 (0)