Skip to content

Commit

Permalink
Basic macOS support
Browse files Browse the repository at this point in the history
  • Loading branch information
calebmadrigal committed Apr 30, 2018
1 parent ad28b52 commit 0aab5a6
Show file tree
Hide file tree
Showing 7 changed files with 334 additions and 12 deletions.
8 changes: 6 additions & 2 deletions README.md
Expand Up @@ -8,7 +8,7 @@ PyPI page: https://pypi.python.org/pypi/trackerjacker

pip3 install trackerjacker

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

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

Expand Down Expand Up @@ -296,7 +296,11 @@ Note that trackerjacker will automatically switch channels as necessary during n
- [x] Plugin system
- [x] Fox hunt mode
- [x] Tracking by SSID (and not just BSSID)
- [ ] macOS (OS X) support (under active development)
- [x] Basic macOS (OS X) support (pre-alpha)
- [ ] macOS support: reverse airport binary to determine how to set true monitor mode
- [ ] macOS support: diverse interface support (not just `en0`)
- [ ] macOS support: get interface supported channels
- [ ] macOS support: get signal strength values correct
- [ ] Mapping a specific SSID
- [ ] Performance enhancement: not shelling out for channel switching
- [ ] "Jack" mode - deauth attacks
Expand Down
20 changes: 15 additions & 5 deletions trackerjacker/__main__.py
Expand Up @@ -8,21 +8,25 @@
import errno
import pprint
import logging
import inspect
import platform
import traceback

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

from . import config_management
from . import device_management
from . import dot11_frame
from . import dot11_mapper
from . import dot11_tracker
from . import plugin_parser
from . import ieee_mac_vendor_db
from .common import TJException

if platform.system() == 'Linux':
from . import linux_device_management as device_management
elif platform.system() == 'Darwin':
from . import macos_device_management as device_management

LOG_NAME_TO_LEVEL = {'DEBUG': 10, 'INFO': 20, 'WARNING': 30, 'ERROR': 40, 'CRITICAL': 50}


Expand Down Expand Up @@ -200,14 +204,20 @@ def start(self):
self.iface_manager.start()
while True:
try:
if 'exceptions' in inspect.signature(scapy.sniff).parameters:
scapy.sniff(iface=self.iface_manager.iface, prn=self.process_packet, store=0, exceptions=True)
# macOS
if platform.system() == 'Darwin':
self.logger.warning('trackerjacker macOS support is pre-alpha - most functionality is linux-only')
scapy.sniff(iface=self.iface_manager.iface, monitor=True, prn=self.process_packet, store=0)
break
# linux
else:
# For versions of scapy that don't provide the exceptions kwarg
scapy.sniff(iface=self.iface_manager.iface, prn=self.process_packet, store=0)
break
except (IOError, OSError):

except TJException:
raise
except (OSError, IOError):
self.logger.error(traceback.format_exc())
self.logger.info('Sniffer error occurred. Restarting sniffer in 3 seconds...')
time.sleep(3)
Expand Down
9 changes: 7 additions & 2 deletions trackerjacker/dot11_frame.py
@@ -1,6 +1,6 @@
"""Provides nice interface for Dot11 Frames"""

# pylint: disable=R0902
# pylint: disable=R0902, C0413, W0703

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

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

if frame.haslayer(scapy.RadioTap):
try:
Expand Down
7 changes: 5 additions & 2 deletions trackerjacker/dot11_tracker.py
Expand Up @@ -286,8 +286,11 @@ def do_trigger_alert(self,
raise TJException('Error occurred in trigger plugin: {}'.format(traceback.format_exc()))

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

else:
if num_bytes:
Expand Down
File renamed without changes.

0 comments on commit 0aab5a6

Please sign in to comment.