Я пытаюсь угадать пароль из файла etc / shadow (в нем 43 пользователя / пароля).И мне дали несколько подсказок о паролях:
- Длина от 4 до 8 символов
- Может быть только 2 цифры и только в конце
- Заглавные буквы только в начале
Итак, я начал с небольшой группы, состоящей из 4 символов с двумя цифрами в ней.Но на это уходит так много времени:
import crypt
import string
import itertools
import datetime
dir = "shadow3"
file = open(dir, 'r').readlines() #Read all the 43 hashes
username = []
hashed = []
c = 0
cc = 0
for x in file: #Split the hash and the username
usr, hshd, wtf, iss, this, thing, here, doing, example = x.split(':')
username.append(usr)
hashed.append(hshd)
#GRUPO1 4 caracteres 2 numeros
letters = string.ascii_lowercase
digits = string.digits
grupo1=[]
group1=itertools.product(letters,repeat=2)
group1b=itertools.product(digits,repeat=2)
for x in itertools.product(group1,group1b): #Join the possible iterations
string=''.join([''.join(k) for k in x])
grupo1.append(string)
print(len(grupo1))
for y in grupo1:#Get the one of the iterations and try it
prueba=y
for x in hashed: #Verify if that iteration is the password to any of the 43 users
rehashed = crypt.crypt(prueba, x)
if rehashed == x: #Password is found
print('La contraseña del usuario ' + username[c] + ' es ' + prueba)
cc = 1
c = c + 1
if cc == 0: #after all iterations password is not found
print('Lo sentimos "' + prueba + '" no es la contraseña de ningun usuario')
Как я могу повысить эффективность этого?У меня есть GTX 1070, если он помогает для любого типа обработки графического процессора.