4 Way Handshake Explained
4 Way Handshake Explained
or how WPA cracking really does work
This work is licensed under the Creative Commons AttributionNonCommercialNoDerivs 3.0 Unported
License. To view a copy of this license, visit http://creativecommons.org/licenses/byncnd/3.0/ or send a
letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
Abstract:
Over the past years people perennial asking stuff like how they can crack WPA Passphrases
with the common MD5 online crackers or tables and the Pr0s answerd perennial stuff like:
"Guys it doesn't work that way."
So obviously the Answer is "look in the fucking specification paper". But a wise men once
said:
The IEEE 802.112007 Paper is great, you sleep perfectly well on it
So this Papers is suppossed, to give people who aren't deep in cryptography and protocol
analysis an understanding how tools like aircrack or pyrit work and why there isn't just a
MD5 Hash. Therefore this paper will have only a look at the things who are important for
the authentication and neglect the details for the key exchange for the futher encrypted
transmission.
Overview:
As mentioned above WPA or rather the authentication and the negotiation of the keys isn't
just a MD5 of the password from the client to the accesspoint. Mainly there a two pseudo
Randomnumbers, a SSID and the passphrase . But before we totally jump in, we need some
acronym clarification. You also should slightly understand what HMAC() does. (Have a look at
wikipedia or the like).
SNonce: PseudoRandomnumber, generated by the Client
ANonce: PseudoRandomnumber, generated by the Acesspoint (AP)
EAPOLFrame: Is a structur for the EAPOL Packets, stores many information about the
connection status.
GTK: Group temporal Key, used for further transmission, nonrelevant for us
Dude, where are my keys?
During a connection process to a WPA Network, they are many keys who relay on each
other. But do we need so many keys? First it confuses people and secondly, which is the more
important point, they are needed to verfiy particular aspects of the whole exchange and the
encrypted communication afterwards.
At first we'll have a look at the keychain of the most important keys. This keys exist both,
on the Client and on the AP side. The chain starts with the Passphrase and the ESSID. The
HMAC with the SHA1Algorithm over the essid with the passphrase results in the Pairwise
MasterKey (PMK).
Afterwards the string "Pairwise key expansion", the SNonce, the ANonce, the client MAC
and the accesspoint MAC are build, in a certain order, in a string. This string will hashed
with the PMK in a HMAC(sha1). (The A and SNoce are exchanged during the
authentication process.) The clew of this is our PairewiseTrancientKey (PTK).
Parts of the PTK are also keys. Thus, for example the KeyConfirmationKey (KCK) (no
kidding it really exists) consist of the 16 first Bytes of the PTK. The other keys who come
from the PTK are "generated" in the same way.
Quite a handshake What can I do for you?
If a client wants to connect it sends an authentication request first. If this is succesfull , the
client sends an association request if this also is sucessfull it gets interesting.
After the association the accesspoint sends the first of the four Pakets, containig just the
generated ANonce of the accesspoint.
Now the client knows the ANonce and is able to compute the PTK. But it doesn't send the
whole PTK. It fills the EAPOLFrame with the SNonce and generates the authentication and
Integrity Code M(A)IC with the KCK over this EAPOLFrame. Then the client writes the
MAIC in the Frame too and sends the Second Paket of the Handshake to the Accesspoint.
They don't send the whole PTK because, the other parts of it are used to etablish the GTK
and other keys. So they shouldn't be public, even if they on each authentication procedure
different.
The accesspoint now has the ANonce, the last what it needs to generate the PTK. Now the
AP caches the MAIC and zero the fields in the frame. Then it computes the MAIC (with the
KCK from his PTK) over the EAPOLFrame. If the MAIC matches with the cached MAIC
from Client the AP continue, otherwise it cancels the connection and don't reply to the
client, it even doesn't announce that the Authentication Procedure is failed. Within the third
paket is also the GTK, the GTK is needed afterwards to de/encrypt traffic and verfiy Data.
After the Client has integrate the GTK and other Keys, it sends a confirmation to the
Accesspoint again with a MAIC and the actual data transfer begins.
And the numbers are always cracking
Lets have a look at the cracking procedure. At first the cracker gathers all the needed
informations from the paket stream: the ANonce, the SNonce, the Client MAC and the
Accesspoint MAC and the first send MAIC.
The SSID is taken from an association request or a beacon frame. Now the cracker
computes the PMK, with the first password from the password list, then the PTK and finally
it computes the MAIC with the KCK over the second EAPOLFrame with a zeroed M(A)IC
Field. If it matches it is the correct passphrase otherwise it will repeat the procedure.
To speed up this people made Rainbowtables with PMKs, so the cracker doesn't have to
compute the PMK, just the PTK and the MAIC. And why this is always possible for only one
SSID, you should understand by yourself now.