-
Notifications
You must be signed in to change notification settings - Fork 148
/
project17.py
35 lines (29 loc) · 963 Bytes
/
project17.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# ZIP password cracker
# This script iterates through a user provided dictionary and finds the password for the encrypted
import zipfile
'''
zipfile has a method call extractall().
extractall(self, path=None, members=None, pwd=None)
Extract all members from the archive to the current working
directory. `path' specifies a different directory to extract to.
`members' is optional and must be a subset of the list returned
by namelist().
'''
def test_pass(zipfile, password):
try:
zipfile.extractall(password)
return password
except Exception as ex:
print("An error occured "%(ex))
return
def main():
zip_obj = zipfile.ZipFile('''Use zip file you want to crack''')
filepass = open('dictionary.txt')
for word in filepass.readlines():
password = word.split('\n')
guess_password = test_pass(zip_obj, password)
if guess_password:
print("[+] Password found:" + password + "\n")
exit(0)
if __name__ == '__main__':
main()