Crunch is an extremely useful tool for penetration testers. In essence, it is a powerful word list generator that can generate various word sets required by users, sometimes even up to terabyte level. The potential of this tool is endless, giving you the flexibility to generate the content you need. In this tutorial, we will learn in depth the functions and usage of Crunch.
On Kali Linux or Parrot OS, crunch is pre-installed. But this is not the case on Ubuntu. So it's up to us to install it.
Install it using the following command:
sudo apt—get install crunch
Now that we have Crash, let's start using it.
Basically, you have to follow the given syntax to use crunch:
Cash[][options]
Options and strings are not required, but min-len (minimum length) and max-len (maximum length) are indeed required. min_len and max_len are required even if you don't plan to use it. Therefore, it must always be available. Essentially, there are some cases where you don't need a minimum or maximum length, but even in those cases you have to provide arbitrary values for min_len and max_len to facilitate manipulation.
Let’s start with a simple example:
Crunching 0 1 AA
What just happened?
Crunch first lets you know the size of the file (5 bytes) and the number of lines (3). The four lines following the file size also specify the file size in MB, GB, TB, and PB. Then, it starts generating possible combinations. Here, since we are talking about the maximum number of characters is 1, the line will contain at most 1 character. The character to use is either an uppercase letter A or a lowercase letter A. So, that's what it does: A or A. In this case, the number of possible combinations is 3. This is because 0 or the empty string is also an option.
Now, please note that from here on we will not be able to display the full screen containing the list because it is very long (even the simplest one). But we'll make sure to show you the first part and let you know what the final character combination is.
Let us give another example:
December 13, 2011
This one starts with 1 and ends with 333. Why? This is because the minimum number of characters is 1. This means 1, 2 and 3, then a 2 character combination (11, 12, 13,…,33) and finally a 3 character combination (111,123,113,…333).
Now, you don't have to use your own character set all the time. Crunch comes with a built-in character set called "charset.lst". This list is located in "/usr/share/crunch/charset.lst".
Note that in real life, when creating a real dictionary, you are more likely to use "charset.lst". For example, when using "aircrack_ng", please note that you will often use "upper_hex" files to create dictionary files.
crunch 2 3—f/usr/share/crunch/charset. lst hex—upper
crunch 1 2 ABC—o wordlist.txt
Here, what we want to do is save it to an output file called "wordlist.txt".
The next one is more advanced.
Now, let's say you want some characters in your word list to remain unchanged. Let's say we want this:
—CAT
In the given code, hyphens represent characters. So, we have three random characters followed by the word CAT.
We write the following:
Crunching 6 6 ABC-t@猫
The "@" here indicates the position where the characters will be combined. The character that will replace "@" is a, b, or c.
Here, since the length of the word we generate is at least 6 characters, we write 6, 6. This means that crunch will generate a word that is exactly 6 characters long. It starts with aaaCAT and ends with cccCAT.
Now, let's say we want it to start with bbbcat. We write the following command:
Crunching 6 6 abc-t@cat-S bbCAT
As you can see, the word list starts with bbbCAT and ends with cccCAT.
Please note the following:
@—It inserts lowercase characters.
, - it inserts uppercase characters.
%—It inserts numbers.
^—It inserts the symbol.
Let’s look at an example of each given code:
crunch 7 7—t @^%,CAT—c 6
The "c" hyphen is used to set a limit on the number of lines. So instead of showing too many lines, we limit it to around 6 lines.
crunch 4 4 ab CD 12 $%—t @,%^
Here, make sure to leave enough space between symbols and hyphens. If you put it too close together, it will fall apart.
The next one is a little trickier.
Now, remember we said that you must enter a minimum and maximum number of characters. Even if it doesn't work, you have to do it. This means that you can enter minimum and maximum characters even without using these numbers.
crunch 4 5—p loves linux code
crunch 20 24—q version/Downloads/wordlist.txt
Here, "q" does the same thing as "p", but it's extracted from a file instead of writing out words in the terminal.
Overall, Crunch is a great dictionary file generator. It definitely requires you to enter a minimum and maximum number of characters, but everything else is malleable. You can create a word list containing your favorite patterns or files of your choice. But keep in mind that the longer the file, the longer it will take to generate the list. In order to generate a good dictionary file, you not only need time, but also a good external hard drive to save the file. Although the files in the example are small, the actual generated files are very large.
Happy coding!
The above is the detailed content of Crash for Linux. For more information, please follow other related articles on the PHP Chinese website!