Beginners guide to crunch tool
In Previous articles we have used a word Bruteforce attack that is carried out with the help of a dictionary or we can say a list of common user names and passwords.
You can find list of usernames and passwords in /usr/share/wordlists directory but have you ever wondered can we create our own list? Yes in this article we are going to create our own list of username and password using a tool “crunch”
Table of Contents :
Introduction
Syntax of crunch
Using default character set
Set our own character set
Generate alpha numeric list
Generate list having space(““)
List with specified patterns
Using Permutation
Applying limit to generate small list
generate compressed wordlist
Introduction
As of now I haven’t encountered any CTF challenge where the dictionary that are present in kali Linux OS doesn’t work.But there can be a situation where we need a custom dictionary to find the correct login password For Ex. After doing a lot of Social Engineering we find out that a person’s social account can be something like this : hello,social,country,wifi,kite(may be the person loves kite) or it can be the person’s favourite food etc...So here we need to create our own list. That’s the reason we should know crunch.
Syntax of crunch
To check the syntax of crunch we issue the command:
crunch -h

In the above image we can see the syntax.Now in the next step we will use this syntax to generate a wordlist
Using default character set
Execute the command "crunch 2 3 -o /root/Desktop/haclabs"to generate a wordlist with default character set.
here 2 is the min. length and 3 is the max. length and -o specify the location to save the wordlist.

Now we will use cat command to display the content of the file . As the file is too large in no. of lines that's why we have used head -n 20 ,it will display first 20 lines of the file

Set our own character set
Now execute given below command which will generate a dictionary that contains minimum 3 character letters and maximum 5 by using “hac” as the specified string.
crunch 3 5 hac -o /root/Desktop/haclabs1

Now with the help of cat command we can see the content of the file "haclabs1"
"tail" is used to display the last 10 lines of the file

Similarly here we have used head to display first 20 lines of the file

Generate alpha numeric list
You can generate your own alpha-numeric wordlist, execute given below command which will generate a dictionary that contains minimum 3 character letters and maximum 5 by using “hac01” as the specified string.
crunch 3 5 hac01 -o /root/Desktop/haclabs2

Again we had used the cat to display the content of the file "haclabs2"


Generate list having space("")
The following command will generate wordlist using escape sequence character (\) with string “yash”. Instead of using (\) you can also use double quotes around string as “yash ” along with space within double quotes.
crunch 1 3 yash\ -o /root/Desktop/haclabs3

using cat to display the content of the file "haclabs3"

Generate List with specified patterns
crunch has a "-t" command option that let us to create the wordlist according to the pattern we need.Execute the command as show in the image below
NOTE: Here min and max will be same,otherwise it will generate error.
crunch 4 4 -t hac% -o /root/Desktop/haclabs4
-t specifies the pattern.

Use @ for lowercase alphabets
Use , for uppercase alphabets
Use % for numeric character
Use ^ for special character symbol

Using Permutation
use -p command option to create a wordlist with the help of permutation as show below
crunch 2 5 -p hac labs founder

here we can ignore min and max length of the character string
from the above image we can see the output of the command.
Applying limit to generate small list
if you will observe above all output result then you will find crunch has generated dictionary and displays the number of the line for each dictionary.for ex haclabs file has "18252" lines so to limit this we use "-c" command options long with the crunch.
crunch 4 4 hac -c 20 -o /root/Desktop/haclabs6

generate compressed wordlist
Crunch let you generate compress wordlist with –z command option and other parameters are gzip, bzip2, lzma, and 7z, execute given below command for compression.

So this is a basic introduction to crunch tool.