vendredi 23 octobre 2015

Randomised Brute Forcer

For educational purposes, I made a simple Brute Forcer. Due to how it works though, the likelihood of me getting results early on is incredibly slim. That said, I would like to randomise the results without getting duplicates and without slowing it down drastically.

The code at the moment:

from threading import Thread

charset = (
        'abcdefghijklmnopqrstuvwxyz'
        '1234567890'
        'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
)

def recurse(width, position, base_string):
    for i in range(len(charset)):
        if position < (width - 1):
            Thread(target=recurse(width, position+1,base_string+charset[i])).start()
        Thread(target=write_content(base_string+charset[i]+'\n')).start()

def write_content(content):
    with open('permutations', 'a+') as f:
            f.write(content)

if __name__ == '__main__':
    recurse(15,0,'')

My goal is to get my results randomized. So instead of:

aaa
aab
aac
aba
...
cbc
cca
ccb
ccc

I'd get something along the lines of:

aaa
bac
cba
abc
bbc
ccc
...

How would I go about this? I've been thinking about it for some time and just can't work it out.

Also, what language would process this the fastest?




Aucun commentaire:

Enregistrer un commentaire