-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrute_force_test.py
More file actions
28 lines (23 loc) · 913 Bytes
/
Copy pathbrute_force_test.py
File metadata and controls
28 lines (23 loc) · 913 Bytes
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
import itertools
import string
import time
def guess_password(real):
start = time.perf_counter()
chars = string.ascii_lowercase + string.digits
attempts = 0
for password_length in range(1, 9):
for guess in itertools.product(chars, repeat=password_length):
attempts += 1
if attempts % 100000000 == 0:
print(f"{attempts:,}")
print(guess)
guess = ''.join(guess)
if guess == real:
end = round(time.perf_counter() - start)
length = len(real)
print('Time needed was roughly {:,} seconds for password with {} chars.'.format(
end, length))
return 'Password is {} and was found in {:,} guesses.'.format(guess, attempts)
print(guess_password('auto123'))
# make this work with actual files like pdf?
# what about using generators?