0

I'm looking to preform a dictionary attack and want to know how to create a wordlist that has every 10 letter permutation of the letters a-f and 2-9 (which I can do) WHEN every word contains 5 letters (a-f) and 5 numbers (2-9) OR 6 letters (a-f) and 4 numbers (2-9) ONLY (what I can't do).

Here's what I have so far (from here):

import itertools

chrs = 'abcdef23456789'
n = 2

min_length, max_length = 10, 10

for n in range(min_length, max_length+1):
    for xs in itertools.product(chrs, repeat=n):
        print ''.join(xs)

Thanks

Community
  • 1
  • 1
findavcol
  • 7
  • 3

3 Answers3

0

Just write a function that returns the number of valid letters and numbers in a string and test the return value.

nums = '23456789'
chars = 'abcdef'

def letter_number_count(word):
    l,n = 0,0
    if len(word) == 10:
        for c in word:
            if c in nums:
                n += 1
            elif c in chars:
                l += 1
    return l,n

Test output

>>> s = 'abcdef2345'
>>> (l,n) = letter_number_count(s)
>>> if (l,n) == (6,4) or (l,n) == (5,5):
...     print "Do something"
... 
Do something
>>> 
Thane Plummer
  • 7,966
  • 3
  • 26
  • 30
0

You could just individually check each permutation, and if it satisfies the condition, add it to an array. just write a simple boolean function that counts the numbers and letters in each function, and checks the condition.

Gershon Papi
  • 5,008
  • 3
  • 24
  • 50
0

This will print you 20 such permutations from total number n! where n = 10 (10! = 3,628,800)

import itertools as it
print(list(map(''.join,it.islice(it.permutations('abcdef23456'), 20))))

['abcdef2345', 'abcdef2346', 'abcdef2354', 'abcdef2356', 'abcdef2364', 'abcdef2365', 'abcdef2435', 'abcdef2436', 'abcdef2453', 'abcdef2456', 'abcdef2463', 'abcdef2465', 'abcdef2534', 'abcdef2536', 'abcdef2543', 'abcdef2546', 'abcdef2563', 'abcdef2564', 'abcdef2634', 'abcdef2635']
Fernando Matsumoto
  • 2,697
  • 1
  • 18
  • 24
LetzerWille
  • 5,355
  • 4
  • 23
  • 26