In the article Basic WPA cracking, we learned to crack a basic WPA network. But how do we actually use it ?
Most networks will have enabled DHCP, and in that case, it's simple, but what if it haven't got DHCP ?
That is the topic in this little tutorial, so let's go have some more fun with Wifi..
As I said in the intro, most networks have DHCP enabled. It's a service in the router, that configures the IP, netmask and gateway automatically, so it's the perfect tool for lazy admins, and homeowners alike.
But, what if there isn't a DHCP server running, or we need something special ? Maybe it could be nice to know how to configure the network in the hand. So, let's get going.
The first thing we need to make sure of, is NetworkManager not bothering us, so we''ll stop it.
service NetworkManager stop
Next, let's check DNS settings. They are in the /etc/resolv.conf file. So cat that. If it's empty, write a couple of servers in it. I like using Googles, but OpenDNS is also an option. Google's are 8.8.8.8 and 8.8.4.4, and OpenDNS is 208.67.222.222 and 208.67.220.220.
#write DNS servers into /etc/resolv.conf
echo "nameserver 8.8.8.8" > /etc/resolv.conf
echo "nameserver 8.8.4.4" >> /etc/resolv.conf
That takes care of DNS, moving on to configuring the network WIFI settings. We do that using wpa_passphrase and wpa_supplicant.
wpa_passphrase <networkname> <passphrase> > /etc/network/networkname.lan
The above command is for setting up the network config file for wpa_supplicant, and write it to a config file, so we have the settings later on. The next step, is setting up the network card, and then connect to the network. We do that with ifconfig.
#setup network card
ifconfig wlan0 up
ifconfig wlan0 192.168.0.18 netmask 255.255.255.0
Here i set mine up with 192.168.0.18, and netmask 255.255.255.0, as that's a good choice for my network. Your's will be different, or maybe not, depending on your network settings and IP address range, and router address.
Next, we connect to the network. Open up a terminal, and call wpa_supplicant with the config file you made under /etc/network.
wpa_supplicant -i wlan0 -c /etc/network/network_name.lan
It should be kept running for as long as you want to be connected to the network. Next, we see if we can ping the network router, and Google DNS servers.
# Ping router (if 192.168.0.1 is the router)
ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=6.77 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=0.817 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=0.827 ms
64 bytes from 192.168.0.1: icmp_seq=4 ttl=64 time=0.789 ms
^C
--- 192.168.0.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3037ms
rtt min/avg/max/mdev = 0.789/2.301/6.771/2.580 ms
#Ping Google
ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=56 time=22.2 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=56 time=22.1 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=56 time=22.7 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=56 time=23.7 ms
^C
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 22.058/22.657/23.673/0.633 ms
If it works, you should get a response like mine. If you do, we can continue and try pinging on the domain name instead. Simply ping www.google.com and see if you get a response. If not, you might need to set the default route. You can do that with the command route, like so.
#Format of adding default gateway is "route add default gw gateway_ip"
route add default gw 192.168.0.1
#If 192.168.0.1 is the default gateway.
Try pinging Google again, and see if DNS resolution is working. If you get a response, you're done. Try opening a browser next, and see if you can go online, and see a webpage :)
Happy surfing :)