Skip to content

Commit 0aab5a6

Browse files
committed
Basic macOS support
1 parent ad28b52 commit 0aab5a6

File tree

7 files changed

+334
-12
lines changed

7 files changed

+334
-12
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ PyPI page: https://pypi.python.org/pypi/trackerjacker
88

99
pip3 install trackerjacker
1010

11-
**Linux-only** at this time (tested on Ubuntu, Kali, and RPi).
11+
*Supported platforms*: Linux (tested on Ubuntu, Kali, and RPi) and macOS (pre-alpha)
1212

1313
![visual description](https://i.imgur.com/I5NH5KM.jpg)
1414

@@ -296,7 +296,11 @@ Note that trackerjacker will automatically switch channels as necessary during n
296296
- [x] Plugin system
297297
- [x] Fox hunt mode
298298
- [x] Tracking by SSID (and not just BSSID)
299-
- [ ] macOS (OS X) support (under active development)
299+
- [x] Basic macOS (OS X) support (pre-alpha)
300+
- [ ] macOS support: reverse airport binary to determine how to set true monitor mode
301+
- [ ] macOS support: diverse interface support (not just `en0`)
302+
- [ ] macOS support: get interface supported channels
303+
- [ ] macOS support: get signal strength values correct
300304
- [ ] Mapping a specific SSID
301305
- [ ] Performance enhancement: not shelling out for channel switching
302306
- [ ] "Jack" mode - deauth attacks

trackerjacker/__main__.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,25 @@
88
import errno
99
import pprint
1010
import logging
11-
import inspect
11+
import platform
1212
import traceback
1313

1414
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
1515
import scapy.all as scapy
1616

1717
from . import config_management
18-
from . import device_management
1918
from . import dot11_frame
2019
from . import dot11_mapper
2120
from . import dot11_tracker
2221
from . import plugin_parser
2322
from . import ieee_mac_vendor_db
2423
from .common import TJException
2524

25+
if platform.system() == 'Linux':
26+
from . import linux_device_management as device_management
27+
elif platform.system() == 'Darwin':
28+
from . import macos_device_management as device_management
29+
2630
LOG_NAME_TO_LEVEL = {'DEBUG': 10, 'INFO': 20, 'WARNING': 30, 'ERROR': 40, 'CRITICAL': 50}
2731

2832

@@ -200,14 +204,20 @@ def start(self):
200204
self.iface_manager.start()
201205
while True:
202206
try:
203-
if 'exceptions' in inspect.signature(scapy.sniff).parameters:
204-
scapy.sniff(iface=self.iface_manager.iface, prn=self.process_packet, store=0, exceptions=True)
207+
# macOS
208+
if platform.system() == 'Darwin':
209+
self.logger.warning('trackerjacker macOS support is pre-alpha - most functionality is linux-only')
210+
scapy.sniff(iface=self.iface_manager.iface, monitor=True, prn=self.process_packet, store=0)
205211
break
212+
# linux
206213
else:
207214
# For versions of scapy that don't provide the exceptions kwarg
208215
scapy.sniff(iface=self.iface_manager.iface, prn=self.process_packet, store=0)
209216
break
210-
except (IOError, OSError):
217+
218+
except TJException:
219+
raise
220+
except (OSError, IOError):
211221
self.logger.error(traceback.format_exc())
212222
self.logger.info('Sniffer error occurred. Restarting sniffer in 3 seconds...')
213223
time.sleep(3)

trackerjacker/dot11_frame.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Provides nice interface for Dot11 Frames"""
22

3-
# pylint: disable=R0902
3+
# pylint: disable=R0902, C0413, W0703
44

55
import logging
66
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
@@ -51,7 +51,12 @@ def __init__(self, frame, channel=0, iface=None):
5151
if (frame.haslayer(scapy.Dot11Elt) and
5252
(frame.haslayer(scapy.Dot11Beacon) or frame.haslayer(scapy.Dot11ProbeResp))):
5353

54-
self.ssid = frame[scapy.Dot11Elt].info.decode().replace('\x00', '[NULL]')
54+
try:
55+
self.ssid = frame[scapy.Dot11Elt].info.decode().replace('\x00', '[NULL]')
56+
except UnicodeDecodeError:
57+
# Only seems to happen on macOS - probably some pcap decoding bug
58+
self.ssid = None
59+
#print('Error decoding ssid: {}'.format(frame[scapy.Dot11Elt].info))
5560

5661
if frame.haslayer(scapy.RadioTap):
5762
try:

trackerjacker/dot11_tracker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,11 @@ def do_trigger_alert(self,
286286
raise TJException('Error occurred in trigger plugin: {}'.format(traceback.format_exc()))
287287

288288
elif self.trigger_command:
289-
# Start trigger_command in background process - fire and forget
290-
subprocess.Popen(self.trigger_command)
289+
try:
290+
# Start trigger_command in background process - fire and forget
291+
subprocess.Popen(self.trigger_command)
292+
except Exception:
293+
raise TJException('Error occurred in trigger command: {}'.format(traceback.format_exc()))
291294

292295
else:
293296
if num_bytes:

0 commit comments

Comments
 (0)