Python - create wordlist from given characters of that contain 4-5 letters and 5-6 numbers ONLY
Question: 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](http://stackoverflow.com/questions/21559039/python-how-to-generate-
wordlist-from-given-characters-of-specific-length)):

    
    
    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


Answer: 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
    >>> 
    

