-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrute.py
47 lines (43 loc) · 1.69 KB
/
brute.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
import zipfile, time
def bruteforce(file, list="lists\list100k.txt", list2="lists\list1m.txt"):
zip = zipfile.ZipFile(file) #open the zipfile
password = None
counter = 0
startTime = time.time() #check when we started so we can know how much time it took us
with open(list, "rt") as f: #open the first 100,000 passwords
listpass = [x.strip() for x in f.readlines()] #takes passwords from the list one by one while omitting the "\n"
for password in listpass: #take the passwords one by one
counter += 1
try:
zip.extractall(pwd=password.encode('cp850','replace')) #try to open the file with the given password
except RuntimeError:
continue #if fails, continue to the next run of the loop
finishTime = time.time() - startTime #how much time it took us
speed = counter/finishTime #how many tries we were doing per second
print("Password Found")
print("Password:",password)
print("It took ",finishTime," seconds to crack the Password (",speed," attempts per second).",sep='')
f.close()
return
with open(list2, "rt") as f: #open the last 900,000 passwords
listpass = [x.strip() for x in f.readlines()]
for password in listpass:
counter += 1
try:
zip.extractall(pwd=password.encode('cp850','replace'))
except RuntimeError:
continue
finishTime = time.time() - startTime
speed = counter/finishTime
print("Password Found")
print("Password:",password)
print("It took ",finishTime," seconds to crack the Password (",speed," attempts per second).",sep='')
f.close()
return
print("Password Not Found")
f.close()
if __name__ == "__main__": #don't run if imported
path = input("zip path?\n")
bruteforce(path)
input("Press Enter to exit...")
quit()