tar -xvf crunch-3.0.tgz
cd crunch3.0/
make && make install
Edit 12-06-2011
crunch is now available in the BT repositories,
so can download and install on backtrack5 simply by doing a ;
apt-get update
apt-get install crunch
BASIC USAGE AND CHARACTER SETS
The default installation directory / path for crunch in backtrack 5 is
/pentest/passwords/crunch/
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;
/pentest/passwords/crunch/crunch 8 8 abc + + \!\@\# -t TEST^%,@ -o test.txt
Basic usage is as follows to print to screen
./crunch [min length] [max length] [character set] [options]
To write to file use the -o switch ;
./crunch [min length] [max length] [character set] [options] -o filename.txt
If no character set is defined, then crunch will default to using the lower case alpha character set;
./crunch 4 4
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 \ ;
./crunch 6 6 ABC\!\@\#\$
CREATING WORDLISTS IN BLOCKS OF A CERTAIN SIZE
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;
./crunch 6 6 0123456789 -b 1mb -o START
To create a wordlist split in files of no more than 100mb;
./crunch 8 8 abcDEF123 -b 100mb -o START
To create a wordlist split into files of no more that 10kb;
./crunch 4 4 0123456789 -b 10kb -o START
To create a wordlist split into files of no more than 2gb;
./crunch 8 8 0123456789ABCDEF -b 2gb -o START
etc.
etc.
CREATING WORDLISTS IN BLOCKS OF A CERTAIN LINECOUNT
(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);
./crunch 6 6 abcDEF123 -c 150000 -o START
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
USING FIXED CHARACTER SETS
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;
./crunch 6 6 -f charset.lst ualpha
To use only numeric characters ;
./crunch 6 6 -f charset.lst numeric
To use hexidecimal characters (with uppercase alpha values) ;
./crunch 8 8 -f charset.lst hex-upper
To use lower case, uppercase, numeric & special characters (beware of the size ! Don’t try to save..lol..) ;
./crunch 8 8 -f charset.lst mixalpha-numeric-all-space
etc.
etc.
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.
INVERTING THE OUTPUT DIRECTION
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.
./crunch 4 4 -i
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 ;
./crunch 8 8 0123456789 -i
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 4 4 zyxwvutsrqponmlkjihgfedcba
./crunch 4 4 ZYXWVUTSRQPONMLKJIHGFEDCBA
./crunch 8 8 9876543210
CREATING PERMUTATIONS
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) ;
./crunch 1 1 -p abcd
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 ;
./crunch 1 1 -u -p abcd
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;
echo “bird” > test.txt && echo “cat” >> test.txt && echo “dog” >> test.txt
./crunch 1 1 -q test.txt
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 ;
./crunch 8 8 0123456789 -o test.txt
Stop the creation with a Ctrl C, then restart with ;
./crunch 8 8 0123456789 -o test.txt -r
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..
./crunch 8 8 0123456789 -s 59999999 -o test.txt
After cancelling with a Ctrl C, resume would then be done with ;
./crunch 8 8 0123456789 -o test.txt -r
STARTING FROM A SPECIFIC POSITION
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
/pentest/passwords/crunch/
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.
example ;
./crunch 7 7 0123456789 -o test.txt
> Ctrl + C stopping the wordlist creation,
> check the last couple of entries in the START temporary file ;
tail -n 2 START
> copy or rename the temporary file to a name of your liking;
cp START file1.txt
> restart the wordlist creation from the last noted entry in the temporary file;
./crunch 7 7 0123456789 -s 9670549 -o test.txt
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 ;
./crunch 8 8 0123456789 -s 59999999 -o test.txt
CREATING CUSTOM PATTERNS
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’;
./crunch 6 6 -t dog@@@
or if we want ‘dog’ to be appended ;
./crunch 6 6 -t @@@dog
or have ‘dog’ bang in the middle ;
./crunch 7 7 -t @@dog@@
Or ‘dog’ followed by an upper case alpha, number and symbol;
./crunch 6 6 -t dog,%^
Miscellaneous patterns
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;
./crunch 8 8 -t ,,^^@@%%
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 @@@@
only numeric;
./crunch 4 4 -t %%%%
or only uppercase;
./crunch 4 4 -t ,,,,
only special characters;
./crunch 4 4 -t ^^^^
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 ;
Note that it is required to enter the custom values in the order ;
lower alpha — upper alpha — numeric — special characters
./crunch 8 8 abcdef ABCDEF 12345 @#$%- -t @@,,%%^^
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.
./crunch 8 8 abcdef + 12345 + -t @@,,%%^^
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 ;
./crunch 8 8 123abcDEF -t TEST@@@@
./crunch 10 10 123abc+-= -t @@@test@@@
Remember that certain characters on some occasion require escaping, if in doubt, better to just do it.
./crunch 10 10 123abcDEF\!\@\# -t TESTING@@@
If you want to include a space in the charset, then enclose the charset in quotes ;
(space at end of charset below)
./crunch “123abcDEF ” -t TEST@@@@
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 ;
./crunch 11 11 -t 0131-%%%%%%
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);
./crunch 14 14 -t “(01201) %%%%%%”
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.
ESCAPING / FIXING SPECIAL CHARACTERS FOR USE IN PATTERNS
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 ! ;
./crunch 4 4 -t 12!@
will result in an error.
In order to make it work correctly you must ‘escape’ the exclamation mark ;
./crunch 4 4 -t 12\!@
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@
or
./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 ;
./crunch 6 6 -t b@d%%% -l @
Other possibilities;
./crunch 8 8 -t P@SS%%%% -l @
./crunch 8 8 -t P@\$\$,,,, -l @
etc. etc.
./crunch 8 8 -f charset.lst mixalpha -t pass^^@@ -l ^
Also, more than 1 placeholder character can be fixed as a literal character;
./crunch 8 8 -f charset.lst mixalpha -t pass@,%^ -l %^
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.
./crunch 8 8 -t p@ss@@@@ -l @
./crunch 8 8 -f charset.lst mixalpha-numeric -t p@ss@@@@ -l @
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;
./crunch 4 4 -o test.txt
And then use ‘sed’ or ‘awk’ to place the word ‘p@ss’ in front of each line ;
Using sed ;
sed ‘s/^/p\@ss/’ test.txt > file1.txt
Using awk ;
awk ‘{print “p@ss” $0}’ test.txt > file1.txt
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.
edit 25-05-2011
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 @
PIPING CRUNCH THROUGH TO OTHER PROGRAMS
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 ;
aircrack
./crunch 8 8 -t %%%%%%%% -u | aircrack-ng -e SSID -w – /pathto/capfile.cap
cowpatty
./crunch 8 8 -t %%%%%%%% -u | cowpatty -f – -r /pathto/capfile.cap -s SSID
pyrit
./crunch 8 8 -t %%%%%%%% -u | pyrit -i – -r /pathto/capfile.cap -e ESSID attack_passthrough
COMPRESSING OUTPUT FILES
Output files can be compressed with crunch using the -z switch.
Supported formats are;
> gzip
> bzip
> lzma
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.
./crunch 6 6 -f charset.lst lalpha -o test.txt -z gzip
To unzip the created file ;
gunzip test.txt.gz
./crunch 6 6 -f charset.lst lalpha -o test.txt -z bzip2
To decompress the created file ;
bunzip2 test.txt.bz2
./crunch 6 6 -f charset.lst lalpha -o test.txt -z lzma
To decompress the created file ;
unlzma test.txt.lzma