Determining The WEP Key

It is surprisingly easy to setup the necessary equipment to crack a WEP key. If you have a laptop and wireless card supported by Linux, it takes about 10 minutes to temporarily convert it into a network security tool. For this article, I made use of the following (shown in Equipment Used To Decode WEP):

Network Security Toolkit v1.2.2

This Live CD contains all of the software tools necessary for this article (kismet, aircrack, ntop, etc) in a ready to run format. You simply boot the CD, configure it as needed, and then monitor network activity. This toolkit is freely available from http://www.networksecuritytoolkit.org/.

vprMatrix 200A5

This is my wife's old laptop. Its sufficient (though not my idea of an ideal laptop) for running the NST software.

Note

Deciphering a WEP key requires one to capture a large amount of data (you probably want to have at least 2GB of free disk space). As the vprMatrix 200A5™ is no longer a dedicated Windows XP™ machine (it dual boots now), I have a partition on the hard disk formatted with a ext3 file system. Therefore, hard disk space is not an issue for this system. If you attempt to use a existing laptop whose entire disk is formatted for Windows XP, you will not be able to make use of the hard disk (you will need to re-partition, use a USB storage device, or use network storage for data capture).

Linksys WPC55AG v1.1

The vprMatrix 200A5™ laptop has a built in wireless card which is directly supported by the NST distribution. However, it is a 802.11b card, and I want to be able to capture 802.11g data. The Linksys WPC55AG v1.1™ is supported by the MADWIFI project and allows me to monitor 802.11g traffic.


To convert the laptop into a network security tool, we will need to:

Note

I'm a strong believer in "type it once". Normally, I would create a single script to automate the above steps. However, for the purpose of this article, we will do everything by hand.

When booting from the NST CDROM, one is given the chance to choose an initial configuration. The default configuration is desktop mode. In this mode it is assumed you are using a standard desktop system which is networked with an available DHCP server.

Since a non-networked laptop is being used for this article, I will need PCMCIA drivers loaded, but won't require network access. To accomplish this, I will choose to boot into pcmcia mode as shown in the output below:


Note

It is difficult to capture initial boot screens. The above boot screen is close to, but not exactly what one sees at boot time. The information shown was captured by using a serial port connected to a different NST system. The serial output is not as "pretty" as what one sees on the console, but is functionally similar.

As we are using the unmodified public ISO image which is publicly distributed by the Network Security Toolkit project, we are then prompted to set the root password.

After setting the root password, we are then prompted to login, and we log into the system as root with the password we previously specified.


This is pretty self explanatory - we just need to physically insert the wireless adapter into the PCMCIA slot. Since the wireless adapter used in this article has a compatible Atheros chip set, it should be mapped to interface ath0 if things go well. We can verify this by running the following commands (after inserting the card of course):


Note

I'm not particularly fond of the warning message displayed in the output produced by iwconfig ath0 (shown above). However, I've come to live with it as the card functions for the purpose required.

Though not required, we will bring up a graphical desktop. This facilitates screen captures for the purpose of this article. The following commands are used to configure and start the graphical desktop:

Figure 5. Bringing Up A Graphical Desktop


[root@probe root]# setup_x
Starting xfs:                              [OK]
* ddcprobe returned bogus values:
ID:   None
Name: None
HorizSync: None
VertSync:  None

Could not find existing X configuration
Trying with card: NVIDIA GeForce 4 (generic)
Writing temporary config file to /tmp/tmpTRjIRDxorg.config
Trying to start X server
Waiting for X server to start...log located in /var/log/Xorg.setup.log
1...2...3...4...5....Logging to: /root/fluxbox.log
BScreen::BScreen: managing screen 0 using visual 0x23, depth 16
X connection to :17.0 broken (explicit kill or server shutdown).
X server started successfully.
Writing configuration to /etc/X11/xorg.conf
Removing old /etc/X11/X
Creating /etc/X11/X symlink
X Setup Finished.

You may want to review: /etc/X11/xorg.conf

Use the following command to start up X:

  startx

[root@probe root]# startx
xauth:  creating new authority file /root/.Xauthority
xauth:  creating new authority file /root/.Xauthority


Release Date: 18 December 2003
X Protocol Version 11, Revision 0, Release 6.7
Build Operating System: Linux 2.4.21-23.ELsmp i686 [ELF] 
Current Operating System: Linux probe 2.6.10-1.771_FC2 #1 Mon Mar 28 00:50:14 EST 2005 i686
Build Date: 24 March 2005
Build Host: bugs.build.redhat.com
 
	Before reporting problems, check http://wiki.X.Org
	to make sure that you have the latest version.
Module Loader present
OS Kernel: Linux version 2.6.10-1.771_FC2 (bhcompile@porky.build.redhat.com) (gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)) #1 Mon Mar 28 00:50:14 EST 2005 
Markers: (--) probed, (**) from config file, (==) default setting,
	(++) from command line, (!!) notice, (II) informational,
	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Tue May  3 10:00:31 2005
(==) Using config file: "/etc/X11/xorg.conf"
Logging to: /root/fluxbox.log
BScreen::BScreen: managing screen 0 using visual 0x23, depth 24

waiting for X server to shut down 


At this point, we see a graphical desktop similar to the one below.


As we need to capture a lot of data in order to decipher the WEP key (think .5 GB to 2.0 GB), we won't be able to use RAM disks (the machine being used has only 512MB of RAM). This can be a problem if the machine being used has its entire disk dedicated to Windows XP™ (the NST distribution does not recommend one write directly to the NTFS partitions used by Windows XP™). Fortunately, this machine has been configured for a dual boot environment and has a partition which is readable AND writable by the NST distribution. The following demonstrates how the fdisk command was used to identify the partition and how the partition was then mounted to /mnt/wep.


From the above, you should see that we have 9GB (9018MB) of writable disk space available to us under the /mnt/wep directory.

Note

If there wasn't sufficient hard disk space available, we still would have had several options open to us. We could have attached an external USB hard disk. We also could have made use of the Ethernet port on the notebook to connect to the network and made use of a shared network drive. The NST distribution supports the use of both NFS and SMB (Windows Shares) drives.

Now that we have writable disk space available, we can go ahead and setup and configure kismet. In order to accomplish this, we will do the following:

  • Run the setup_kismet script and tell the script that it should make use of the writable disk space under /mnt/wep.

  • Edit the kismet configuration file (/etc/kismet/kismet.conf) created by the setup_kismet script and make sure it matches our wireless card and that logging of all of captured packets is enabled.

  • Start the kismet_server so that it can start collecting wireless data.

The command sequence to accomplish these steps is shown below:


Note

The author of this article is more comfortable with the emacs style key bindings used by the jed editor, feel free to use vi if that's what you are comfortable with.

We need to make two changes to the /etc/kismet/kismet.conf configuration file. First we need to select the appropriate kismet source module for our wireless card. We will comment out the default wlanng source line, and uncomment the madwifi_g source line. This looks like:


Next, we need to enable the dump option in the logtypes configuration line. After finding the logtypes line in the /etc/kismet/kismet.conf file, we change it to:


Once the configuration file has been modified and saved, we exit the jed editor and use the following commands to start the kismet_server:

Figure 11. Starting The Kismet Server


[root@probe root]# cd /mnt/wep/kismet
[root@probe kismet]# ./run_kismet_server
*** Adding user: "kismet"...

*** Starting up the Kismet Server...
[root@probe kismet]# Will drop privs to kismet (10002) gid 10002
No specific sources given to be enabled, all will be enabled.
Enabling channel hopping.
Enabling channel splitting.
Source 0 (atheros): Enabling monitor mode for madwifi_g source interface ath0 channel 6...
Source 0 (atheros): Opening madwifi_g source interface ath0...
Spawned channelc control process 2954
Dropped privs to kismet (10002) gid 10002
Allowing clients to fetch WEP keys.
WARNING:  Disabling GPS logging.
configdir '/home/kismet/.kismet/' does not exist, making it.
SSID cloak file did not exist, it will be created.
IP track file did not exist, it will be created.
Logging networks to Kismet-May-03-2005-1.network
Logging networks in CSV format to Kismet-May-03-2005-1.csv
Logging networks in XML format to Kismet-May-03-2005-1.xml
Logging cryptographically weak packets to Kismet-May-03-2005-1.weak
Logging cisco product information to Kismet-May-03-2005-1.cisco
Logging data to Kismet-May-03-2005-1.dump
Writing data files to disk every 300 seconds.
Mangling encrypted and fuzzy data packets.
Tracking probe responses and associating probe networks.
Reading AP manufacturer data and defaults from /usr/local/etc/ap_manuf
Reading client manufacturer data and defaults from /usr/local/etc/client_manuf
Dump file format: wiretap (ethereal libwiretap) dump
Crypt file format: airsnort (weak packet) dump
Kismet 2005.01.R1 (Kismet)
Logging data networks CSV XML weak cisco
Listening on port 2501.
Allowing connections from 127.0.0.1/255.255.255.255
Registering builtin client/server protocols...
Registering requested alerts...
Registering builtin timer events...
Gathering packets...
Tue May  3 20:45:34 2005 Found new network "ccgdom" bssid 00:0C:41:D0:58:8E WEP Y Ch 8 @ 54.00 mbit
Tue May  3 20:45:40 2005 Found new network "Linksys" bssid 00:0C:41:C8:8B:29 WEP  N Ch 6 @ 54.00 mbit
[root@probe kismet]# 


Now that we've started the kismet_server, we'll bring up the kismet_client for the following reasons:

We will right click on the desktop to bring up the applications menu and then select Kismet from the Wireless Applications menu.


The kismet client program starts up and reports that two networks have been found. The network I'm interested in has a SSID of ccgdom. From the screen capture below, we can see that the ccgdom network is using channel 8 and WEP encryption.


After clearing the “Welcome to Kismet” message (by pressing the space bar), we will instruct the kismet_client program to sort by SSID. To do this, we press the lowercase s key twice. After sorting, we will use the arrow keys to select the line displaying information for the ccgdom network and press the upper case L key to instruct the kismet_server to lock onto channel 8. This will allow kismet to acquire data from our network more quickly (it won't miss packets by channel hopping to frequencies used by other wireless networks). At this point, we are capturing data and the kismet_client screen resembles:


Now that we have the kismet_server running and capturing wireless packet data (which its storing in /mnt/wep/kismet/Kismet-May-03-2005-1.dump), all we can really do is wait until enough traffic has been captured. Unfortunately, knowing when you have enough captured data is not an exact science. As a general rule of thumb, I don't bother running aircrack on the captured data until I have at least .5 GB of data, and prefer to have something closer to 2 GB of data.

If we assumed a fully utilized network, we might estimate (very optimistically) that a 802.11g network might generate .005 GB (5 MB) of data every second. At this rate, it would take 5 minutes (1.5 GB / .005 GB / 60 secs/min) to capture 1.5 GB of data. However, we'll see that my home network produces much less data than this optimistic estimate (we'll need to wait MUCH longer than 5 minutes).

We will run a command which periodically reports a time stamp followed by the size of the captured data, waits for 15 minutes and repeats the process. By using the information reported, we can make some estimates as to how much time must elapse before my home network has leaked enough information to the outside world such that its WEP key could be cracked.


From the one hour period starting May 3 21:15 and ending May 3 22:15, we see that our capture file has grown at a rate of 5427200 bytes/hour in size (6733824-1306624). At this rate, it will take roughly 276 hours (1500000000/542720) to capture 1.5 GB of data. It looks like we are in for a long wait. However, I started on this article late at night when there is very little traffic occurring on our wireless LAN. We'll let it run over night and check the rates again later in the morning during normal business hours (both my wife and I work out of the home).

From the 32.5 hour period starting May 3 21:15 and ending May 5 05:45, we see that our capture file has grown at a rate of 19503244 bytes/hour in size ((716460032-1306624)/32.5). At this rate, it will take roughly 76.5 hours (1500000000/19503244) to capture 1.5 GB of data on my home network. As we are getting impatient, we will move along and see what aircrack can do with the 700 MB of data that has been collected so far.

After collecting quite a bit of data with kismet, we will be using aircrack to decipher the WEP key. Here are my general rules of thumb when using aircrack:

  • If aircrack doesn't determine the WEP within a minute or two, then more data is probably required.

  • It helps to specify the -m MACADDR option to aircrack to make certain it is looking at the packets of the network you are interested in (kismet can tell you this information).

  • If aircrack gives up quickly, it might be worth increasing the fudge factor (the -f fudge option). I've seen aircrack fail to determine a WEP key with a fudge factor of 2 and then succeed by increasing the fudge factor to 3.

In order to determine the MAC address to pass to aircrack, I will use the kismet_client program, select the ccgdom network and press the Enter key. This will display information about the network I am interested in (shown in Network Details Reported By Kismet). I see that the network of interest has a BSSID of 00:0C:41:D0:58:8E. This information will be passed to aircrack in the form of -m 00:0c:41:d0:58:8e.


Now that we have 700 MB of data and we know the MAC address to pass to aircrack, we'll invoke aircrack and see what happens. The invocation is shown in Invoking aircrack Using Default Fudge Factor. After taking a bit to load the captured data, aircrack only runs for 4 seconds before giving up on finding the WEP key (shown in Failed To Find WEP).



Unfortunately, aircrack failed to decipher the WEP key with the first invocation. We'll try running aircrack again and this time, we'll increase the fudge factor to 3 and allow aircrack to explore more possible combinations (shown in Invoking aircrack Using A Fudge Factor Of 3).



As we can see (in Successfully Found WEP), aircrack was able to decipher my WEP key in 54 seconds (not counting the time to load the packet data).

Note

We had the opportunity to transfer the entire 700MB file to a dual AMD Opteron™ 1.6GHz Sun Fire V20z™ server sporting 2GBs of RAM. This systen was running the NST distribution using the SMP kernel: 2.6.10-1.771_FC2smp. Running aircrack on this box produced the WEP key in 40 seconds using one CPU and 24 seconds when using two CPUs. This demonstrates that the SMP Linux kernel scales quite nicely.

Let's pause for a moment and consider what we know so far: