I'm using this code to break an simple password mycubana, but I want to "pause" the itertools loop so that, after some time, I could resume the loop starting from the last saved itertools.product
value. Is there any way to do it without change a lot of the code ?
Code:
import string
from itertools import chain, product
def bruteforce(charset, minlenght, maxlenght):
return(''.join(candidate)
for candidate in chain.from_iterable(product(charset, repeat = i)
for i in range(minlenght, maxlenght)))
contador = 0
for attempt in bruteforce(string.ascii_lowercase, 8, 9):
codigo = 'mycubana'
contador+=1
if attempt==codigo:
print(attempt)
contador=0