# Generate wordlist with exactly 4 letters and 6 numbers in any order?

I need to configure crunch so that it produces a wordlist with the following set of rules:

• Exactly 10 characters long
• Contains exactly 4 letters, which have to be a-f (all lowercase)
• Contains exactly 6 numbers, which have to be 2-9
• The letters and numbers can be anywhere in the word

I'm guessing maybe regex is involved?

I don't know if crunch is able to generate that, however it's pretty easy to generate the word list programmatically. I put such a program (un-optimized) at :

https://gist.github.com/brohee/e0be67593b71d2845b86

The word list ends up humongous, so not hosting it anywhere...

The list going from "aaaa222222" to "aa973ac757" was already 2.6GiB big, so I stopped the experiment.

• Original asker here... That program is very helpful, and does seem the best way to approach this problem. Is there any way to add a function to that program that disallows character repetition above 2? So for example, 'ba444a5c51' would not be allowed because the number 4 appears 3 times in sequence. Also.... How would I calculate the amount of possible passwords with these rules? Is it something along the lines of: (6^6)*(8^4)*10 which is (6 possible letters ^ 6 letters) * (8 possible numbers * 4 numbers) * password length I'm doing this for my Computer Science Dissertation so any help is gre
– Tom
Oct 15, 2015 at 11:54
• By the way, I couldn't comment on Bruno Rohée's answer as my reputation is too low :(
– Tom
Oct 15, 2015 at 11:55
• My program is pretty easy to extend, filtering for two many repetitions is easy before output. This is easier (but slower) than just not repeating them in the first place... As for the number of passwords permitted by the complete rules, that should be a pretty easy enumerative combinatorics question, more suited for another stack exchange site... Oct 15, 2015 at 12:22
• Could you give me any advice on how to implement the repetition feature? I understand your code but I am struggling to figure out how to do it. Sorry to be a pain!
– Tom
Oct 15, 2015 at 20:11
• gist.github.com/brohee/c6e3f3dec32f009ba255 as I said just check for repetition and abort. The result set is still huge even removing password with 3 consecutive identical chars, and the program is very slow, it displays obvious correctness but would be pretty dramatic changes to be fast. Oct 15, 2015 at 23:36

I tried to generate the wordlist using the following crunch 10 10 charset abcdef23456789 and then pipeline the result to either egrep or perl one line and write a regex to filter for strings which has 6 numbers with no luck so far but I think this is the way to go. other way is to generate 2 different wordlists and combine them

• This is asking crunch to generate 14^10=289,254,654,976 words then throwing most of the output. A regex is less than ideal for that purpose, the one that works being more expensive than a purpose built program... Oct 15, 2015 at 5:37

You can create a password list by using the following command:

``````crunch min max input-list -t pattern -o output-filename
``````

e.g.

``````crunch 10 10 abcdef23456789 -o output_file.txt
``````