-
Notifications
You must be signed in to change notification settings - Fork 3
/
Crack zip files.py
82 lines (33 loc) · 1.49 KB
/
Crack zip files.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import zipfile
#crack zip file with dictionary attack
def ex7():
try:
#first you have to define the directory of the zip file you want to enter, or if you know only the name of
#zip file you can just check the directories and search for the zip file you want
#with the command os.listdir(path), which returns in a list all the names (files) of a directory you can check for
#your file
myzip = zipfile.ZipFile('test_zip.zip')
#raise exceptions
except zipfile.BadZipfile:
print("ERROR")
quit()
#start with no passowrd
password = None
#supposing that you have already a deictionary you just read every line of it (every line represents a candidate password)
with open('english.txt','r') as f:
passes = f.readlines()
#iterate the list
for x in passes:
password = x.split('\n')[0]
try:
print(password)
#encode the password to utf 8, which means that you encode that password to one 8 bit number
pas = str.encode((password))
#try your password
myzip.extractall(pwd=pas)
#print it
print('Password cracked with : ',password)
quit()
except Exception:
pass
print('Password not found')