4
I’m trying to create a Bruteforce program that can generate passwords with a size x of characters. The problem is that I can’t develop a logic for this. See my code below:
chars = getAllChars() # Obtém caracteres [A-z 0-9]
password = "pato34" # Senha que deverá ser encontrada
c1, c2, c3, c4, c5, c6 = "", "", "", "", "", ""
def checks(*chars, show = True):
global password
string = ""
for char in chars:
string += char
if show: print(string)
if string == password: return True
def bruteForce():
global c1,c2,c3,c4,c5,c6
for c1 in chars:
if checks(*getChars()): return getChars()
for c2 in chars:
if checks(*getChars()): return getChars()
for c3 in chars:
if checks(*getChars()): return getChars()
for c4 in chars:
if checks(*getChars()): return getChars()
for c5 in chars:
if checks(*getChars()): return getChars()
for c6 in chars:
if checks(*getChars()): return getChars()
def getChars():
return c1, c2, c3, c4, c5, c6
print(bruteForce())
This code basically tries every possible combination with every letter and number until it finds a 6-digit password. The problem is that if I want to do a Bruteforce for 20-digit passwords, I should write 20 blocks for
.
You can reduce this so you don’t need to write more lines of code for a larger password size ?