Wireless Pre-Shared Key Cracking WPA, WPA2
Wireless Pre-Shared Key Cracking WPA, WPA2
Wireless Pre-Shared Key Cracking WPA, WPA2
com
Wireless Pre-Shared Key Cracking (WPA, WPA2) v1.0 Author: Darren Johnson
www.og150.com
Introduction
The purpose of this document is to discuss wireless WPA/WPA2 PSK (Pre-Shared Key) security. Whilst there are plenty of YouTube videos demonstrating PSKs being cracked, there is little information on the mechanics behind PSK security. This document will discuss the mechanics of PSKs, how they can be cracked with the OG150, myths, limitations and preventative measures. Please note: In this document we use the term PSK, this applies to both WPA and WPA2 PSKs. For clarity, a pass-phrase is defined as A secret text string employed to corroborate the users identity. as per the IEEE 802.11i wireless standard. A pass-phrase and a PSK are DIFFERENT as explained in subsequent sections of this document.
The major difference is that PSKs require a pass-phrase to be statically configured on the client/AP for Personal mode, whereas the equivalent key in Enterprise mode is dynamically created by the RADIUS server and securely sent to the client (upon successful authentication of the client). In other words, Personal mode uses manually/statically configured keys, Enterprise mode uses dynamically negotiated keys. Obviously Enterprise is more secure, but requires a RADIUS server.....which not all people have. Please note: A pass-phrase is a sequence of between 8 and 63 ASCII-encoded characters. The limit of 63 comes from the desire to distinguish between a pass-phrase and a PSK displayed as 64 hexadecimal characters. Lets assume that we have configured a pass-phrase on the client and the AP. What happens next in the communication flow? It is important to highlight the high-level operations here, before diving into the specifics. 1. A pass-phrase is used to generate a PSK (a PSK in this context is also referenced as a PMK Pairwise Master Key). 2. A PSK is then used to generate a PTK (Pairwise Transient Key) using a 4-way WPA handshake between the client and the AP. It is the PTK that is used to encrypt the users data traffic*
Wireless Pre-Shared Key Cracking (WPA, WPA2) v1.0 Author: Darren Johnson
www.og150.com
*There are other keys generated too such as the GTK (Group Temporal Key) to secure broadcast/multicast traffic - we will leave this out for simplicity. OK we have the pass-phrase, how do we generate this thing called a PSK? As per the IEEE 802.11i wireless standard, the following formula is used; PSK = PBKDF2(PassPhrase, ssid, ssidLength, 4096, 256) Hmmmm, that is interesting..... What the hell is it!? Essentially, we take the pass-phrase, the SSID name, SSID length and two other components* and throw it into an algorithm (PBKDF2) which creates a 256-bit PSK. Screenshot 1 is a demonstration of the PSK being generated. For the really sad people (like me), count the hex octets there are 64 HEX octets = 256-bit key (each HEX octet is obviously 4 bits in length).
Screenshot 1 PSK generation based on SSID (og150-test) and pass-phrase (originalgangster)
* 4096 is the number of times the pass-phrase is hashed and 256 is the number of bits output by the pass-phrase mapping. Source: http://www.wireshark.org/tools/wpa-psk.html As shown in Screenshot 1, a pass-phrase of originalgangster and an SSID of og150-test yields a PSK/PMK of; 2274345f36785b71e7f96219873ccd567e6f01abc46b3da10e278c41dc1f117e Please note: The PSK/PMK shown above can be verified by reviewing the Master Key shown in Screenshot 13. We now have the PSK, which also known as the PMK. What next? We need to generate the PTK on the client and the AP, which can then be used to encrypt the users data. The PMK created by the client and the AP SHOULD match, if they dont the following process will fail Wireless Pre-Shared Key Cracking (WPA, WPA2) v1.0 Author: Darren Johnson
www.og150.com
(maybe the user has mis-typed the pass-phrase or maybe a hacker is trying to guess it). The creation of the PTK uses what is called a 4-way handshake. This 4-way handshake is shown in Screenshot 2.
Screenshot 2 WPA 4-way handshake
This part is not rocket science. The AP creates a random number - ANonce and the client (STAtion) creates a random number SNonce. The AP transmits its ANonce to the client. The client then has the PMK, the ANonce and the SNonce which is used to create the PTK. For simplicity, lets pretend that the PTK is simply the addition of the PMK, ANonce and SNonce numbers. The client transmits its SNonce to the AP, but importantly it creates a hash (also known as the MIC Message Integrity Check) of the frame using the newly generated PTK. Once the AP receives the SNonce, it too has the PMK, the ANonce and the SNonce and can create the PTK. If the client and AP derive different PTKs (maybe the pass-phrase is different) the AP will generate a different hash (MIC) and the 4-way handshake fails (client does not connect). Only by having the SAME PTK will the client and AP generate the same hash. Next, the AP sends a frame (Message 3 in Screenshot 2) to the client with a hash and the client can verify the hash using the same process. Interesting points to highlight; The PMK is never actually transmitted over the air, it is locally generated and used as an input to derive the PTK. Each client will generate a DIFFERENT PTK. This is because each client is high likely to generate a DIFFERENT SNonce compared to other clients. This is why one client cannot decrypt another clients traffic using its own PTK.
Wireless Pre-Shared Key Cracking (WPA, WPA2) v1.0 Author: Darren Johnson
www.og150.com
At this point, the client and the AP have authenticated each-other (verifying each others hash values) and can now transmit to each other over the air securely. The traffic is encrypted using the PTK that was previously created. Excellent, we are encrypting traffic over the air now..... I hope it is secure. For reference, Screenshot 3 shown below summarises the PTK generation process.
Screenshot 3 PTK generation process
Wireless Pre-Shared Key Cracking (WPA, WPA2) v1.0 Author: Darren Johnson
www.og150.com
compared to the hash that was captured during the 4-way handshake, if they are the same we have got the correct WPA pass-phrase This process can be seen in Screenshot 4.
Screenshot 4 PTK cracking process
By default, the wireless LAN interface on the OG150 is enabled. I have run into issues cracking PSKs with this enabled, therefore consider disabling the wireless LAN interface (wlan0) as shown in Screenshot 6.
Wireless Pre-Shared Key Cracking (WPA, WPA2) v1.0 Author: Darren Johnson
www.og150.com
Next, turn the OG150 wireless interface (wlan0) into sniffer mode (the OG150 will create mon0 as the wireless sniffer interface) as shown Screenshot 7.
Screenshot 7 Start wireless sniffer on OG150
Use the command airodump-ng mon0 on the OG150 to find out what wireless networks the mon0 interface is detecting. Notice in Screenshot 8 that SSID og150-test is detected and is using WPA2 AES (CCMP) encryption.
Screenshot 8 Discover wireless networks
Next, lets capture specific traffic for the target SSID. We know from the previous screen it is using channel 1 and we also know the BSSID of the AP. We capture traffic specific to this environment and save the output to the USB stick (/mnt/usb/etc) with filename PSK_Capture as shown in Screenshot 9. Please note: It is strongly advised to save the packet capture to the USB that is connected to the OG150, there is very limited memory on the OG150 motherboard.
Screenshot 9 Capture wireless traffic for the target SSID.
I then enable wireless on my iPhone, select og150-test and enter the pass-phrase originalgangster. My iPhone successfully connects and receives an IP address of 10.1.2.28. I prove connectivity by pinging 10.1.2.27 from the default gateway (10.1.2.1). Notice in the Wireless Pre-Shared Key Cracking (WPA, WPA2) v1.0 Author: Darren Johnson
www.og150.com
top right hand corner of Screenshot 10, the text saying WPA handshake. This appears when a 4-way WPA handshake has been captured. Therefore, we have successfully captured the 4-way WPA handshake between my iPhone and the AP! Please note: Sometimes, and for no logical reason, the WPA handshake does NOT display in the top right hand corner. If this happens, please continue to follow the steps in this tutorial as you might still actually have the 4-way WPA handshake.
Screenshot 10 A 4-way WPA handshake has been captured.
There is a dictionary located on www.og150.com that you can download to your OG150 as shown in Screenshot 11. You must download this file to the USB stick connected to your OG150 because the memory built into the OG150 motherboard is very limited and will run out of memory if you try and download to it. Before you run this test, ensure your passphrase exists in the dictionary, otherwise the WPA cracking will fail!
Screenshot 11 Download dictionary file to OG150
Finally, we try and crack the WPA2 PSK. We use the dictionary (previously downloaded in Screenshot 11) and the 4-way handshake within the packet capture file created in Screenshot 9 and Screenshot 10. Please note: The dictionary file hosted on www.og150.com is big, if you want to speed up the process consider using your own dictionary with about 12 words one of which is your pass-phrase.
Screenshot 12 Let the OG150 try crack the WPA2 PSK!
Excellent, in Screenshot 13 you can see that the KEY FOUND message has correctly identified our pass-phrase of originalgangster!!
Wireless Pre-Shared Key Cracking (WPA, WPA2) v1.0 Author: Darren Johnson
www.og150.com
OK we have the pass-phrase. What could a hacker actually do with this? A few things actually...... Configure an Evil-twin AP. This is basically an AP that the hacker owns and is configured with the correct SSID and pass-phrase. A legitimate user could easily associate to this AP and would have no idea that the AP is an Evil-twin AP. All traffic the user sends is captured and is a classic MITM (Man In The Middle) attack An unauthorised user could use the wireless network. The hacker, once he has discovered the pass-phrase, could connect to the wireless network using the passphrase and have full access to network resources A hacker, who captures the WPA handshake, can decrypt the users wireless traffic
Wireless Pre-Shared Key Cracking (WPA, WPA2) v1.0 Author: Darren Johnson
www.og150.com
(and email it to you)! An example of a paid service that does this is: https://www.wpacracker.com/ A good prevention method is to use a non-default/uncommon SSID. Avoid using obvious SSIDs like wireless...... Can ANY pass-phrase be cracked? In theory yes. In reality no. It would take hundreds of years if you had a large enough pass-phrase, and by this time you are probably dead so who cares.....
Conclusion: Is WPA/WPA2 PSK secure? Well, yes if they are deployed properly. If you use a 13 character (random) pass-phrase with a non-default SSID it is VERY unlikely that the pass-phrase will be cracked.
Wireless Pre-Shared Key Cracking (WPA, WPA2) v1.0 Author: Darren Johnson