< Day Day Up > |
Getting Used to Efficient Wireless Interface ConfigurationTo perform efficient wireless security audits, you should familiarize yourself with using UNIX wireless configuration utilities. Yes, this means a lot of command line. However, there are significant advantages to be gained from knowing it, including understanding how more complicated wireless security tools work, being able to write useful shell scripts that save time and make your life easier, and, finally, saving a lot of battery power by not using a GUI (more on that in the following chapter). Linux Wireless ExtensionsWe start with Linux Wireless Extensions as the most common wireless card and interface configuration utilities used on the Linux operating system. Linux Wireless Extensions were initially developed in 1996 to work with the first Hermes chipset cards. Wireless Extensions' support of Prism cards running under wlan-ng drivers is very limited and mainly related to (often incorrect) checking the inserted card configuration parameters. However, Prism cards running under HostAP drivers are perfectly supported and configurable by Linux Wireless Extensions. Besides, 802.11a cards using vt_ark5k drivers and combo cards under Madwifi are configured using the Extensions as well. Despite the comments in the INSTALL file considering possible installation difficulties, we have never encountered any when compiling the Extensions from source, and there is nothing wrong with installing it from your favorite distribution package, unless you have some code modification ideas in mind. The most important utility in Linux Wireless Extensions is iwconfig: arhontus:~# iwconfig --help Usage: iwconfig interface [essid {NN|on|off}] [nwid {NN|on|off}] [mode {managed|ad-hoc|...} [freq N.NNNN[k|M|G]] [channel N] [sens N] [nick N] [rate {N|auto|fixed}] [rts {N|auto|fixed|off}] [frag {N|auto|fixed|off}] [enc {NNNN-NNNN|off}] [power {period N|timeout N}] [txpower N {mW|dBm}] [commit] As you can see, practically any parameter of your WLAN can be configured using iwconfig. Some useful tips to keep in mind are these:
In all these command examples, as well as many more to follow, we use the example eth0 interface for Hermes chipset, wlan0 for Prism and ath0 for Atheros (madwifi) chipsets, and eth0 and wifi0 for Cisco Aironet chipset cards. Don't forget to use appropriate interfaces in your practice. When iwconfig is executed without any given parameters, it displays the data about all available 802.11 interfaces taken from /proc/net/dev. The latest versions of Linux Wireless Extensions support automatic scanning for access points in range and taking the ESSID/frequency of the appropriate access point found. In our observations, the scanning might not work perfectly unless the interface is first brought up with ifconfig (e.g., ifconfig eth0 up) and, until the interface is up, iwconfig might show a freakish frequency value. If for some reason you need an easy-to-use GUI interface to iwconfig, you can use xwconfig from http://www.random-works.co.uk/xwconfig/ (Figure 4-3). Figure 4.3. Xwconfig graphical front end to iwconfig.Iwpriv, or the private extension, is the important companion tool to iwconfig: Whereas iwconfig deals with setting generic standard-defined parameters, iwpriv enables driver-specific configuration changes. Iwpriv is used for setting wireless roaming with some 802.11 card drivers (e.g., wavelan_cs). The main implication of iwpriv in security testing and wireless protocol debugging is setting the card into a monitor mode. For Hermes chipset cards running under the Shmoo-patched Orinoco driver, the command to put such a card into the monitor mode is as follows: arhontus:~# iwpriv eth0 monitor <mode> <channel> where the mode can be 1 (append Prism II headers-specific data to the frame, ARPHRD_IEEE80211_PRISM device type), 2 (monitor mode with no Prism II-specific info, ARPHRD_IEEE80211 device type), and 0 (turn the monitor mode off). For Prism chipset cards running under HostAP drivers, this would be the corresponding command: arhontus:~# iwpriv wlan0 monitor <mode> where the mode value 2 is ARPHRD_IEEE80211 device type, mode value 3 is ARPHRD_IEEE80211_PRISM device type, and mode value 0 is also turning the RFMON mode off. Interestingly, the Linux Wireless Extensions version 25 and later iwconfig can be used to set Prism cards under HostAP into the monitor mode: arhontus:~# iwconfig wlan0 mode monitor This might make obsolete the use of iwpriv with the latest HostAP and also Madwifi versions. You can still set the device type and dumped headers data to both possible values with this: arhontus:~# prism2_param wlan0 monitor_type <type> where type 0 is IEEE 802.11 headers (ARPHRD_IEEE80211) and type 1 is Prism2 + IEEE 802.11 headers (ARPHRD_IEEE80211_PRISM). HostAP drivers come with their own 802.11 frame parser called wlansniff in the sniff subdirectory: arhontus:~# ./wlansniff -h wlansniff [-h] [-b#] [auth] <wlan#> -h = help -b0 = do not show beacons -b1 = show only one line of data for each beacon -b2 = show full beacon data -auth = show only authentication frames You need to put the card into the monitor mode (both ARPHRD_IEEE80211 and ARPHRD_IEEE80211_PRISM device types would do) before running wlansniff. Finally, when you use iwconfig to set an Atheros chipset 802.11a card into the monitor mode the command is this: arhontus:~# iwconfig wlan0 mode monitor After executing this command, bring up the wireless interface (ifconfig wlan0 up). A simple vt_ar5k_monitor.sh shell script to do this can be found in the vt_ar5k/misc directory. You can also enable prism2-compatible headers appending with iwpriv wlan0 prism 1 command if necessary. A few other utilities included with Linux Wireless Extensions are iwevent, iwgetid, iwlist, and iwspy. Iwevent reports changes of settings such as ESSID, channel, mode, WEP, and network ID, as well as joining new access points or ad-hoc cells, dropped transmitted packets, and the registration or unregistration of new clients if the card is run in a master mode (acts as an access point under the HostAP drivers). As such, iwevent can be useful for creating network monitoring and even intrusion detection scripts. Iwgetid is an auxiliary utility that shows current wireless network parameters such as access point (AP) MAC address, interface mode, channel, and ESSID and can be useful in scripting together with iwevent. Iwspy sets a list of host names, IPs, or MAC addresses for wireless hosts and monitors the link quality for every device on the list using /proc/net/wireless. Iwlist is another parameter-showing utility that has some very useful options including these: arhontus:~# iwlist -h Usage: iwlist [interface] frequency [interface] channel [interface] ap [interface] accesspoints [interface] bitrate [interface] rate [interface] encryption [interface] key [interface] power [interface] txpower [interface] retry [interface] scanning The iwlist frequency or channel commands demonstrate a list of frequencies supported by the selected interface and currently used frequency; for example: arhontus:~# iwlist eth1 freq eth1 14 channels in total; available frequencies: Channel 01 : 2.412 GHz Channel 02 : 2.417 GHz Channel 03 : 2.422 GHz Channel 04 : 2.427 GHz Channel 05 : 2.432 GHz Channel 06 : 2.437 GHz Channel 07 : 2.442 GHz Channel 08 : 2.447 GHz Channel 09 : 2.452 GHz Channel 10 : 2.457 GHz Channel 11 : 2.462 GHz Channel 12 : 2.467 GHz Channel 13 : 2.472 GHz Channel 14 : 2.484 GHz Current Frequency:2.412GHz (channel 01) Ensure that the interface you use supports all frequencies you might encounter in the country of operation.
The iwlist rate command lists the supported connection speed values and the current connection speed, iwlist key/enc shows the WEP keys available and lists their sizes (ensure proper iwlist and /etc/pcmcia/wireless.opts permissions), and iwlist txpower can help you find out if your card supports regulated transmitted power output: arhontus:~# iwlist eth1 txpower eth1 6 available transmit-powers: 0 dBm (1 mW) 7 dBm (5 mW) 14 dBm (20 mW) 15 dBm (30 mW) 17 dBm (50 mW) 20 dBm (100 mW) Current Tx-Power=20 dBm (100 mW) (This example is a Cisco Aironet 350 card.) The most interesting iwlist command is iwlist scan (the obsolete one is iwlist ap/accesspoint), which shows all APs and ad-hoc networks in range and even gives a variety of their settings like the signal quality. If you run HostAP in a master mode, you have to use the old iwlist ap and not iwlist scan command, although by the time this book comes out this might change. Also, iwevent has an option of showing that iwlist scan request is completed (iwlist <interface> scanning), which can come in handy in your scripting adventures. The iwlist scan option gives you an opportunity for the quick discovery of access points in range while staying connected to your AP and without putting the card into the monitor mode. We have included the fine manpages for Linux Wireless Extensions in Appendix D. Although many consider including manpages or Requests for Comments (RFCs) a waste of space, in our experience sometimes there is no substitution to printed text, and manpages make perfect bedtime reading. :) Linux-wlan-ng UtilitiesThere are multiple reasons you might want to use linux-wlan-ng drivers with a Prism chipset card. The configuration options are immense, RFMON mode can be set out of the box, and the majority of network discovery and security-related tools support linux-wlan-ng by default. In fact, the development of LINUX wireless security auditing tools has started exclusively on Prism chipset cards and wlan-ng drivers. The linux-wlan-ng utilities include wlancfg and wlanctl-ng. These tools are very powerful, but their syntax is somewhat awkward and lacks documentation. Nevertheless, linux-wlan-ng utilities syntax closely reflects 802.11 standard specifications and standard-defined SNMP MIBs, which makes playing with wlancfg and wlanctl-ng very educational. If you have trouble understanding linux-wlan-ng and its utilities, you can always consult a linux-wlan maillist at http://archives.neohapsis.com/archives/dev/linux-wlan/. Compiling linux-wlan-ng is very straightforward: arhontus:~# ./Configure -------------- Linux WLAN Configuration Script ------------- The default responses are correct for most users. Build Prism2.x PCMCIA Card Services (_cs) driver? (y/n) [y]: Build Prism2 PLX9052 based PCI (_plx) adapter driver? (y/n) [n]: Build Prism2.5 native PCI (_pci) driver? (y/n) [n]: Build Prism2.5 USB (_usb) driver? (y/n) [n]: Linux source directory [/usr/src/linux]: The kernel source tree is version 2.4.20. The current kernel build date is Thu Mar 6 22:53:57 2003. Alternate target install root directory on host []: PCMCIA script directory [/etc/pcmcia]: Module install directory [/lib/modules/2.4.20]: It looks like you have a System V init file setup. Prefix for build host compiler? (rarely needed) []: Build for debugging (see doc/config.debug) (y/n) [n]: y Configuration successful. arhontus:~# make all && make install && make clean You don't need to build the prism2_cs and p80211 modules if you already have the ones that come with your kernel. Interestingly, apart from placing wlan-ng and wlan-ng.conf files in /etc/pcmcia, linux-wlan-ng creates an additional /etc/wlan directory, which contains shared, wlan.conf and wlancfg-DEFAULT files (check them out). Some useful examples of employing wlanctl-ng include the following:
(Note: Without executing the first command the association would not take place.) In our experience, the best way to configure Prism cards running under wlan-ng drivers is using the wlancfg show <interface> command followed by wlancfg set <interface> and inputting: arhontus:~# wlancfg show wlan0 dot11StationID=00:02:6f:01:4c:49 dot11PowerManagementMode=active dot11DesiredSSID='' dot11DesiredBSSType=infrastructure dot11OperationalRateSet=02:04:0b:16 dot11AuthenticationAlgorithmsEnable1=true dot11AuthenticationAlgorithmsEnable2=false dot11PrivacyInvoked=false dot11WEPDefaultKeyID=0 dot11ExcludeUnencrypted=false dot11MACAddress=00:02:6f:01:4c:49 dot11RTSThreshold=2347 dot11FragmentationThreshold=2346 dot11Address1=00:00:00:00:00:00 .......................................................... dot11Address32=00:00:00:00:00:00 p2MMTx=false p2Comment='' p2LogEvents=false p2CnfPortType=1 p2CnfOwnMACAddress=00:02:6f:01:4c:49 p2CnfDesiredSSID='' p2CnfOwnChannel=3 p2CnfOwnSSID='non-spec' p2CnfOwnATIMWindow=0 p2CnfSystemScale=1 p2CnfMaxDataLength=2312 p2CnfWDSAddress=00:00:00:00:00:00 p2CnfPMEnabled=false p2CnfPMEPS=false p2CnfMulticastReceive=true p2CnfMaxSleepDuration=100 p2CnfPMHoldoverDuration=100 p2CnfOwnName='' p2CnfWEPDefaultKeyID=0 p2CnfWEPFlags= p2CnfAuthentication=0 p2CnfTxControl=512 p2CnfRoamingMode=1 p2CnfRcvCrcError= p2CnfAltRetryCount=7 p2CnfSTAPCFInfo=1 p2CnfTIMCtrl=0 p2CnfThirty2Tally=false p2CnfShortPreamble=long p2CnfBasicRates=0,1,2,3 p2CnfSupportedRates=0,1,2,3 p2CreateIBSS=false p2FragmentationThreshold=2346 p2RTSThreshold=2347 p2TxRateControl=0,1,2,3 p2PromiscuousMode=false p2TickTime=10 Then do wlancfg set wlan0 and cut and paste the necessary variable and its value of choice. For example, for the monitor mode do: arhontus:~# wlancfg set wlan0 p2CnfOwnChannel=6 p2CnfOwnName='31337' p2PromiscuousMode=true Ctrl-D Congratulations, you are monitoring channel 6 (okay, we admit that the p2CnfOwnName='31337' string is not really necessary). Finally, if you do need a GUI, there is a tiny utility called WlanFE (The Linux Wireless Front End) that might come in handy (Figure 4-5) and gpe-wlancfg GUI for handhelds. Figure 4.5. WlanFE graphical front end to wlancfg.However, we encourage you to use the command line for a variety of reasons, some of which are revealed later. Cisco Aironet ConfigurationAs stated before, the configuration of Cisco Aironet PCMCIA cards can be done by editing a text file created in /proc/driver/aironet/, for example: arhontus:~# cat /proc/driver/aironet/eth1/Config Mode: ESS Radio: on NodeName: PowerMode: CAM DataRates: 2 4 11 22 0 0 0 0 Channel: 6 XmitPower: 100 LongRetryLimit: 16 ShortRetryLimit: 16 RTSThreshold: 2312 TXMSDULifetime: 5000 RXMSDULifetime: 10000 TXDiversity: both RXDiversity: both FragThreshold: 2312 WEP: open Modulation: cck Preamble: short Simply open your text editor of choice (shame on you if it isn't vi or emacs!) and change the needed parameters. To put the card into the RFMON mode, change the top Mode: ESS line to Mode: yna (any) bss rfmon; this will take care of the ESSID, too. Changing the transmission power to the minimal 1 mW value is also a good idea, so change XmitPower: 100 to XmitPower: 1. You can also echo to the configuration file from your console; for example: arhontus:~# echo "Mode: rfmon" > /proc/driver/aironet/eth1/Config or arhontus:# echo "Mode: r" > /proc/driver/aironet/eth1/Config arhontus:# echo "Mode: y" > /proc/driver/aironet/eth1/Config then arhontus:# echo "XmitPower: 1" > /proc/driver/aironet/eth1/Config If you run iwconfig you can see that with the Cisco Aironet cards there are two wireless interfaces instead of the usual one: eth1 IEEE 802.11-DS ESSID:"Arhont-X" Mode:Managed Frequency:2.412GHz Access Point: 00:02:2D:4E:EA:0D Bit Rate:11Mb/s Tx-Power=0 dBm Sensitivity=0/65535 Retry limit:16 RTS thr:off Fragment thr:off Encryption key:off Power Management:off Link Quality:59/10 Signal level:-90 dBm Noise level:-256 dBm Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:0 Invalid misc:58 Missed beacon:6 wifi0 IEEE 802.11-DS ESSID:"Arh0not-X" Mode:Managed Frequency:2.412GHz Access Point: 00:02:2D:4E:EA:0D Bit Rate:11Mb/s Tx-Power=0 dBm Sensitivity=0/65535 Retry limit:16 RTS thr:off Fragment thr:off Encryption key:off Power Management:off Link Quality:59/10 Signal level:-90 dBm Noise level:-256 dBm Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:0 Invalid misc:58 Missed beacon:6 The wifiX interface is used to direct the captured traffic in RFMON mode, not the ethX. This is important to remember when running your sniffer. When you switch from the monitoring mode to association with the network, we recommend you restart the pcmcia-cs services. Then you will have to use iwconfig or the Cisco-supplied ACU GUI to set all necessary parameters and associate. The ACU is highly intuitive (Figure 4-6) and has excellent status and statistic reporting interfaces (Figures 4-7 and 4-8). As such, it can be used as a good site surveying tool. Figure 4.6. ACU graphical interface to Cisco cards.Figure 4.7. ACU graphical interface to Cisco cards.Figure 4.8. ACU graphical interface to Cisco cards.Configuring Wireless Client Cards on BSD SystemsThe configuration utilities that remain to be covered are ifconfig, wicontrol, and ancontrol on BSD operational systems. The manual pages for these utilities are included in Appendix D and there is not a lot we can add to them. Of course, you are interested in setting your card into a monitor mode. If you have a Prism chipset card, you cannot put it into the monitor mode with ifconfig (FreeBSD) or wicontrol. Instead use the prism2ctl tool from BSD-airtools: arhontus:~# prism2ctl wi0 -m If the card is Cisco Aironet and you use FreeBSD 5.0 or later, an supports the monitor mode with the -M switch: arhontus:~# ancontrol -i <interface> -M 0-15 Set monitor mode via bit mask, meaning:
Note: it appears that an SSID must be set. It is worth mentioning that with older versions of Ethereal, bit mask 8 might be necessary. This is an example of setting a Cisco Aironet card into the monitor mode: arhontus:~# ancontrol -i wi0 -M 1 -p 1 where -p 1 sets the transmitting power to 1 mW (battery life preservation). If you are very conservative and use older BSD versions, you'll have to apply the an.rfmon patch (see http://www.ambrisko.com/doug/an/old/) to implement the -M switch. |
< Day Day Up > |