The short answer
- A rule is a short instruction that changes each wordlist entry: capitalize it, append digits, reverse it.
- Rules multiply your candidates without a bigger wordlist, which is why a dictionary attack with rules beats a plain wordlist.
- Apply a rule file with
-r:hashcat -a 0 -m 0 -r rules.txt hash.txt wordlist.txt. - Start with the rule files shipped with Hashcat, such as
best64.rule, then write your own.
Introduction
Hashcat is a powerful password tool that uses various techniques to test passwords, including brute-force attacks, combinator attacks, and dictionary attacks.
In this article, we will focus on how Hashcat applies rules to wordlists to enhance the password testing process.
What Are Hashcat Rules?
Rules in Hashcat are essentially instructions that modify words from a given wordlist. These modifications help generate different password variations, such as changing capitalization, appending numbers, or reversing the word, thereby increasing the chances of recovering a password.
Rules are applied one at a time or in combination, allowing Hashcat to expand the number of password candidates beyond the entries in the wordlist. The flexibility and efficiency of rules make them an essential feature when performing dictionary-based attacks.
How Hashcat Applies Rules to Wordlists
When you run Hashcat with a wordlist and rules, Hashcat processes each word in the wordlist according to the defined rules, creating variations of that word. Each modified word is then checked against the hash you're trying to crack.
For example, let's assume your wordlist contains the word password. Hashcat can use rules to modify this word in various ways:
- Reverse it:
drowssap - Capitalize the first letter:
Password - Append numbers:
password123 - Append symbols:
pass-word? - Change characters:
p@ssw0rd
Each of these transformations increases the likelihood of matching a complex password in real-world scenarios.
Common Hashcat Rule Notations
Hashcat uses a specific syntax for rules. Below are some of the most common rule operations and their notations:
- Append character:
$1appends the number1to the word. - Prepend character:
^pprepends the letterpto the word. - Toggle case:
t0toggles the case of the first character. - Reverse:
rreverses the word. - Duplicate first character:
fduplicates the first character of the word.
These rules can be combined, creating complex transformations of words. For example, the rule $1 ^p r would modify the word "password" as follows:
- Append 1:
password1 - Prepend "p":
ppassword1 - Reverse the word:
1drowssapp
Example: Using Rules with a Wordlist
Let’s walk through a basic example where we apply a rule to a wordlist.
Assume you have a wordlist file wordlist.txt that contains the following words:
password admin welcome
We want to apply a rule that toggles the case of the first letter and appends the number 123 to each word. We use the rule file rules.txt:
t0 $123
This rule will:
t0: Toggle the case of the first character.$123: Append the numbers123.
To apply this rule in Hashcat, use the following command:
hashcat -a 0 -m 0 -r rules.txt hash.txt wordlist.txt
The resulting transformations of the wordlist would be:
Password123
Admin123
Welcome123
Hashcat will now attempt to test the hash by using these modified words as potential passwords.
Tips for Using Hashcat Rules Effectively
- Start with common rules: Hashcat provides pre-built rule files, such as
rules/best64.ruleandrules/d3ad0ne.rule, which are good starting points. - Combine rules: You can create custom rule files that combine different rules to generate more variations.
- Use efficient wordlists: The effectiveness of rules depends on the quality of your wordlist. Ensure your wordlist contains common passwords or words related to the target you are trying to crack.
- We provide a selection of top-tier rule lists, curated based on our expertise, to help you choose the most effective rules tailored to your specific case and needs.
Skip the setupOHC runs curated wordlists and rule sets on cloud GPUs. Submit a hash and the right attack is chosen for you.
Hashcat rules: frequently asked questions
What are Hashcat rules?
Rules are instructions that transform each word of a wordlist before it is tested, for example capitalizing the first letter, appending a number or reversing the word. They expand the number of candidates well beyond the wordlist itself.
How do I use a rule file with a wordlist?
Pass it with the -r option in a dictionary attack: hashcat -a 0 -m <mode> -r rules.txt hash.txt wordlist.txt. Each wordlist entry is tested once per rule in the file.
Which rule files should I start with?
The rules directory shipped with Hashcat includes best64.rule and d3ad0ne.rule, which are good general-purpose starting points.
Can I combine several rules on one line?
Yes. Functions on the same line run in order, so one line can capitalize a word, append digits and reverse it in a single candidate.
Do rules replace a good wordlist?
No. Rules only transform what the wordlist already contains, so a list of common passwords and target-related words still matters most.
Further reading
Related guides on Online Hash Crack:
External references: