Offline - Password Cracking

MITRE ATT&CK™ Brute Force: Password Cracking - Technique T1110.002

Theory

When obtaining hashed passwords, we must run various plaintext passwords through the hashing algorithm and compare the returned hash to the target hash. This password attack technique is known as password cracking.

Cracking hashes is usually done on attacker-controlled systems outside of the target network, as this technique does not require direct interaction with the target.

Practice

Note that John is mainly a CPU-based cracking tool that also supports GPUs, while Hashcat is mainly a GPU-based cracking tool that also supports CPUs.

Finding Hashcat Mode

Hashcat offers different modes that you can use to crack a specific algorithm. When you crack a hash with hashcat, the first step is to find the right mode.

To do this, we can use the -h or --example-hashes arguments. Alternatively we may refers to the example_hash online resource.

HashId & Help

We may use hashid against a hash to do identify the hash type

$ hashid '$S$C33783772bRXEx1aCsvY.dqgaaSu76XmVlKrW9Qu8IQlvxHlmzLf'
Analyzing '$S$C33783772bRXEx1aCsvY.dqgaaSu76XmVlKrW9Qu8IQlvxHlmzLf'
[+] Drupal > v7.x

Then we can use following commands to retrieve that the Hashcat mode is 7900

$ hashcat -h |grep -i 'Drupal'
   7900 | Drupal7  | Forums, CMS, E-Commerce

Example_hashes & Grep

We may directly use the --example-hash argument to find the right mode. Using the previous hash, we can easily find the 7900 mode.

$ hashcat --example-hashes|grep -i '\$S\$' -B 11
Hash mode #7900
  Name................: Drupal7
  Category............: Forums, CMS, E-Commerce
  Slow.Hash...........: Yes
  Password.Len.Min....: 0
  Password.Len.Max....: 256
  Salt.Type...........: Embedded
  Salt.Len.Min........: 0
  Salt.Len.Max........: 256
  Kernel.Type(s)......: pure
  Example.Hash.Format.: plain
  Example.Hash........: $S$C20340258nzjDWpoQthrdNTR02f0pmev0K/5/Nx80WSkOQcPEQRh

Brute-Force Attack

We may perform a brute-force attack against a target hash using Hashcat charsets:

Following commands can be used

Dictionary Attack

We may perform a dictionary attack against a target hash using Hashcat

Rule-Based Attack

Rule-Based attacks assume the attacker knows something about the password policy. Rules are applied to create passwords within the guidelines of the given password policy and should, in theory, only generate valid passwords. Using pre-existing wordlists may be useful when generating passwords that fit a policy — for example, manipulating or 'mangling' a password such as password: p@ssword, Pa$$word, Passw0rd, and so on.

To generate a rule-based wordlists, see this page.

Hashcat has rule sets located at /usr/share/hashcat/rules/. To create your own rules, you may check this hashcat documentation.

Hybrid Attack

We can use hashcat to perform hybrid attacks using both a dictionary and a mask and even rules.

Rainbow Table Attack

Crackstation is a website that can be used for Rainbow Table Attacks.

Resources

Last updated

Was this helpful?