Saturday, March 27, 2010

Backtrack 4 WPA

I've been messing around with Backtrack 4 for a few weeks now. The biggest thing that initially caused the most frustration is the ease of wireless in Backtrack...or, more accurately, the lack thereof. It took me a good hour or two to figure out exactly how to connect my machine to my wireless network. I didn't find any thorough tutorials on the subject, so here it is.

My environment consists of a Cisco 1242AG, using WPA-PSK. The SSID for my network is...well, the SSID of the sample I'm using here is SAMPLESSID. ;)

The password is going to be SAMPLEPASS.

So, first off, you need to enable the interface. Run iwconfig to figure out which of your interfaces is the wireless one. This was necessary in my case because the wireless NIC showed up as an eth interface, not a wlan interface.

root@bt:~# iwconfig
lo no wireless extensions.

eth0 no wireless extensions.

eth1 unassociated ESSID:off/any
Mode:Managed Channel=0 Access Point: Not-Associated
Bit Rate:0 kb/s Tx-Power=20 dBm Sensitivity=8/0
Retry limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0

So, knowing now that eth1 is my wireless interface, I bring it up using the following:

root@bt:~# ifconfig eth1 up

Now that the interface is up and running, you need to run wpa_supplicant to make everything work.  Before that, however, you need to create a config file to use. 

Do the following:

root@bt:~# vim wpa_supplicant.conf

network={
ssid="SAMPLESSID"
key_mgmt=WPA-PSK
psk="SAMPLEPASS"
}
 
When this is done, you need to run wpa_supplicant using the following command:
 
root@bt:~# wpa_supplicant -B -i eth1 -c wpa_supplicant.conf
 
The -B switch makes wpa_supplicant run in the background, so if you close your terminal you won't lose the functionality.  -i specifies the interface you found above.  In my case, I have to use eth1.  Finally, -c specifies the configuration file.  If you saved that config file to your home directory and run wpa_supplicant from that same location, it'll just work. 
 
Almost done!

After running wpa_supplicant, your computer should be authenticated to the network.  Your final step is to run the following:
 
root@bt:~# dhclient
 
dhclient is the utility used to configure your interfaces using DHCP.  You could also manually set your IP, Subnet, GW and DNS; if that's what you do, you will not need to run dhclient.
 
The output should look something like this:
 
root@bt:~# dhclient
Internet Systems Consortium DHCP Client V3.1.1

Copyright 2004-2008 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/

Listening on LPF/eth1/00:54:fd:1d:93:a4
Sending on LPF/eth1/00:32:ae:1d:73:84
Listening on LPF/eth0/00:c4:a9:d9:ba:d1
Sending on LPF/eth0/00:c4:a9:d7:ba:d1
Sending on Socket/fallback
DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 7
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 6
DHCPOFFER of 192.168.1.40 from 192.168.0.1
DHCPREQUEST of 192.168.1.40 on eth1 to 255.255.255.255 port 67
DHCPACK of 192.168.1.40 from 192.168.0.1
bound to 192.168.1.40 -- renewal in 40829 seconds.
root@bt:~#
 
You're all done.  Verify network connectivity by:
 
root@bt:~# ping 4.2.2.1

PING 4.2.2.1 (4.2.2.1) 56(84) bytes of data.
64 bytes from 4.2.2.1: icmp_seq=1 ttl=59 time=21.2 ms
64 bytes from 4.2.2.1: icmp_seq=2 ttl=59 time=12.1 ms
64 bytes from 4.2.2.1: icmp_seq=3 ttl=59 time=11.5 ms
64 bytes from 4.2.2.1: icmp_seq=4 ttl=59 time=11.7 ms
64 bytes from 4.2.2.1: icmp_seq=5 ttl=59 time=12.3 ms
^C
--- 4.2.2.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 11.561/13.828/21.253/3.723 ms
root@bt:~#

No comments: