4. Password mutations

Many people create their passwords according to simplicity instead of security

Unfortunately, the tendency for users to create weak passwords also occurs despite the existence of password policies. Most people/employees follow the same rules when creating more complex passwords. Passwords are often created closely related to the service used. This means that many employees often select passwords that can have the company's name in the passwords. A person's preferences and interests also play a significant role. These can be pets, friends, sports, hobbies, and many other elements of life. `OSINT` information gathering can be very helpful for finding out more about a user's preferences and may assist with password guessing. More information about OSINT can be found in the [OSINT: Corporate Recon module](https://academy.hackthebox.com/course/preview/osint-corporate-recon). Commonly, users use the following additions for their password to fit the most common password policies:
Description Password Syntax
First letter is uppercase. Password
Adding numbers. Password123
Adding year. Password2022
Adding month. Password02
Last character is an exclamation mark. Password2022!
Adding special characters. P@ssw0rd2022!

Based on statistics provided by WPengine, most password lengths are not longer than ten characters. So what we can do is to pick specific terms that are at least five characters long and seem to be the most familiar to the users, such as the names of their pets, hobbies, preferences, and other interests.

hashcat

We can use a very powerful tool called Hashcat to combine lists of potential names and labels with specific mutation rules to create custom wordlists. To become more familiar with Hashcat and discover the full potential of this tool, we recommend the module Cracking Passwords with Hashcat.

The complete list of this syntax can be found in the official documentation of Hashcat. However, the ones listed below are enough for us to understand how Hashcat mutates words.

Function Description
: Do nothing.
l Lowercase all letters.
u Uppercase all letters.
c Capitalize the first letter and lowercase others.
sXY Replace all instances of X with Y.
$! Add the exclamation character at the end.

Each rule is written on a new line which determines how the word should be mutated. If we write the functions shown above into a file and consider the aspects mentioned, this file can then look like this: ![](/img/Pasted image 20240803223803.png) Generating a rule-based wordlist:

stejwes@htb[/htb]$ hashcat --force password.list -r custom.rule --stdout | sort -u > mut_password.list
stejwes@htb[/htb]$ cat mut_password.list

Hashcat and John come with pre-built rule lists that we can use for our password generating and cracking purposes. One of the most used rules is best64.rule, which can often lead to good results.

 It is important to note that password cracking and the creation of custom wordlists is a guessing game in most cases  We can narrow this down and perform more targeted guessing if we have information about the password policy and take into account the company name, geographical region, industry, and other topics/words that users may select from to create their passwords. Exceptions are, of course, cases where passwords are leaked and found.

Other hashcat rules can be found:

ls /usr/share/hashcat/rules/

We can now use another tool called CeWL to scan potential words from the company's website and save them in a separate list. We can then combine this list with the desired rules and create a customized password list that has a higher probability of guessing a correct password.

stejwes@htb[/htb]$ cewl https://www.inlanefreight.com -d 4 -m 6 --lowercase -w inlane.wordlist
stejwes@htb[/htb]$ wc -l inlane.wordlist

NOTE TO FUTURE STEPHEN - Hashcat odd behavior

There are demons inside of your computer causing strange shit to happen.

If you run hashcat to generate a password list with a .rule file, you will not get the same results as when you run it locally on kali.

Therefore, to actually crack a password that we were working with, you have to

  1. GENERATE THE WORDLIST FROM KALI USING THE RULELIST
  2. TRANSFER IT BACK TO WINDOWS
  3. USE WINDOWS TO CRACK THE PASSWORD USING THE GENERATED WORDLIST FROM KALI