PMKID Attack
PMKID Attack
Introduction ........................................................................................... 3
Open System Authentication ................................................................. 3
Shared Key Authentication .................................................................... 3
WPA and WPA2 (PSK)............................................................................. 4
4 Way handshake ................................................................................... 5
PMK Caching and PMKID........................................................................ 6
Explanation of PMKID attack ................................................................. 7
Capturing PMKID using hcxdumptool .................................................... 7
Converting pcapng to a hashcat file and cracking using hashcat .......... 9
Capturing only a single PMKID using hcxdumptool ............................. 11
Converting pcapng to pcap and cracking using Aircrack-ng ................ 12
PMKID capture and attack using Airgeddon ........................................ 14
PMKID capture using bettercap ........................................................... 17
Conclusion ............................................................................................ 20
Page 2 of 20
Introduction
PMKID attack was developed by Team Hashcat. Traditional handshake capture and brute force methods
wait for the client to de-authenticate and re-authenticate while PMKID attack doesn’t. Direct PMKID is
captured in this attack and then cracked. This attack works on WPA and WPA2 protocols and recent
studies have shown little to no success in WPA3 and are far more resilient to PMKID attacks. Let’s
understand the basics of Wireless Networks first and then we’d have a better understanding of PMKID.
Figure 1
Consider when you plug an ethernet cable in your desktop and it connects you right away to the network.
It is analogous to WEP for wireless networks. Hence, the name is wired equivalent protocol.
There are obvious issues with this mechanism like decryption of authenticated code, static IV, weak
encryption used, etc. WEP protocol was enhanced by something known as a Shared Key Authentication.
Page 3 of 20
Access Point sends an encrypted file to the client that can only be decrypted by the key (Wi-Fi
Password)
Client enters the password and sends the authentication request frame to AP
AP verifies the decrypted file and confirms that the client has the key used for authentication and
grants access.
Figure 2
UC Berkeley proved that WEP is a weak protocol due to encryption happening using that static key and
hence the advent of WPA and WPA2
Page 4 of 20
Authenticator= AP
Supplicant= client
Anonce = 1-time value for each packet generated by the access point called an Authenticator
nonce
Snonce = 1-time value generated for each packet by the supplicant called a Supplicant nonce.
Now that we know the formulas for PSK and PTK, let’s see how clients and access points create, exchange,
and verify these keys using a 4-way handshake.
Add: For broadcast and multicast modes, basic is the same, the keys generated are a little different. The
pair then becomes GTK and GMK (Group Temporal Key, Group Master Key), and the PSK in this mode is
generated from a Master Session Key (MSK).
4 Way handshake
In layman terms, while authentication, some source keying material is turned into data encryption
material which eventually can be used to encrypt data frames. This process of turning source keying
material into data encryption material is called a 4-way handshake. As we saw above, both the client and
authenticator (access point) know the PSK (aka PMK). But the PMK is not used to encrypt the data and a
PTK has to be derived using PMK.
Let’s understand how a handshake is done now:
Page 5 of 20
Figure 3
Page 6 of 20
PMKID is a hashed value of another hashed value (PMK) with 2 MACs and a fixed string.
PMKID = HMAC-SHA1-128(PMK, “PMK Name” + MAC (AP) + MAC(Supplicant)) HMAC-SHA1 is again just
an example of a pseudo-random function. PMKID is a field in the RSN IE frame (Robust Security Network
Information Element). RSN IE is an optional frame found in routers. “PMK Name” is a fixed string label
associated with the SSID. Now, this PMKID has cached in the router and the next time my client connects
to the AP, AP, and client would simply verify this PMKID, and no 4-way handshake regime is required
again. PMKID caching is done on various IEEE 802.11 networks with roaming features. Many vendors have
been providing additional RSN security features these days too since the prominence of PMKID attacks is
increasing.
No more regular users required – because the attacker directly communicates with the AP (aka
“client-less” attack)
No more waiting for a complete 4-way handshake between the regular user and the AP
No more eventual retransmissions of EAPOL frames (which can lead to uncrackable results)
No more eventual invalid passwords sent by the regular user
No more lost EAPOL frames when the regular user or the AP is too far away from the attacker
No more fixing of nonce and replay counter values required (resulting in slightly higher speeds)
No more special output format (pcap, hccapx, etc.) – final data will appear as a regular hex-
encoded string
Page 7 of 20
To install this along with other tools in the suite:
apt install hcxtools
After that, we have to put our Wi-Fi adapter or the NIC in monitor mode using aircrack-ng
Now, we’ll try and capture PMKIDs from all the routers around us using hcx.
Here, the demo is the output filewlan0mon is the interface and enable_status 5 means display
authentication and EAP and EAPOL frames only. PMKID could be captured by status 1 as well.
EAP Frames: EAP stands for Extensible Authentication Protocol. This protocol is used for authentication
in WPA2-PSK routers. You see, when we talked about a 4-way handshake, their encryption keys were
being created. EAP however, is responsible for the authentication of the client to Access Point.
The EAP process works as follows:
Page 8 of 20
Access Point gets verification done from the user and sends verification messages back to the
authentication server.
Server grants access and the user is connected to the network and further proceeds for a 4-way
handshake.
There is a total of 40+ authentication mechanisms in EAP but the gist is as told above.
Page 9 of 20
See how PMKIDs are written to the hash. Let us rename this “hash” to “pmkidhash.” Next up is the juicy
brute force.
Page 10 of 20
Capturing only a single PMKID using hcxdumptool
Now, earlier we were capturing all of the PMKIDs near us, what if we want to capture PMKID from a
single Access Point? For that, we have to take note of the MAC ID of the AP. Here, from the previous
hcxdumptool step, I saved the MAC ID in a text file called “target”
cat target
Now, I’ll capture the PMKID and save the output in a file called raj.
Page 11 of 20
Converting pcapng to pcap and cracking using Aircrack-ng
In the demonstration above, we had captured a file called “demo” using hcxdumptool which was a pcapng
file. Now we’ll convert this to a pcap file and crack right away with aircrack-ng
file demo
tcpdump -r demo -w demo.pcap
ls
Page 12 of 20
To crack this, we use the command:
Page 13 of 20
PMKID capture and attack using Airgeddon
The manual labor and memorization of commands are eased down by airgeddon. Here, using this simple
CLI we can press some numeric keys and do the same. Let us capture PMKID by running the airgeddon
script:
Then again press 5 and wait for the script to capture SSIDs around.
Page 14 of 20
Here, you’ll see a list of targets now. Our target is “Amit 2.4 G” on number 6. Then simply enter the
timeout you want the script to wait to capture the PMKID. Let’s say 25 seconds are enough.
Page 15 of 20
Then simply store this PMKID as a cap file. First press Y then enter the path and done.
Now, with an integrated aircrack-ng we can crack the cap file within the airgeddon script itself like this:
Just choose dictionary attack and yes and then the dictionary file.
Page 16 of 20
Sure enough, we have the password we needed
wget http://old.kali.org/kali/pool/main/libp/libpcap/libpcap0.8_1.9.1-4_amd64.deb
dpkg -i libpcap0.8_1.9.1-4_amd64.deb
Page 17 of 20
Now that it’s installed and our adapter is in monitor mode, we’ll run bettercap
bettercap
set wifi.interface wlan0mon
wifi.recon on
wifi.show
Page 18 of 20
We now need to associate with an access point using the BSSID.
wifi.assoc 68:14:01:5a:0e:9c
wifi.assoc all
We now need to convert this pcap file in Hashcat format and crack it as we did before, so:
Page 19 of 20
And that’s how it’s done!
Conclusion
PMKID attacks are a big threat to SOHOs and enterprises and necessary steps must be taken in order to
safeguard yourself against these kinds of low intellect attacks that anyone could perform. It also explains
the necessity of having a complex password and also, the importance of upgrading to WPA3.
******************
Page 20 of 20
JOIN OUR
TRAINING PROGRAMS
H ERE
CLICK BEGINNER
Network Pentest
Wireless Pentest
ADVANCED
Advanced CTF
Android Pentest Metasploit
EXPERT
Privilege Escalation
APT’s - MITRE Attack Tactics
Windows
Active Directory Attack
Linux
MSSQL Security Assessment
www.ignitetechnologies.in