WPA: Enhancements Over WEP Security
WPA: Enhancements Over WEP Security
Table of Contents
Table of Contents................................................................................................................ii
List of Figures....................................................................................................................iii
WPA: WEP with Band-aids?..............................................................................................1
1 Wireless Networks.......................................................................................................1
2 WEP/WPA/WPA2 and the IEEE 802.11 Specification..............................................1
2.1 Data Frames.........................................................................................................2
2.2 Typical Encryption Modes..................................................................................3
3 WPA’s Modifications to Patch WEP’s Vulnerabilities...............................................3
3.1 Authentication of Management Frames...............................................................3
3.1.1 WEP: No Authentication of Management Frames.....................................3
3.1.2 WPA Protocol Modification........................................................................4
3.2 Message Integrity Check.....................................................................................4
3.2.1 WEP: Weak Message Integrity Check.......................................................4
3.2.2 WPA Protocol Modification........................................................................4
3.3 Replay Protection.................................................................................................5
3.3.1 WEP: No Replay Protection.......................................................................5
3.3.2 WPA Protocol Modification........................................................................5
3.4 IV Collisions, Challenge/Response, and Key Generation...................................6
3.4.1 WEP: IV Collisions....................................................................................6
3.4.2 WEP: Challenge/Response Authentication reveals PRGA........................7
3.4.3 WEP: Encryption Key is Reversible from Ciphertext................................8
3.4.4 WPA Protocol Modification........................................................................9
4 Tools to Exploit WEP/WPA Weaknesses.................................................................13
4.1 WEP Attack – Recovering the PSK with AirCrack-ng.....................................14
4.1.1 Basic WEP-PSK Attack Approach............................................................14
4.1.2 Attack Setup...............................................................................................14
4.1.3 WEP Packet Capture and Traffic Acceleration.........................................16
4.1.4 Cracking the PSK......................................................................................17
4.2 WPA Attack – Recovering the PSK..................................................................18
4.2.1 Basic Attack Approach..............................................................................18
4.2.2 Capture Handshake....................................................................................18
4.2.3 Offline Dictionary Attack..........................................................................19
5 Conclusion.................................................................................................................21
Useful Tools for Exploiting WEP/WPA............................................................................22
Bibliography......................................................................................................................23
Haisler iii
List of Figures
Figure 1: Typical Wireless Configuration [16]..................................................................1
Figure 2: Unencrypted Data Frame [1]...............................................................................2
Figure 3: WEP Encryption Enabled [1]..............................................................................2
Figure 4: WPA Encryption Enabled [2].............................................................................2
Figure 5: MIC Counter Measures [2].................................................................................5
Figure 6: WPA Replay Protection using Counters [2].......................................................6
Figure 7: Exploiting IV Collisions.....................................................................................7
Figure 8: WEP Encryption [9]............................................................................................8
Figure 9: 4 Way Handshake and Key Generation............................................................10
Figure 10: Graphical Representation of WPA Encryption...............................................12
Figure 11: BackTrack v2 802.11 Attack Tools................................................................13
Figure 12: Basic Attack with AirCrack [12].....................................................................14
Figure 13: Configuring Wireless Interface.......................................................................15
Figure 14: Finding the Neighbor’s Network....................................................................16
Figure 15: Packet Capture................................................................................................17
Figure 16: Cracking the WEP PSK..................................................................................17
Figure 17: Successful WEP Attack...................................................................................18
Figure 18: Capturing Handshake......................................................................................19
Figure 19: Attempting to Force a Handshake...................................................................19
Figure 20: Kick off Offline Dictionary Attack.................................................................20
Figure 21: Successful WPA-PSK Attack.........................................................................20
Haisler 1
1 Wireless Networks
Wireless IEEE 802.11 networks are constantly increasing in popularity and are showing
up everywhere, even at coffee shops. The real advantage of a wireless network is the
mobility it provides due to the fact that clients do not need to be physically connected to
the network. Wireless networks are typically used to extend an existing wired network.
The most typical home setup is shown in Figure 1 where clients communicate to hosts on
the wired network (an Internet) through a hardware access point. Since any packet that is
sent in the air waves is received by any host that is in range, each access point is assigned
a Basic Service Set Identifier (BSSID). The access points and its clients use the BSSID
to filter out extraneous packets that are intended for other networks. In addition, due to
the fact that any host within range can see any packet transmitted, 802.11 included the
Wired Equivalency Protocol (WEP) to provide confidentiality to the traffic between a
host and the access point.. However, WEP was soon found to be a poor encryption
protocol that spurned several appendices to be added to the 802.11 specification to solve
the problem of providing confidentiality over a wireless network. This paper seeks to
give a discussion of various weaknesses and insecurities found in the WEP protocol,
WPA’s modification to the protocol to address these vulnerabilities, and a conclusion of
WPA’s effectiveness. Lastly, the author captures the simplicity of using today’s tools to
attack WEP-PSK and WPA-PSK.
of the 802.11i before it was ratified. The protocol was named Wi-Fi Protected Access
(WPA) and was based on Draft 3 of 802.11i. The focus of WPA centered around
creating a new encryption mechanism that would improve confidentiality while utilizing
the existing WEP hardware. The Wi-Fi alliance decided to trade a complete specification
rewrite, and perhaps a more secure protocol, for the benefit of designing WPA such that
it could be deployed to most existing wireless systems via a firmware/software upgrade.
WPA2 implements the full 802.11i standard which includes the features of WPA as well
as support for AES and CCMP. WPA2 requires a full hardware upgrade in most
instances.
In order to prevent abuse of the MIC, the 802.11i specification requires an access point
that receives more than 2 packets with an invalid MIC in 60 seconds to 1) de-authenticate
all users, 2) shutdown for 60 seconds, 3) re-authenticate all users [2]. Although this
approach is effective at slowing down the attack, it could also be used to implement a
DOS attack on the network. Figure 6 from the 802.11i specification graphically depicts
the MIC countermeasures.
Haisler 5
packet that preceded it [3]. A receiver only updates the TSC counter it is caching to the
received packet’s TSC counter if the ICV/MIC checks pass.
Two potential attacks to the TSC mechanism are remedied by the ICV and MIC checks.
The first attack involves attempting to replay packets onto the network by capturing a
packet, incrementing the TSC (remember the TSC is transmitted in the clear) and then re-
broadcasting the packet onto the network. The attack fails because the TSC is used as
input to the packet decryption key. Thus when the MIC and ICV are decrypted, the
calculated ICV/MIC will not match the received ICV/MIC values and the packet will be
dropped. The second attack involves an attempted DoS attack by transmitting (or
modifying a packet and re-transmitting) a packet with the TSC set to a significantly
higher value [3]. As above, receivers are protected from such packets by the ICV/MIC
checks. The packet decryption will be garbled and the packet will be dropped.
Since the shared secret key is always 1 of 4 keys, the IV part of the encryption key is
used so that a unique encryption key is available for each packet. The IEEE 802.11
specification does not define IV selection criteria [1]. Thus, most vendors simply
implement a sequential (big-endian or little-endian) counter for IV selection that starts at
Haisler 7
x00:00:00 for the first packet and wraps at xFF:FF:FF. A few vendors implement a
random IV generator that filters out “weak IVs” (weak IVs are discussed later).
It is very important in WEP that Initialization Vectors (IV) are never reused because they
are the only piece of the encryption key that is unique. Figure 7 shows how plaintext2
can be revealed if plaintext1 is known and both messages are encrypted with the same
encryption key (which results in the same PRGA output) [13]. The plaintext of certain
encrypted well known packets, such as ARP or DHCP packets, can be guessed by
observing packet size and header information. When these packets are found, they can be
used to decrypt other packets encrypted with the same IV. A single DHCP packet
provides enough information to decrypt most of the TCP/IP header of any other packet
encrypted with the same IV [11].
An insertion attack can also be carried out if an attacker knows the ciphertext and
matching plaintext of a packet. They can XOR the ciphertext and plaintext together to
produce a valid keystream (PRGA). The attacker can then insert any arbitrary packet
they desire on the network encrypting it with the valid keystream. The packet will be
encrypted correctly -- all without knowing the shared secret key!
decrypts the received response from the client and compares the known challenge
plaintext with the decrypted response plaintext. If the plaintext matches, the client is
assumed to know the shared secret key and is allowed to logon to the network [6].
The problem with closed networks is that the challenge/response authentication exchange
can be used to generate 128 bytes of valid keystream (PRGA). All an attacker needs to
do is sniff the challenge/response authentication packets.
With a valid keystream, an attacker can now transmit arbitrary packet contents without
knowledge of shared secret key [18].
paper to derive the encryption key. Once the encryption key is known, the shared secret
key is known (because the IV is plaintext).
In WPA-PSK, TKIP begins with a PSK (8 – 63 ASCII characters in length) that has been
entered manually into each access point (AP) and each client (C). The PSK is used to
generate a 256 bit Pairwise Master Key (PMK) which in turn is used to generate a 512-bit
Pairwise Transient Key (PTK). PMK is calculated using the Password-Based Key
Derivation Function v2 (PBKDF2) as follows:
After both the client and the access point have the PMK, the four way handshake occurs.
See Figure 9 for a graphical depiction of the handshake. The access point initiates the
handshake by sending a random number (ap-nonce) and his MAC address (ap-MAC) to
the client. After receiving the information from the access point and generating a random
number, the client now has the necessary information to calculate the PTK. PTK is
calculated as follows where PRGF is a pseudo-random generator function based on
HMAC-SHA1.
After determining the PTK, the client responds with his random number (c-nonce), MAC
address (c-MAC) and a MIC calculated using the EAPOL-Key.
Upon receiving the ap-nonce and ap-MAC, the access point calculates the PTK, validates
the MIC and then transmits a starting sequence number and a MIC. The client validates
the MIC received from the access point and then responds with an acknowledgement and
a MIC.
At the completion of the handshake, each party has determined the PTK and verified that
the opposite party has knowledge of the PMK (by verifying the MIC) [4]. The PTK is
broken into 4 separate keys as shown at the bottom of Figure 9.
Haisler 10
Once the PTK is shared between the client and the access point, the encryption algorithm
shown in Figure 10 is used to handle data packets. Notice that WEP is still used in TKIP.
The shaded gray area of Figure 10 represents the original WEP specification, while the
peach shaded area includes the parts added by TKIP.
TKIP starts in Phase 1 by mixing the 32 most significant bits of the TKIP Sequence
Counter (TSC) with the transmitters address and the Temporal Encryption Key (TEK) to
produce an 80 bit intermediate key (TTAK). For each data packet that is sent, the 16
least significant bits of the TSC are incremented by 1 to produce a unique WEP Seed key.
To prevent IV collisions with the same key, when TSC0 and TSC1 rollover, TSC5-TSC2
are incremented by 1 which in turn updates the TTAK (updating the TTAK generates a
new key for the 104-bit part of the WEP key and thereby eliminates IV collisions) [2].
Phase 2 the TKIP encryption protocol is responsible for creating the actual IV and
encryption key that will be passed to WEP. Phase 2 mixes the TTAK with the TEK to
create the 104-bit piece of the WEP key, and then takes TSC1 and TSC0 to calculate the
Haisler 11
1 byte Seed to place in the 24-bit IV along with TSC0 and TSC1. The Seed is used to
prevent certain classes of weak RC4 keys used by various WEP attacks (such as the FMS
attack) from being loaded into the IV [3]. The Seed is created by calculating the
following
Once the MIC is calculated it is appended to the data and passed as a single data block to
WEP. WEP appends the ICV and then encrypts the entire piece with the RC4 keystream.
When the TKIP protocol is used, the Ext IV (the extended IV consists of TSC2-TSC5) bit
is set in the final transmitted frame.
With the resources available (being compatible with existing WEP hardware), TKIP has
proven so far to be a significant improvement over WEP. The MIC prevents random bit
flipping attacks and greatly strengthens the ICV. Although susceptible to attack, the
Michael countermeasures successfully slow attackers down to the point that the attack is
impractical. The introduction of the TKIP Sequence Counter closes the WEP replay
attack vulnerability and provides fresh input into the key mixing algorithms. In addition,
the traditional attack of “gather as many weak IVs as possible by injecting packets with
duplicate IVs” has been thwarted by TKIP since the 104-bit key is changed regularly,
duplicate IV packets are dropped, and an IV seed is used to eliminate many of the known
weak keys.
However, WPA’s PSK is susceptible to dictionary attack when a weak PSK is chosen.
The attack results from the fact that the PTK is based upon a single unknown, the PSK.
The remaining parameters of the PTK generation algorithm can be sniffed during the 4
way handshake. Remember that:
Several tools have surfaced to automate the attack against the 4 way handshake using
dictionaries to guess the PSK. These include AirCrack and coWPAtty. Notice however
that the attack is complicated by the fact that the SSID is included in the PMK. To
Haisler 13
overcome this hurdle, an organization called the Church of the WiFi currently provides 8
gigabytes of rainbow tables that include pre-computed PMKs using a 172,000 common
password dictionary and the top 1000 SSIDs listed on [Link] [21].
The best countermeasure against the dictionary attack on the 4 way handshake is to use a
strong, uncommon and lengthy PSK.
Aircrack is a suite of tools that can be used to statistically attack and recover WEP and
WPA pre shared keys The following applications make up the Aircrack suite:
Airodump-ng - performs packet capturing for 802.11 frames
Aircrack-ng - performs attacks using the weaknesses published in FMS with some
optimizations based on KoreK’s Chopchop
Airdecap-ng - performs decryption on WEP/WPA packet capture files
Aireplay-ng – performs packet injection on 802.11 networks including WEP
enabled networks (currently supports 5 different attacks) [8]
An easy way to explore the capabilities and get hands on practice with Aircrack is to
download BackTrack 2. BackTrack 2 is a Linux live distribution (boot from CD while
running in RAM only) that supports a wealth of network penetration tools and wireless
network cards. Figure 11 below shows version 2’s 802.11 tool support.
The author is using an IBM Thinkpad laptop (1.8GHz with 256MB RAM) paired with an
AirLink 101 wireless cardbus adapter (AWLC4130) and the BackTrack 2 Final Linux
live distribution.
Haisler 15
After booting BackTrack and logging in, bring up a terminal window to configure the
WNIC for monitor mode (see Figure 13).
1.) Run: iwconfig
iwconfig will list the wireless configuration of the network interfaces. Here we are
looking for a wireless interface that is already in monitor mode (there is not one in
this example)
2.) Run: airmon-ng
aimon-ng without any parameters will list any wireless interfaces and the driver
associated with the interface. The associated driver must support monitor mode. If a
driver is not loaded, manually install a driver that supports monitor mode for the
WNIC’s chipset.
3.) Run: airmon-ng start wifi0 to create a new interface set in monitor mode. Notice
ath0 was created.
4.) Run: iwconfig one more time to verify that the WNIC is actually in monitor mode
Now that the wireless NIC is ready to start sniffing packets, run airodump-ng ath0 to
determine which networks are in range. Figure 14 below shows an example output. Note
that the neighbors network the author will be testing is marcus (obtained through social
Haisler 16
engineering because at this point the neighbor still trusts the author!). The BSSID of
marcus shown here will be used later to limit the attack to just the neighbor’s access
point.
The attack is successful in generating traffic on the network due to the fact that the client
with the IP address specified in the broadcasted ARP-request packet responds with a
packet. Since there is no replay protection in WEP, the ARP-request packet can be re-
injected over and over producing a constant stream of packets (answers) from the client.
To begin capturing packets, use the airodump-ng command. To limit the captured
packets to just those desired, use the --bssid parameter. Note in Figure 15 airodump-ng is
also passed the channel for marcus (to eliminate channel hopping), the --ivs flag (tells
airodump to only capture the IVs while dropping the rest of the packet – saves disk
space), and the --write flag (tells airodump to write the captured IVs to the file
“capture”).
Haisler 17
Now that we have accumulated a little over 200,000 packets, let’s begin the WEP-PSK
attack with aircrack-ng. Notice in Figure 16 that we pass two parameters – 128 tells
aircrack that the WEP key is 128-bit (obtained through social engineering) and capture-
[Link] is the name of the IV capture file airodump-ng is writing to (the “01” in the
filename is appended by airodump automatically).
face, the author enjoyed the overwhelming surprise in the neighbor’s face when the key
was verified to be correct.
airodump-ng with the following parameters: channel number, BSSID, file to write the
packets to, and the sniffing interface.
aircrack-ng the name of the dictionary file, the MAC address of the client and the name
of the file holding the 4 way handshake. If aircrack returns an error that a handshake is
not found, repeat the steps above to capture a handshake.
The author has now since explained the attacks to his neighbor and assisted him in setting
up a secure wireless network (as secure as WPA can get). His only response….”How
will I ever remember that huge passphrase?”
5 Conclusion
In conclusion, 802.11 with WEP enabled provides insufficient confidentiality. The
biggest problems that plague the WEP implementation include:
IVs are too short
ICV is too short and is linear
Implementation of the RC4 algorithm is weak and vulnerable to attack
No protection against replay attacks
Since there is a growing number of ready to download tools that exploit WEP’s
weaknesses, WEP should not be utilized to provide confidentiality on a wireless network
if confidentiality is important.
WPA has proven so far to be a significant improvement over WEP. The MIC prevents
random bit flipping attacks and greatly strengthens the ICV. The TKIP Sequence
Counter closes the WEP replay attack vulnerability and provides fresh input into the key
mixing algorithms. In addition, the traditional attack of “gather as many weak IVs as
possible by injecting packets with duplicate IVs” has been thwarted by TKIP. WPA
provides good confidentiality as long as a good long PSK is chosen and kept secret.
Haisler 22
Bibliography
[1] IEEE 802.11, 1999 Edition (ISO/IEC 8802-11: 1999);
[Link]
[3] Sanker, Krishna; Cisco Wireless LAN Security; Cisco Press 2005, p200 – 210.
[5] WEP: Dead Again, Part 1 by Michael Ossmann, December 14, 2004;
[Link]
[11] Unsafe at any key size; An analysis of the WEP encapsulation by Jesse R. Walker,
October 27, 2000; [Link]
[12] Reverse engineering of AirCrack software by Mihail Roman, Laurent Fallet, Sumit
Chandel, Najib Nassif, May 2005;
[Link]
[14] Wireless Vulnerabilities & Exploits; ID: WVE-2005-0021, WEP Weak IVs
Vulnerability; [Link]
Haisler 24
[17] Wireless Vulnerabilities & Exploits; ID: WVE-2006-0037, WEP Inverse inductive
attack reveals plaintext; [Link]
[20] Weaknesses in the Key Scheduling Algorithm of RC4 by Scott Fluhrer, Itsik
Mantin, and Adi Shamir; [Link]