Mac For Hackers: How To Set Up A MacOS System For Wi-Fi Packet Capturing Null Byte :: WonderHowTo
Mac For Hackers: How To Set Up A MacOS System For Wi-Fi Packet Capturing Null Byte :: WonderHowTo
M AC FO R H AC K E R S
M acOS isn't known as an ideal operating system for hacking without customization, but it includes
native tools that allow easy control of the Wi-Fi radio for packet sniffing. Changing channels, scanning
for access points, and even capturing packets all can be done from the command line. We'll use aliasing
to set some simple commands for easy native packet capture on a macOS system.
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s
That command isn't exactly easy to remember, so instead, we can shorten them dramatically by
mapping the most useful commands for Wi-Fi scanning and sniffing to shorter, more memorable ones. Of
the available commands, the most important are scanning the current connection for available detail,
scanning for nearby access points, switching the current Wi-Fi channel, and beginning a packet capture
session.
Don't Miss: Use Kismet to Watch Wi-Fi User Activity Through Walls
By changing some settings in Wireshark, you can begin to see all of the traffic on a particular channel,
but this still doesn't give you the ability to sniff on channels on which you have no network to join. To
solve this, we'll need to use a macOS tool to set the channel manually so that we can switch between
channels of interest based on the result of a scan of nearby APs.
Step 1
Create an Alias
First, to create an alias, we'll be editing our terminal Bash profile; This will allow us to map lengthy or
more complicated commands we frequently use to smaller commands. To do this, open a new terminal
window and type the following.
nano .bash_profile
That command will open up a text file that should say something like this:
Beneath that, you can begin to add aliases. So how do they work? The anatomy of a Bash alias looks
like this:
alias (NameOfAlias)='(TheCommandsYouWantTheAliasToRun)'
Using that format, let's write and text our first alias.
Don't Miss: Wardrive with the Kali Raspberry Pi to Map Wi-Fi Devices
All of this information is handy for targeting nearby networks or deciding which channel to sniff on. To
do this scan, we need to type the following command into a terminal window.
sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airpo
I prefer to shorten this to an alias I've named scanarea for quick access. To create this alias, type nano
.bash_profile and then add the following code at the bottom of the text document.
alias scanarea='sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current
Press Ctrl-X to close out of the text file, typing Y to save the changes when prompted. To test the alias,
quit your terminal program and reopen it again. After restarting your terminal window, you should now
be able to see the alias there by typing alias into a terminal window.
Now, you should be able to type scanarea into a terminal window, enter your password, and see a list
of all nearby Wi-Fi networks.
Reopen the Bash profile and add the following code to also be able to display what channel the card is
currently set to, as well as information about the AP you're currently connected to.
After again saving and closing the file, you should be able to open a fresh terminal window, and after
restarting terminal, type "currentap
currentap" to learn information about the current link status of your
computer.
currentap
agrCtlRSSI: 0
agrExtRSSI: 0
agrCtlNoise: 0
agrExtNoise: 0
state: init
op mode:
lastTxRate: 0
maxRate: 0
lastAssocStatus: 16
802.11 auth: open
link auth: none
BSSID: 0:0:0:0:0:0
SSID:
MCS: -1
channel: 4
Dell-2:~ skickar$ currentap
agrCtlRSSI: -56
agrExtRSSI: 0
agrCtlNoise: -93
agrExtNoise: 0
state: running
op mode: station
lastTxRate: 130
maxRate: 144
lastAssocStatus: 0
802.11 auth: open
link auth: none
BSSID: fc:a:81:78:40:90
SSID: Caesars_Resorts
MCS: 15
channel: 149
Step 2
This command can't have any spaces in it, so we need to create a new alias for each channel that we
want our Wi-Fi card to be able to switch to.
Save this alias withCtrl-X and then agree to save by typing Y . Quit your terminal session, and reopen it
to see the command available by typing alias into a fresh terminal window. While this command is the
most useful, it is also one that is likely to need to be run more than once.
Don't Miss: Spy on Your 'Buddy 's' Network Traffic with Wireshark
To make sure this command works, disconnect from any access point you are currently connected to.
You may need to "forget" nearby networks in order to do so, by going into your advanced network
settings. Once you are disconnected from any AP and with the Wi-Fi card turned on, try to set the
channel to channel 4 by typing setchannelto4 in a terminal window. Then, run currentap to find
which channel you're on.
setchannelto4
currentap
agrCtlRSSI: 0
agrExtRSSI: 0
agrCtlNoise: 0
agrExtNoise: 0
state: init
op mode:
lastTxRate: 0
maxRate: 0
lastAssocStatus: 16
802.11 auth: open
link auth: none
BSSID: 0:0:0:0:0:0
SSID:
MCS: -1
channel: 4
If it's not on the right AP, turn your Wi-Fi card off and back on again, then run the command again. You
may need to do this a few times, as macOS will tend to ignore this if it thinks it can connect to an AP in
range.
If you're running Wireshark, you should be able to see packets all start coming in on the same channel;
This means that you've successfully switched the wireless card to the desired channel.
Step 3
Running this command will begin saving all observed packets to a .cap file, which you can open in
Wireshark later to interpret. Once the alias is set and you've saved and closed the file, quit terminal, and
reopened it to make the alias available for use.
sniff
Capturing 802.11 frames on en0.
Session saved to /tmp/airportSniffuwvwnx.cap.
Step 4
wireshark -r /tmp/yourfilename.cap
This will open the capture in Wireshark, allowing you to confirm you got the capture you needed and
inspect the intercepted packets.
Utilizing aliasing makes the built-in commands shorter and more memorable, allowing a hacker to create
an easy workflow for discovering, tuning to, and capturing traffic from networks of interest. Using these
tactics, a macOS computer near your target is everything you need to spy on local Wi-Fi
communications.
I hope you enjoyed this guide to configuring an Apple computer to control the wireless card and sniff
Wi-Fi packets! If you have any questions about this guide on working with macOS or you have a
comment, feel free to reach me below or on Twitter @KodyKinzie.
Don't Miss: The Everyman's Guide to How Network Packets Are Routed Across the Web