> For the complete documentation index, see [llms.txt](https://riteshs4hu.gitbook.io/infosec-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://riteshs4hu.gitbook.io/infosec-notes/internal-and-external-network-sec/password-cracking/hash-cracking.md).

# Hash Cracking

A **hash** is a one-way cryptographic function that converts input data (such as passwords) into a fixed-length string. Hashing stores passwords securely, verifies data integrity, and more.

#### Hashes are mainly classified into two categories:

### **Reversible Hashing (Encoding)**

Reversible encoding methods are not true hashing algorithms. They transform data in a way that can be easily reversed.

* **Base64** – Encodes binary data into ASCII text; can be decoded easily.
* **ROT13** – A simple letter substitution cipher (shifts letters by 13 places); can be reversed.

### **Irreversible Hashing (E**ncryptio&#x6E;**)**

These are cryptographic hash functions, meaning the original data cannot be directly recovered from the hash. However, they can be cracked using different methods.

* **MD5** – 128-bit hash; fast but insecure (collisions possible).
* **SHA1** – 160-bit hash; more secure than MD5 but still vulnerable to collisions.
* **SHA512** – 512-bit hash; stronger but still crackable with enough computing power.

***

### **Ways to Crack Password Hashes**

There are several methods used to crack password hashes:

#### **1. Brute Force Attack**

* Tries every possible combination of characters until the correct hash match is found.
* Time-consuming, but guarantees a result if given enough time.
* Tools: `John the Ripper`, `Hashcat`

#### **2. Wordlist Attack**

* Uses a precompiled list of common passwords (like RockYou).
* Faster than brute force if the password is weak.
* Example wordlist: `rockyou.txt`
* Tools: `Hashcat`, `John the Ripper`

#### **3. Rainbow Table Attack**

* Precomputed hash values are stored in a table to speed up cracking.
* If a hash exists in the table, it can be cracked instantly.
* Example: Searching Google for a hash often leads to websites with precomputed hashes.
* Tools: `Rainbow Crack`

#### **4. Rule-Based Attack**

* Uses smart rules to modify wordlists (like adding numbers or special characters).
* Example: `Password123!` → `Password!123`
* Good for cracking slightly modified common passwords.
* Tools: `Hashcat`, `John the Ripper` with rule-based options.

***

### **Tools for Identifying Hashes**

Before cracking a hash, you need to identify its type.

#### **Hash Identification Tool**

* **`hashid`** – Detects hash types based on their characteristics.
* **`hash-identifier`** – Alternative tool for identifying hash types.

***

### **Hash Cracking and Analysis** Resources:

1. [**Hashes.com**](https://hashes.com/en/decrypt/hash)
2. [**CrackStation**](https://crackstation.net/)
3. [**CyberChef**](https://gchq.github.io/CyberChef/)

***

### **Wordlist Generator Tools**

#### **Crunch**

* **Command-line tool** to generate wordlists based on specified parameters (length, character set, patterns).
* Example: Generate a wordlist with passwords of length 6 to 8 using only lowercase letters:

  ```bash
  crunch 6 8 abcdefghijklmnopqrstuvwxyz -o wordlist.txt
  ```

#### **Cewl**

* A **custom wordlist generator** that scrapes words from a target website.
* Example: Generate a wordlist from `example.com` and save it:

  ```bash
  cewl -w wordlist.txt https://example.com
  ```
