Last active
February 2, 2017 09:02
-
-
Save ankitshekhawat/35b7ccfa3519f2c4179e867585a6d8e8 to your computer and use it in GitHub Desktop.
A simple python wifi scanner for OSX using OSX's airport command line utility. Returns Mac Addresses and RSSI
This file contains 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
from subprocess import check_output | |
import re | |
def scan_networks(): | |
airport = '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -s' | |
rc = check_output(airport, shell=True).split('\n')[1:-1] | |
networks =[] | |
for i in rc: | |
i = i.lstrip().rstrip() | |
mac = re.search(r'([0-9A-F]{2}[:-]){5}([0-9A-F]{2})', i, re.I).group() | |
rssi = re.search(r'\-(\d)\w+', i, re.I).group() | |
networks.append([mac, int(rssi)]) | |
return networks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With additional regex SSID, channel and security etc. can also be extracted