Since the post on Creating wordlists with crunch v2.4 made in April last year, crunch has gone through
quite a few changes and improvements and bofh28 has now released v3.0 ! (on 16-05-2011)
To make sure that the information on this blog is staying upto date, its time for a new and improved post.
There will be a lot of duplication from my previous post on crunch, but it should then at least
be a more or less full and complete post.
I have tried to follow the alphabetical order of the options and have done a chapter per option/switch.
Please leave comments should the post be lacking information on anything you feel should be included.
crunch is a tool for creating bruteforce wordlists which can be used to audit password strength.
The size of these wordlists is not to be underestimated, however crunch can make use of patterns to reduce wordlist sizes, can compress output files in various formats and (since v2.6) now includes a message advising the size of the wordlist that will be created, giving you a 3 second window to stop the creation should the size be too large for your intended use.
The full range of options is as follows ;
-b Maximum bytes to write per file, so using this option the wordlist to be created can be split into various
sizes such as KB / MB / GB (must be used in combination with «-o START» switch)
-c Number of lines to write to output file, must be used together with «-o START»
-e Specifies when crunch should stop early (crunch v3.1)
-f Path to the charset.lst file to use, standard location is ‘/pentest/passwords/crunch/charset.lst
to be used in conjunction with the name of the desired charset list, such as ‘mixalpha-numeric-space’
-i Inverts the output sequence from left-to-right to right-to-left
(So instead of aaa, aab, aac, aad etc, output would be aaa baa caa daa)
-l When specifying custom patterns with the -t option, the -l switch allows you to identify which of the characters
should be taken as a literal character instead of a place holder ( @,%^ )
-o Allows you to specify the file name / location for the output, e.g. /media/flashdrive/wordlist.txt
-p Prints permutations of the words or characters provided in the command line.
-q Prints permutation of the words or characters found in a specified file
-r Resumes from a previous session, exact same syntax to be used followed by -r
-s Allows you to specify the starting string for your wordlist.
-t Allows you to specify a specific pattern to use. Probably one of the most important functions !
Place holders for fixed character sets are ;
@ — lower case alpha characters
, — upper case alhpa characters
% — numeric characters
^ — special characters (including space)
-u Supresses the output of wordlist size & linecount prior starting wordlist generation.
-z Adds support to compress the generation output, supports gzip, bzip & lzma
All the below is done on backtrack 5, only tested on the 32bit versions.
crunch is not installed by default on BT5 and as yet (22-05-2011) not yet in the repo’s.
(When it does hit the repo’s I will amend this post to reflect installing from repo’s)
so download from the source at ;
and install as follows;
crunch is now available in the BT repositories,
so can download and install on backtrack5 simply by doing a ;
apt-get install crunch
The default installation directory / path for crunch in backtrack 5 is
All the below examples are based on being in the crunch directory /pentest/passwords/crunch/
To run crunch from outside of crunch’s own directory use ;
/pentest/passwords/crunch/crunch [min length] [max length] [ character set] [options]
example from root directory;
Basic usage is as follows to print to screen
To write to file use the -o switch ;
If no character set is defined, then crunch will default to using the lower case alpha character set;
Also any desired character set can be enterered manually in the command line ;
./crunch 6 6 0123456789ABCDEF
Certain characters will need escaping with a backslash \ ;
Using the -b switch, we can tell crunch to create a wordlist which is split into multiple files
of user-specified sizes.
This must be done in conjunction with -o START.
The size definition can be; kb, mb, gb or kib, mib, gib
kb, mb, and gb are based on the power of 10 (i.e. 1KB = 1000 bytes)
kib, mib, and gib are based on the power of 2 (i.e. 1KB = 1024 bytes).
The output files will be named after the first and last entry in the wordlists.
To create a wordlist split into files of not more than 1mb;
To create a wordlist split in files of no more than 100mb;
To create a wordlist split into files of no more that 10kb;
To create a wordlist split into files of no more than 2gb;
(ie. number of passphrases per file)
Using the -c switch you can have crunch create wordlists which do not contain more than the
specified number of lines.
This must be used in conjunction with -o START.
To create files containing no more than 200000 (200 thousand) lines (passphrases);
./crunch 6 6 0123456789 -c 200000 -o START
To create files containing no more that 150000 (150 thousand) lines (passphrases);
The output files will be named after the first and last entry in the wordlists.
STOPPING CRUNCH WORDLIST GENERATION AT A PRE-DETERMINED TIME
Crunch v3.1 is now also released (20-07-2011) and with it comes the new -e switch.
This option allows you to specify when you want the wordlist generation to stop.
So the below example will start creating the 6 character numeric wordlist, but will stop at 333333 ;
./crunch 6 6 -t %%%%%% -e 333333
Crunch also comes with fixed character sets in charset.lst which is included in the installation.
(also found in directory /pentest/passwords/crunch/ )
This saves on the typing (and typoes) when dealing with standard character sets.
To use the fixed characters sets, instead of typing in character sets manually in the command line,
you can use the -f switch to specify which character set we want to use ;
To use only upper case alpha characters;
To use only numeric characters ;
To use hexidecimal characters (with uppercase alpha values) ;
To use lower case, uppercase, numeric & special characters (beware of the size ! Don’t try to save..lol..) ;
Since v2.7 additional Swedish character support has also been added for our Swedish brethren, nicely contributed by Niclas Kroon.
It should be noted that you can easily create your own custom charset by simply including a line in the same format.
If you for instance know that your target has a certain medical condition known as 133tsp34k, and you have an idea of which letters/numbers are usually used (forum posts etc. etc.) , you could simply include an extra line such as ;
1337 = [4bcd3f9hijk1mn0pqr$7uvwxyz]
Doubt the above is authentic enough, but I’m sure you get the idea.
Then just run in crunch as you would any other charset;
./crunch 4 4 -f charset.lst 1337
See /pentest/passwords/crunch/charset.lst for all possibilities / charsets currently included.
Using the -i option will invert the direction in which the wordlist is created, from left-to-right to right-to-left.
Note that this does not change the content of the created wordlist, it only changes the intial direction in which it is created.
The -i option can also be used when character sets have been specified, either manually or using the pre-defined charsets.
./crunch 4 4 -f charset.lst ualpha -i
or for instance for creating numeric wordlists in an alternative direction ;
If you actually want the wordlist creation to start from the last letter in the alphabet and work backwards, or
work backwards from the last digit in a 10 digit numeric sequence, then you would have to enter the charset manually ;
Crunch can also be used to create permutations for either ;
> characters / words entered in the command line with the -p switch.
> lines in a wordlist with the -q switch
Although there is no min/max character setting, this still needs to be entered for both
the -p and -q switch.
Using the -p switch you can create permutations of characters or of all words entered in the command line.
Creating permutations of letters (fun for anograms) ;
Creating permutations of lists of words;
./crunch 1 1 -p bird cat dog
As the -p switch can read the input on command line as being letters or words, it MUST be the last option used;
If for instance trying to suppress the size output message using the -u switch and placing the -u switch last,
crunch will see 2 words (abcd + -u) and so will only print out the 2 permutation possibilities as well as actually recognizing the -u switch ;
./crunch 1 1 -p abcd -u
So to ensure the output is as expected, the -p switch MUST always be the last option, and the correct syntax
with the above example would be ;
Using the -q switch, you can create all possible permutations of words in a text file ;
(as always, beware of the possible size ! This best done on a ‘focussed’ wordlist)
As an example, create a small text file with 3 lines and then run crunch over it with the -q option;
RESUMING WORDLIST CREATION AFTER CANCELLATION
crunch allows a wordlist creation to be stopped and restarted, to do this we use the -r (resume) switch.
For this to work we must type the exact same line followed with the -r switch ;
Stop the creation with a Ctrl C, then restart with ;
If the wordlist was started from a specific position (see below chapter) then
when resuming the -s switch as well as input must be removed ;
When using this method, the notification on %% complete will not be accurate.
Also, when resuming, crunch will advise that it is generating xx amount of data and xx number of lines.
This information will not be correct as the calculation process thinks it is resuming from a creation of an entire wordlist, whereas it is of course resuming from a wordlist with a certain startblock.
The below picture probably explains it better..
After cancelling with a Ctrl C, resume would then be done with ;
./crunch 8 8 0123456789 -o test.txt -r
If we want to start crunch from a specific position in the wordlist we want to create, we can use the -s
switch to use a specific startblock as starting position for the wordlist.
For instance, if you started creating a wordlist, but had to cancel and resume on a different disk or HDD space ran out.
The temporary file that crunch uses for the wordlist creation is «START» located in the crunch directory
You can check this temporary file for the last couple of entries to allow you to move/rename the temp file START
and restart the wordlist creation without losing the work already done.
> Ctrl + C stopping the wordlist creation,
> check the last couple of entries in the START temporary file ;
> copy or rename the temporary file to a name of your liking;
> restart the wordlist creation from the last noted entry in the temporary file;
NOTE! crunch will overwrite START when it starts a new wordlist creation process, so be sure to rename START into whatever you want to ensure you don’t lose the work already done !
Of course using the starting block can be used for whatever reason, for instance if you are sure that you don’t need any list with numbers starting before 59999999 ;
This is where crunch really shines, and in my humble opinion, the most powerful capability that crunch has to offer.
With a minimum amount of information on known or expected patterns and/or possible characters in the passphrase, custom patterns can be created allowing to specify what to place where in the created passhprases.
In doing so the size of the wordlist can be reduced significantly and the wordlist can be tailored to the target in a much more efficient way, which is always to be endeavoured !
To fix a pattern, we use the -t switch in crunch.
There are fixed symbols used for certain character sets ;
@ –> Lower case alpha values (or @ will read and print from a specified character set, see further down in post)
, –> Upper case alpha values
% –> Numeric values
^ –> Special characters including ‘space’
So if we want to create a 6 character, lower alpha wordlist and with a pre-fix of ‘dog’;
or if we want ‘dog’ to be appended ;
or have ‘dog’ bang in the middle ;
Or ‘dog’ followed by an upper case alpha, number and symbol;
We can also combine the various fixed character sets, for instance, if we want to create an 8 character
wordlist with alpha, numeric and special characters in fixed positions;
Using the fixed character sets you can quickly and easily make ‘quick’ wordlists for a single character set..
Creating a wordlist with only lower case;
./crunch 4 4 -t @@@@
./crunch 4 4 -t %%%%
or only uppercase;
./crunch 4 4 -t ,,,,
only special characters;
And of course if certain positions and characters are known, it can all be mixed up ;
./crunch 9 9 -t %%DOG^^@@
We can also even go a step further and specify which range of characters should be used for each character type.
In the below example ;
lower alpha values to only be ; abcdef
upper alpha values to only be ; ABCDEF
numeric values to only be ; 12345
special characters to only be ; @#$%
We can then specify same by entering these values manually in the command line ;
lower alpha — upper alpha — numeric — special characters
If there is no specific character range to be used for the character set, then that position should be
completed with a ‘+’ placeholder sign which signifies the usage of the complete standard character set for that set positon. (lower alpha — upper alpha — numeric — special characters)
The below example is using ‘abcdef’ as lower alpha charset, the full upper case charset, ‘12345’as numeric charset and the full special character charset.
Although in the above examples @ is used as fixed character set for lower case values, we can also use it to specify a manually chosen single set of all types of characters ;
Remember that certain characters on some occasion require escaping, if in doubt, better to just do it.
If you want to include a space in the charset, then enclose the charset in quotes ;
(space at end of charset below)
Creating telephone lists
You can also use the -t switch to easily make lists of telephone numbers, so if for instance the telephone number
is usually noted as for instance; 0131-321654, then you could easily create a wordlist of telephone numbers following that same example ;
Or if the layout is different, for instance including a space such as «(01201) 111111» this is achieved by putting quotes on the -t pattern as follows (this to ensure that the space is included);
Endless variations are possible.
The possiblities crunch offers to create patterns with such detail give you many options to really fine-tune what you want placed where in your passphrase wordlist and thus reduce the size of your final wordlist.
When you start manually defining what to place where with special characters, you will on some occasions need to to ‘escape’ characters to allow crunch to read them correctly.
This is the case for for instance an exclamation mark ! ;
will result in an error.
In order to make it work correctly you must ‘escape’ the exclamation mark ;
As some special characters are used to define character sets, this can cause some limitations when trying to fix positions of certain special characters. Such as wanting to use @ as a fixed character ;
./crunch 4 4 -t 012@
./crunch 4 4 -t 012\@
This will not fix the character ‘@’ but use it to provide lower case alpha values.
To remedy this to some extent, since crunch v3.0, the new -l switch can be used to fix the literal character instead of having it refer to a place holder for a specific character set.
This would now be accomplished by doing ;
Also, more than 1 placeholder character can be fixed as a literal character;
Of course this in itself also has limitations as you are not able to to check for all possible lower case alpha
values or passthrough a user defined charset with a fixed setting of the @ character.
The below 2 examples will obviously only return 1 result as all the instances of the @ character will be fixed
as a literal character.
This is an issue that is being looked into and possibly a following update of crunch will have an answer.
Of course there are workarounds for some part; if for instance you wanted a password list to start with «p@ss»
followed by 4 characters of all possible lower case values, you could create a list of 4 characters;
And then use ‘sed’ or ‘awk’ to place the word ‘p@ss’ in front of each line ;
Using sed ;
Using awk ;
So with a bit of imagination and a couple of oneliners with sed or awk, you should still
be able to create more or less what you want.
bofh28 has informed me of another workaround which can be used.
You can override the standard characters per placeholder setting by entering a different type of
charset in a different position and then using the placeholder character for that position.
Normally the 3rd position is for numeric values, however if you specify lower case values, it will use these
characters, however you then do need to use the place holder for that position, in this example %.
Confused ? You won’t be after this episode of .. ;)
./crunch 8 8 + + abcdefghijklmnopqrstuvwxyz + -t p@ss%%%% -l @
Crunch can be used to pipe passwords through to programs such as aircrack / pyrit / cowpatty etc.
Considering that crunch is now advising the estimated size of wordlists to be created following the command given as well as the wordcount, to have a seamless integration with piping, it is recommended to use the -u option to supress that information on size, wordcount etc.;
Without using the -u command, it is possible that unexpected errors occur with some programs.
Using the -u option will result in the creating of the wordlist directly instead of giving the 3 second delay during which the estimated wordlist size and wordcount is shown ;
In examples only testing for 8 character numeric passwords ;
./crunch 8 8 -t %%%%%%%% -u | aircrack-ng -e SSID -w – /pathto/capfile.cap
./crunch 8 8 -t %%%%%%%% -u | cowpatty -f – -r /pathto/capfile.cap -s SSID
./crunch 8 8 -t %%%%%%%% -u | pyrit -i – -r /pathto/capfile.cap -e ESSID attack_passthrough
Output files can be compressed with crunch using the -z switch.
Supported formats are;
Crunch will first create the wordlist and will then compress the wordlist.
Upon the finalisation of the wordlist creation, you will see the 100% being reached
and the 100% denomination will continue to be printed until the compression is complete.
So if you see a continuous ‘stream’ of 100%, don’t worry, the program is not hanging,
the output file is simply being compressed.
It had me guessing when I was testing a compression of a couple of gigabytes.. but I assure you it is the case.
The best level of compression and thus the slowest is obtained with lzma.
The quickest compression, with the lowest level of compression, is obtained with gzip.
To unzip the created file ;
To decompress the created file ;
To decompress the created file ;