Code to bruteforce words from given chars

Written in python, can be easily be translated into other languages
pull/1/head
EmaMaker 2018-12-27 18:11:28 +01:00 committed by GitHub
commit a8b314e558
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 50 additions and 0 deletions

50
bruteforce.py Normal file
View File

@ -0,0 +1,50 @@
'''
PYTHON CODE BRUTEFORCES WORDS FROM GIVEN CHAR LIST.
ENDLESS WORD LIST CAN BE GENERATED, UNTIL PROGRAM STOPPED
EVERY 100 WORDS GENERATED THEY ARE SAVED ON FILE
'''
lPossibleChars = ("a", "b", "c", "d", "e", "f")
sWord = ""
sFileName = "words.txt"
lGenWords = []
dWordsForSave = 100
def bruteforce(index):
global sWord, lPossibleChars
#generates only if the index to change is less than currrent word length
if index < len(sWord):
for i in range(len(lPossibleChars)):
#makes the word a list
lWord = list(sWord)
#changes the index
lWord[index] = lPossibleChars[i]
#makes the list back a word
sWord = ''.join(lWord)
print(sWord)
#adds to the list
lGenWords.append(sWord)
#goes on for the next index
bruteforce(index + 1)
while True:
#saves word on file (append mode) and cleares the list
if len(lGenWords) >= dWordsForSave:
f = open(sFileName, "a")
for s in lGenWords:
f.write(s + "\n")
lGenWords[:] = []
f.close()
#starts bruteforcing the word and adds a new character when ended
if len(sWord) > 0:
bruteforce(0)
sWord += lPossibleChars[0]