-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwlan_darwin.py
36 lines (25 loc) · 1.29 KB
/
wlan_darwin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
"""Via https://github.com/allfro/sploitego/blob/master/src/sploitego/webtools/geolocate.py"""
from log import log
AIRBEARS = "AirBears"
from Foundation import NSBundle, objc
CoreWLANBundle = NSBundle.bundleWithPath_(objc.pathForFramework('/System/Library/Frameworks/CoreWLAN.framework'))
if CoreWLANBundle is None:
raise SystemError("Unable to load wireless bundle. Maybe it's not supported?") # CoreWLAN is 10.6+ only
CoreWLANBundle.load()
def has_airbears():
connected = get_connected_wireless()
if connected is None:
return False
log("Active connected network: " + connected)
return AIRBEARS == connected
def get_connected_wireless(): # I _think_ I might have to call [CWInterface interface] every time...
CWInterface = CoreWLANBundle.classNamed_('CWInterface')
if CWInterface is None:
raise SystemError('Unable to load CWInterface.') # Possibly < 10.6?
# We really should be calling interfaceNames() and then calling interfaceWithName(name) on each one.
default_interface = CWInterface.interface()
if default_interface is None or not default_interface:
# raise SystemError('Unable to load wireless interface.') # If it's not there, don't complain
return ""
return default_interface._.ssid