I need to crack my own router password. Advantage is that I know possible characters and maximum length.

What I need is to create a dictionary. The dictionary should contain all the combos of characters that I choose. I know that the maximal length is 8 characters, and each character can be ([A-Za-z0-9]).

How can I do that?

4 Answers 4


Well, I don't see why you need to create a dictionary. You could just generate the letter combinations as the program runs. No need to generate all the combinations ahead of time.

As for generating every combination, your alphabet has 62 characters in it. So, the number of combinations up to 8 characters in length, having at least one character is:

62 + 62^2 + 62^3 + 62^4 + 62^5 + 62^6+ 62^7 + 62^8 = 221,919,451,578,090

That is about 222 trillion combinations. So, you would need to buy about 200 terabyte hard drives to store your dictionary. Are you sure you want to do that?

Also, if you could generate and write to disk 1 billion combinations per second, then it would take 479 years to write all the combinations, so you would have to have your descendants continue the project after you had passed on.

  • The question was to address the how not the complexity - the math! Jan 22, 2017 at 19:25
  • 1
    Based on the op's question it would seem that he is unfamiliar with password cracking and thus unaware of why his approach is a bad idea from a performance perspective (disk vs memory speed)
    – wireghoul
    Jan 22, 2017 at 19:51
  • +1 I went ahead and wrote a program to do it without even thinking about how many permutations there would be. Doing this math first stops you from wasting time like I did. Jan 23, 2017 at 2:47
  • About 222 trillion combinations but roughly 2 quadrillion bytes hence 2000 x 1TB disks. Jan 23, 2017 at 12:38

It's fairly easy to program this yourself; here's an implementation in Python:

#!/usr/bin/env python3

import itertools
import string

candidate_characters = list(string.ascii_letters + string.digits)
for password_length in range(1, 9):
    for candidate_password in \
            itertools.permutations(candidate_characters, password_length):

As Tyler Durden points out, however, doing this directly is infeasible due to the amount of disk space it will consume.

A better approach would be to not store a dictionary on disk, but try these candidate passwords as you generate them. However, it's still not a great one: if you have to go through all possible 222 trillion combinations, that's going to take a hell of a long time (say, 10 a second? That's a few times longer than the time since the last ice age).

If it's your own router, just hit the reset button.


A simple little python script that makes a "brute_wordlist.txt" file:

Be careful.. This can make pretty large files, pretty fast! Make sure you got plenty room on your hard drive (and don't try to 'cat' the word-list 🤣). You'll think it locked up but it WILL output the number of 'passwords' it created when it's finished, letting you know its done. Try entering a min=1 and max=2 first to verify it's working. Then try larger inputs. Expect it to run for about 30minutes for min3 - max5. There are better methods to cracking OP's issue that don't involve creating huge files and will use a GPU instead of a CPU (much, much faster. eg. Hashcat (which also can be used in Windows OS (so no GPU configuration needed)).

from itertools import product   # itertools is built in Python
import string                   # also included   

min_len = int(input("Enter the minimum length: "))
max_len = int(input("Enter the maximum length: "))
counter = 0
character = string.ascii_lowercase+string.ascii_uppercase+string.digits+string.punctuation

file_open = open("brute_wordlist.txt",'w')

for i in range(min_len,max_len+1):
    for j in product(character,repeat=i):
        word = "".join(j)
        counter += 1
print("Wordlist of {} passwords created".format(counter))

This can easily be modified to add in words you might know are in the password: 1st: add in a input variable on line6 so you'll instead have:

max_len = int(input("Enter the maximum length: "))
known_word = input("What is the known word? ")
counter = 0

2nd:Then just cantonese the 'known_word' on line14:

word = known_word+"".join(j)

So if known_word is "Jimmy" and you enter min=1 and max=2 you'll get: Jimmya Jimmyb... JimmyZZ You get the idea. If there are other known words simply add another 'known_word2' variable-input on line7 and again cantonese the variable 'word = ...+known_word2+...' where you think it may go in the password.

A word + 4 characters (min=4 max=4 knownword=Jimmy) is a 755mb file and can be created in about a minute. So it is a very "do-able" method quite to contrary the top post implies.


There are plenty of approaches to this:

  1. Programming to have a dictionary wordlist
  2. Using existing tool to create a dictionary

For Approach one, I would recommend using Python (being it less time consuming). You can use itertools.permutation Here's a sample code:

import itertools
res = itertools.permutations('abc',3) # 3 is the length of your result.
for i in res: 
   print ''.join(i)

For Approach two, you can use crunch to create the list as per needs:

Sample Code:

crunch 8 8 -f /usr/share/rainbowcrack/charset.txt mixalpha -o /root/alphawordlist.lst

You can use man crunch in Kali Linux to opt for the syntax.

Later you can use Hydra to brute using the custom dictionary you needed.

  • 1
    Notably, your python doesn't calculate passwords up to 3 characters long, and doesn't have the correct input set. Jan 23, 2017 at 2:50
  • @XiongChiamiov it's noted in answer area to be a sample program. It was meant to be. The answer was needed to be how .. Jan 23, 2017 at 5:25
  • This looks like an example for how to use itertools.permutation, but as stated above, you don't explain it in a way that actually answers what was asked. It's half of an example.
    – schroeder
    Dec 2, 2023 at 15:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .