Instead make the former a decorator and the latter part of the calling code, which should be protected by a if _name_ = "_main_": guard to allow you to import from this script without running the brute force cracker: from time import perf_counter Note also that the timing and output string are not in there. Here I used some string formatting to get the right format. With these small changes your code would become: def guess_password(real):Ĭhars = string.ascii_uppercase + string.digitsįor guess in itertools.product(chars, repeat=password_length): Just get it from the real password (or, in a more realistic cracker, pass the length as a parameter). ![]() You know the length of the password, so no need to hardcode it. You could have saved yourself the first str.join entirely by directly converting to list. You also str.join the guess, then convert it to a list, then replace the values and str.join it again. ![]() So don't go on generating all combinations of length 23, only to throw most of them away. ![]() Here you have a 20 character password separated into four blocks of five characters each, joined with a. You should exploit the structure of the password, if it has any.
0 Comments
Leave a Reply. |