Skip to content

CoreLocation, netsh, nmcli: scan Wifi from Python on Windows, MacOS, Linux

License

Notifications You must be signed in to change notification settings

scivision/scan-wifi-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scan WiFi from Python

ci PyPI Download stats

This project shows how to scan WiFi from Python using command line tools or pyobjc (macOS).

Scapy dot11 is an alternative, more robust cross-platform way to scan WiFi than demonstrated here.

Discontinuation of Mozilla Location Services API. is sad as it worked so well!

This project can be used as a reference for simply accessing WiFi information from Python without using Scapy.

A future direction might be to use Google Geolocation API


Uses command line access to WiFi information from Python. The command line programs used to access WiFi information include:

Install

Get latest release

pip install mozloc

or for latest development version:

git clone /~https://github.com/scivision/mozilla-location-wifi/
pip install -e ./mozilla-location-wifi

Usage

python -m mozloc

Shows time lat lng accuracy N BSSIDs heard.

When Mozilla Location Services were available, accuracy better than 100 meters was possible.

Dump raw signals, without using API:

python -m mozloc --dump

macOS

macOS ≥ 14.4 uses CoreLocation.CWWiFiClient as "airport" was removed.

Windows

On Windows, NetSH is used. You may need to disconnect from WiFi (leave WiFi enabled) to make your WiFi chipset scan and be able to get location.

convert to KML

Display logged data in Google Earth or other KML viewer after converting from CSV to KML:

python -m mozloc.csv2kml in.log out.kml

which uses

pip install simplekml

Note that your time MUST be in ISO 8601 format or some KML reading programs such as Google Earth will just show a blank file. E.g.

2016-07-24T12:34:56

TODO

  • Would like to add Bluetooth beacons.
  • Need to use a new location service.

Notes

To print verbose information about nearby WiFi:

  • Windows: netsh wlan show networks mode=bssid
  • MacOS: airport -s
  • Linux: nmcli dev wifi list