Try all combinations from a given keyspace just like in Brute-Force attack, but more specific.
The reason for doing this and not to stick to the traditional Brute-Force is that we want to reduce the password candidate keyspace to a more efficient one.
Here is a single example. We want to crack the password: Julia1984
In traditional Brute-Force attack we require a charset that contains all upper-case letters, all lower-case letters and all digits (aka “mixalpha-numeric”). The Password length is 9, so we have to iterate through 62^9 (13.537.086.546.263.552) combinations. Lets say we crack with a rate of 100M/s, this requires more than 4 years to complete.
In Mask attack we know about humans and how they design passwords. The above password matches a simple but common pattern. A name and year appended to it. We can also configure the attack to try the upper-case letters only on the first position. It is very uncommon to see an upper-case letter only in the second or the third position. To make it short, with Mask attack we can reduce the keyspace to 52*26*26*26*26*10*10*10*10 (237.627.520.000) combinations. With the same cracking rate of 100M/s, this requires just 40 minutes to complete.
There is none. One can argue that the above example is very specific but this does not matter. Even in mask attack we can configure our mask to use exactly the same keyspace as the Brute-Force attack does. The thing is just that this cannot work vice versa.
Note that masks are split into two parts internally to give hashcat something to work as an amplifier to overcome PCI-E bottleneck.
For each position of the generated password candidates we need to configure a placeholder. If a password we want to crack has the length 8, our mask must consist of 8 placeholders.
Optimized due its partially reverse algorithms, password candidates are generated in the following order:
aaaaaaaa aaaabaaa aaaacaaa . . . aaaaxzzz aaaayzzz aaaazzzz baaaaaaa baaabaaa baaacaaa . . . baaaxzzz baaayzzz baaazzzz . . . zzzzzzzz
NOTE: This shows that the first four letters are increased first and most often. The exact number however can vary, especially in a smaller keyspace, but it is fixed until a keyspace has been scanned completly.
All hashcat derivates have four commandline-parameters to configure four custom charsets.
--custom-charset1=CS --custom-charset2=CS --custom-charset3=CS --custom-charset4=CS
These commandline-parameters have four analogue shortcuts called -1, -2, -3 and -4. You can specify the chars directly on the command line or use a so-called hashcat charset file (plain text file with .hcchr extension which contains the chars/digits to be used on the 1st line of the file). See examples below:
The following commands all define the same custom charset that consists of the chars “abcdefghijklmnopqrstuvwxyz0123456789” (aka “lalpha-numeric”):
-1 abcdefghijklmnopqrstuvwxyz0123456789 -1 abcdefghijklmnopqrstuvwxyz?d -1 ?l0123456789 -1 ?l?d -1 loweralpha_numeric.hcchr # file that contains all digits + chars (abcdefghijklmnopqrstuvwxyz0123456789)
The following command defines a charset that consists of the chars “0123456789abcdef”:
The following command defines a full 7-bit ascii charset (aka “mixalpha-numeric-all-space”):
The following command sets the first custom charset (-1) to russian language specific chars:
The following commands creates the following password candidates:
command: -a 3 ?l?l?l?l?l?l?l?l keyspace: aaaaaaaa - zzzzzzzz
command: -a 3 -1 ?l?d ?1?1?1?1?1 keyspace: aaaaa - 99999
command: -a 3 password?d keyspace: password0 - password9
command: -a 3 -1 ?l?u ?1?l?l?l?l?l19?d?d keyspace: aaaaaa1900 - Zzzzzz1999
command: -a 3 -1 ?dabcdef -2 ?l?u ?1?1?2?2?2?2?2 keyspace: 00aaaaa - ffZZZZZ
command: -a 3 -1 efghijklmnop ?1?1?1 keyspace: eee - ppp
A Mask attack is always specific to a password length. For example, if we use the mask “?l?l?l?l?l?l?l?l” we can only crack a password of the length 8. But if the password we try to crack has the length 7 we will not find it. Thats why we have to repeat the attack several times, each time with one placeholder added to the mask. This is transparently automated by using the “--increment” flag (Attention: the mask length itself is the limiting factor for hashcat. That implies that if i.e. the mask is only of length 4 --increment won't increment the length of the password candidates above 4. A mask of length, therefore, won't increase at all even if --increment was specified).
?l ?l?l ?l?l?l ?l?l?l?l ?l?l?l?l?l ?l?l?l?l?l?l ?l?l?l?l?l?l?l ?l?l?l?l?l?l?l?l
Hashcat charsets files (file extension: .hcchr) are a convenient way to reuse charsets, define custom charsets and use the language-specific charsets shipped by hashcat.
These files can be used together with the --custom-charsetN= (or -1, -2, -3 and -4) parameter. Instead of providing all the charset directly on command line, the support for .hcchr files allows one to specify the path to the file:
It is important that .hcchr files are created with language specific file encodings (e.g. cp1252, ISO-8859-15 etc). For examples of content and encoding of .hcchr files, see the examples shipped with hashcat (e.g. [HASHCATROOT]/charsets/standard/Italian/).
Hint: use iconv and similar tools to convert the files to a language specific file encoding (if for instance created as UTF-8 file).
Hashcat mask files (file extension: .hcmask) are files which contain custom charsets (optional) and masks (e.g. ?1?1?1?1?d?d) line-by-line. The advantage of using .hcmask files, which are plain text files, is that those files allow the hashcat user to have a set of predefined and well-working masks stored within a file (or several e.g. password policy specific files) where the lines contained in the hcmask file could for instance be sorted by increasing runtime and/or likelihood of matches*.
The general format of 1 single line in the .hcmask file is as follows:
where the placeholders are as follows:
* see the PACK program and some example hcmask files shipped by hashcat (in the masks/ folder).
You supply the .hcmask file just where you would normally place the single mask on the command line. Like this:
-a 3 hash.txt mask_file.hcmask
Other not so important syntax available in .hcmask files:
- with # you can comment a line (it won't be used), with \# you can use a # at the beginning of the line (either within the custom charsets or, if no custom charset is used, within the mask)
- \, means that the comma should be used literally (not a separator between ?1, ?2, ?3, ?4 or mask)
- ?? within the mask or custom charsets means that the question mark should be used as a literal character (otherwise if only a single question mark was used it would be interpreted as the beginning of a reference to a custom charset or built-in charset)
Notes: .hcmask files can be used together with -i (increment) parameter for brute-force mode. It is not allowed that a [mask] contains ?1,?2,?3 or ?4 references without those being set via [?1], [?2], [?3], [?4]. This will result in an error message. If you want to use a custom charset for your masks you must define it within the same line of the hcmask file by using the [?1], [?2], [?3], [?4] fields.
If for instance [?2] was not set because not needed, the comma that would be normally following [?2] must also be omitted. See examples below:
The following .hcmask file contains some valid example lines which show how to use this feature:
?d?l,test?1?1?1 abcdef,0123,ABC,789,?3?3?3?1?1?1?1?2?2?4?4?4?4 company?d?d?d?d?d ?l?l?l?l?d?d?d?d?d?d ?u?l,?s?d,?1?a?a?a?a?2
Note: also see FAQ: What is a hashcat mask file?
This can be done by some of the hashcat tools using the “--hex-charset” flag.