-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbruteForce.py
56 lines (41 loc) · 1.16 KB
/
bruteForce.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
from itertools import product
def findPassword(chars, function, show=50, format_="%s"):
password = None
attemps = 0
size = 1
stop = False
while not stop:
for pw in product(chars, repeat=size):
password = "".join(pw)
if attemps % show == 0:
print(format_ % password)
if function(password):
stop = True
break
else:
attemps += 1
size += 1
return password, attemps
def getChars():
chars = []
for id_ in range(ord("A"), ord("Z") + 1):
chars.append(chr(id_))
for number in range(10):
chars.append(str(number))
return chars
if __name__ == "__main__":
import time
pw = input("input password : ")
print("\n")
def testFunction(password):
global pw
if password == pw:
return True
else:
return False
chars = getChars()
t = time.process_time()
password, attemps = findPassword(
chars, testFunction, show=1000, format_="trying %s"
)
input(f"\n\n Password found :{password} \n attemps: {attemps}\n time: {t} \n")