Created
October 4, 2016 22:16
-
-
Save kylemcdonald/19e57200db2dcbb9d080d73b7adac815 to your computer and use it in GitHub Desktop.
Wireless sniffing on OS X with channel hopping.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
duration=$1 | |
sudo chmod o+r /dev/bpf* | |
echo "> Enabled sniffing on all interfaces." | |
networksetup -listallhardwareports | |
device=`networksetup -listallhardwareports | grep -A1 'Wi-Fi' | grep 'Device' | cut -d':' -f2 | xargs` | |
echo "> Using device $device." | |
networksetup -setairportpower $device on | |
echo "> Enabled power on device $device." | |
airport="/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport" | |
if [ -e $airport ]; then echo "Airport is available."; else echo "Airport is not available."; fi | |
sudo $airport -z | |
echo "> Dissociating from current wireless network." | |
echo "> Generating filename." | |
randhex=`cat /dev/urandom | env LC_CTYPE=C tr -dc '0-9A-F' | fold -w 6 | head -n 1` | |
filename="dump-$duration-$randhex.pcap" | |
echo "> Using filename $filename." | |
sudo tcpdump -i $device -I -s 0 -B 524288 -w $filename & | |
echo "> Started capture with tcpdump for $duration minute(s)." | |
sleep 1 | |
for i in `seq 1 $duration` | |
do | |
echo "> Hopping through 36 channels ($i/$duration)" | |
for channel in 1 2 3 4 5 6 7 8 9 10 11 36 40 44 48 52 56 60 64 100 104 108 112 116 120 124 128 132 136 140 144 149 153 157 161 165 | |
do | |
echo -n "$channel " | |
sudo $airport --channel=$channel | |
sleep 1.667 # 36 channels in 60 seconds | |
done | |
echo "" | |
done | |
echo "> Done looping stopping sniffing." | |
sudo killall tcpdump | |
echo "> Done sniffing. Resetting airport." | |
networksetup -setairportpower $device off | |
networksetup -setairportpower $device on | |
echo "> Airport reset." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment