trackerjacker 2.0.4__tar.gz → 2.0.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. trackerjacker-2.0.6/PKG-INFO +350 -0
  2. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/README.md +2 -6
  3. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/requirements.txt +1 -1
  4. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/setup.cfg +1 -1
  5. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/setup.py +5 -3
  6. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker/__main__.py +74 -61
  7. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker/dot11_tracker.py +4 -3
  8. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker/oui.txt +12151 -8045
  9. trackerjacker-2.0.6/trackerjacker/version.py +1 -0
  10. trackerjacker-2.0.6/trackerjacker.egg-info/PKG-INFO +350 -0
  11. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker.egg-info/entry_points.txt +0 -1
  12. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker.egg-info/requires.txt +1 -1
  13. trackerjacker-2.0.4/PKG-INFO +0 -428
  14. trackerjacker-2.0.4/trackerjacker/version.py +0 -1
  15. trackerjacker-2.0.4/trackerjacker.egg-info/PKG-INFO +0 -428
  16. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/LICENSE +0 -0
  17. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/MANIFEST.in +0 -0
  18. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/tests/test_config_management.py +0 -0
  19. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/tests/test_dot11map.py +0 -0
  20. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/tests/test_macvendordb.py +0 -0
  21. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker/__init__.py +0 -0
  22. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker/common.py +0 -0
  23. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker/config_management.py +0 -0
  24. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker/dot11_frame.py +0 -0
  25. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker/dot11_mapper.py +0 -0
  26. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker/ieee_mac_vendor_db.py +0 -0
  27. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker/linux_device_management.py +0 -0
  28. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker/macos_device_management.py +0 -0
  29. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker/plugin_parser.py +0 -0
  30. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker/plugins/__init__.py +0 -0
  31. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker/plugins/foxhunt.py +0 -0
  32. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker.egg-info/SOURCES.txt +0 -0
  33. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker.egg-info/dependency_links.txt +0 -0
  34. {trackerjacker-2.0.4 → trackerjacker-2.0.6}/trackerjacker.egg-info/top_level.txt +0 -0
@@ -0,0 +1,350 @@
1
+ Metadata-Version: 2.4
2
+ Name: trackerjacker
3
+ Version: 2.0.6
4
+ Summary: Finds and tracks wifi devices through raw 802.11 monitoring
5
+ Home-page: https://github.com/calebmadrigal/trackerjacker
6
+ Author: Caleb Madrigal
7
+ Author-email: caleb@gods.art
8
+ License: MIT
9
+ Keywords: hacking,network,wireless,packets,scapy
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.2
13
+ Classifier: Programming Language :: Python :: 3.3
14
+ Classifier: Programming Language :: Python :: 3.4
15
+ Classifier: Programming Language :: Python :: 3.5
16
+ Classifier: Programming Language :: Python :: 3.6
17
+ Classifier: Programming Language :: Python :: 3.7
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3.14
25
+ Classifier: Programming Language :: Python :: 3.15
26
+ Classifier: Programming Language :: Python :: Implementation :: CPython
27
+ Classifier: Topic :: System :: Networking
28
+ Classifier: Topic :: System :: Networking :: Monitoring
29
+ Classifier: Topic :: Security
30
+ Classifier: Operating System :: POSIX :: Linux
31
+ Description-Content-Type: text/markdown
32
+ License-File: LICENSE
33
+ Requires-Dist: scapy>=2.5.0
34
+ Requires-Dist: pyaml>=17.12.1
35
+ Requires-Dist: ruamel.yaml>=0.15.35
36
+ Dynamic: author
37
+ Dynamic: author-email
38
+ Dynamic: classifier
39
+ Dynamic: description
40
+ Dynamic: description-content-type
41
+ Dynamic: home-page
42
+ Dynamic: keywords
43
+ Dynamic: license
44
+ Dynamic: license-file
45
+ Dynamic: requires-dist
46
+ Dynamic: summary
47
+
48
+ # trackerjacker
49
+
50
+ Like nmap for mapping wifi networks you're not connected to. Maps and tracks wifi networks and devices through raw 802.11 monitoring.
51
+
52
+ PyPI page: https://pypi.python.org/pypi/trackerjacker
53
+
54
+ #### Install
55
+
56
+ pip3 install trackerjacker
57
+
58
+ *Supported platforms*: Linux (tested on Ubuntu, Kali, and RPi) and macOS (pre-alpha)
59
+
60
+ ![visual description](https://i.imgur.com/I5NH5KM.jpg)
61
+
62
+ trackerjacker can help with the following:
63
+
64
+ * I want to know all the nearby wifi networks **and know all the devices connected to each network.**
65
+ * I want to know who's hogging all the bandwidth.
66
+ * I want to run a command when this MAC address sends more than 100000 bytes in a 30 second window (maybe to determine when an IP camera is uploading a video, which is indicative that it just saw motion).
67
+ * I want to deauth anyone who uses more than 100000 bytes in a 10 second window.
68
+ * I want to deauth every Dropcam in the area so my Airbnb hosts don't spy on me.
69
+ * I want to be alerted when any MAC address is seen at a power level greater than -40dBm that I've never seen before.
70
+ * I want to see when this particular person is nearby (based on the MAC of their mobile phone) and run a command to alert me.
71
+ * I want to write my own plugin to run some script to do something fun every time a new Apple device shows up nearby.
72
+
73
+ ## Usage
74
+
75
+ Find detailed usage like this:
76
+
77
+ trackerjacker -h
78
+
79
+ There are 2 major usage modes for `trackerjacker`: **map** mode and **track** mode:
80
+
81
+ ### Map mode example
82
+
83
+ Map command:
84
+
85
+ trackerjacker -i wlan1337 --map
86
+
87
+ By default, this outputs the `wifi_map.yaml` YAML file, which is a map of all the nearby WiFi networks and all of their users. Here's an example `wifi_map.yaml` file:
88
+
89
+ TEST_SSID:
90
+ 00:10:18:6b:7a:ea:
91
+ bssid: 00:10:18:6b:7a:ea
92
+ bytes: 5430
93
+ channels:
94
+ - 11
95
+ devices:
96
+ 3c:07:71:15:f1:48:
97
+ bytes: 798
98
+ signal: 1
99
+ vendor: Sony Corporation
100
+ 78:31:c1:7f:25:43:
101
+ bytes: 4632
102
+ signal: -52
103
+ vendor: Apple, Inc.
104
+ signal: -86
105
+ ssid: TEST_SSID
106
+ vendor: Broadcom
107
+
108
+ BRANSONS_WIFI:
109
+ 90:48:9a:e3:58:25:
110
+ bssid: 90:48:9a:e3:58:25
111
+ bytes: 5073
112
+ channels:
113
+ - 1
114
+ devices:
115
+ 01:00:5e:96:e1:89:
116
+ bytes: 476
117
+ signal: -62
118
+ vendor: ''
119
+ 30:8c:fb:66:23:91:
120
+ bytes: 278
121
+ signal: -46
122
+ vendor: Dropcam
123
+ 34:23:ba:1c:ba:e7:
124
+ bytes: 548
125
+ signal: 4
126
+ vendor: SAMSUNG ELECTRO-MECHANICS(THAILAND)
127
+ signal: -80
128
+ ssid: BRANSONS_WIFI
129
+ vendor: Hon Hai Precision Ind. Co.,Ltd.
130
+
131
+ hacker_network:
132
+ 80:2a:a8:e5:de:92:
133
+ bssid: 80:2a:a8:e5:de:92
134
+ bytes: 5895
135
+ channels:
136
+ - 11
137
+ devices:
138
+ 80:1f:02:e6:44:96:
139
+ bytes: 960
140
+ signal: -46
141
+ vendor: Edimax Technology Co. Ltd.
142
+ 80:2a:a8:8a:ec:c8:
143
+ bytes: 472
144
+ signal: 4
145
+ vendor: Ubiquiti Networks Inc.
146
+ 80:2a:a8:be:09:a9:
147
+ bytes: 5199
148
+ signal: 4
149
+ vendor: Ubiquiti Networks Inc.
150
+ d8:49:2f:7a:f0:8f:
151
+ bytes: 548
152
+ signal: 4
153
+ vendor: CANON INC.
154
+ signal: -46
155
+ ssid: hacker
156
+ vendor: Ubiquiti Networks Inc.
157
+ 80:2a:a8:61:aa:2f:
158
+ bssid: 80:2a:a8:61:aa:2f
159
+ bytes: 5629
160
+ channels:
161
+ - 44
162
+ - 48
163
+ devices:
164
+ 78:88:6d:4e:e2:c9:
165
+ bytes: 948
166
+ signal: -52
167
+ vendor: ''
168
+ e4:8b:7f:d4:cb:25:
169
+ bytes: 986
170
+ signal: -48
171
+ vendor: Apple, Inc.
172
+ signal: -48
173
+ ssid: null
174
+ vendor: Ubiquiti Networks Inc.
175
+ 82:2a:a8:51:32:25:
176
+ bssid: 82:2a:a8:51:32:25
177
+ bytes: 3902
178
+ channels:
179
+ - 48
180
+ devices:
181
+ b8:e8:56:f5:a0:70:
182
+ bytes: 1188
183
+ signal: -34
184
+ vendor: Apple, Inc.
185
+ signal: -14
186
+ ssid: hacker
187
+ vendor: ''
188
+ 82:2a:a8:fc:33:b6:
189
+ bssid: 82:2a:a8:fc:33:b6
190
+ bytes: 7805
191
+ channels:
192
+ - 10
193
+ - 11
194
+ - 12
195
+ devices:
196
+ 78:31:c1:7f:25:43:
197
+ bytes: 4632
198
+ signal: -52
199
+ vendor: Apple, Inc.
200
+ 7c:dd:90:fe:b4:87:
201
+ bytes: 423223
202
+ signal: 4
203
+ vendor: Shenzhen Ogemray Technology Co., Ltd.
204
+ 80:2a:a8:be:09:a9:
205
+ bytes: 5199
206
+ signal: 4
207
+ vendor: Ubiquiti Networks Inc.
208
+ signal: -62
209
+ ssid: null
210
+ vendor: ''
211
+
212
+ Note that, since this is YAML, you can easily use it as an input for other scripts of your own devising. I have an example script to parse this "YAML DB" here: [parse_trackerjacker_wifi_map.py](https://gist.github.com/calebmadrigal/fdb8855a6d05c87bbb0254a1424ee582).
213
+
214
+ ### Example: Track mode with trigger command
215
+
216
+ Track mode allows you to specify some number of MAC addresses to watch, and if any specific devices exceeds the threshold (in bytes), specified here with the `--threshold 4000` (specifying an alert threshold of 4000 bytes) an alert will be triggered.
217
+
218
+ trackerjacker --track -m 3c:2e:ff:31:32:59 --threshold 4000 --trigger-command "./alert.sh" --channels-to-monitor 10,11,12,44
219
+ Using monitor mode interface: wlan1337
220
+ Monitoring channels: {10, 11, 12, 44}
221
+
222
+ [@] Device (3c:2e:ff:31:32:59) threshold hit: 4734
223
+
224
+ [@] Device (3c:2e:ff:31:32:59) threshold hit: 7717
225
+
226
+ [@] Device (3c:2e:ff:31:32:59) threshold hit: 7124
227
+
228
+ [@] Device (3c:2e:ff:31:32:59) threshold hit: 8258
229
+
230
+ [@] Device (3c:2e:ff:31:32:59) threshold hit: 8922
231
+
232
+ In this particular example, I was watching a security camera to determine when it was uploading a video (indicating motion was detected) so that I could turn on my security system sirens (which was the original genesis of this project).
233
+
234
+ ### Example: Track mode with foxhunt plugin
235
+
236
+ trackerjacker -i wlan1337 --track --trigger-plugin foxhunt
237
+
238
+ Displays a curses screen like this:
239
+
240
+ POWER DEVICE ID VENDOR
241
+ ======= ================= ================================
242
+ -82dBm 1c:1b:68:35:c6:5d ARRIS Group, Inc.
243
+ -84dBm fc:3f:db:ed:e9:8e Hewlett Packard
244
+ -84dBm dc:0b:34:7a:11:63 LG Electronics (Mobile Communications)
245
+ -84dBm 94:62:69:af:c3:64 ARRIS Group, Inc.
246
+ -84dBm 90:48:9a:34:15:65 Hon Hai Precision Ind. Co.,Ltd.
247
+ -84dBm 64:00:6a:07:48:13 Dell Inc.
248
+ -84dBm 00:30:44:38:76:c8 CradlePoint, Inc
249
+ -86dBm 44:1c:a8:fc:c0:53 Hon Hai Precision Ind. Co.,Ltd.
250
+ -86dBm 18:16:c9:c0:3b:75 Samsung Electronics Co.,Ltd
251
+ -86dBm 01:80:c2:62:9e:36
252
+ -86dBm 01:00:5e:11:90:47
253
+ -86dBm 00:24:a1:97:68:83 ARRIS Group, Inc.
254
+ -88dBm f8:2c:18:f8:f3:aa 2Wire Inc
255
+ -88dBm 84:a1:d1:a6:34:08
256
+
257
+
258
+ * Note that `foxhunt` is a builtin plugin, but you can define your own plugins using the same Plugin API.
259
+
260
+ ### Example: Track mode with trigger plugin
261
+
262
+ $ trackerjacker --track -m 3c:2e:ff:31:32:59 --threshold 10 --trigger-plugin examples/plugin_example1.py --channels-to-monitor 10,11,12,44 --trigger-cooldown 1
263
+ Using monitor mode interface: wlan1337
264
+ Monitoring channels: {10, 11, 12, 44}
265
+ [@] Device (device 3c:2e:ff:31:32:59) threshold hit: 34 bytes
266
+ 3c:2e:ff:31:32:59 seen at: [1521926768.756529]
267
+ [@] Device (device 3c:2e:ff:31:32:59) threshold hit: 11880 bytes
268
+ 3c:2e:ff:31:32:59 seen at: [1521926768.756529, 1521926769.758929]
269
+ [@] Device (device 3c:2e:ff:31:32:59) threshold hit: 18564 bytes
270
+ 3c:2e:ff:31:32:59 seen at: [1521926768.756529, 1521926769.758929, 1521926770.7622838]
271
+
272
+ This runs `examples/plugin_example1.py` every time `3c:2e:ff:31:32:59` is seen sending/receiving 10 bytes or more.
273
+
274
+ trackerjacker plugins are simply python files that contain either:
275
+ * `Trigger` class which defines a `__call__(**kwargs)` method (example: `examples/plugin_example1.py`)
276
+ * `trigger(**kwargs)` function (example: `examples/plugin_example2.py`)
277
+
278
+ And optionally a `__apiversion__ = 1` line (for future backward compatibility)
279
+
280
+ ### Example: Configuring with config file
281
+
282
+ trackerjacker.py -c my_config.json
283
+
284
+ And here's the example config file called `my_config.json`:
285
+
286
+ ```
287
+ {
288
+ "iface": "wlan1337",
289
+ "devices_to_watch": {"5f:cb:53:1c:8a:2c": 1000, "32:44:1b:d7:a1:5b": 2000},
290
+ "aps_to_watch": {"c6:23:ef:33:cc:a2": 500},
291
+ "threshold_window": 10,
292
+ "channels_to_monitor": [1, 6, 11, 52],
293
+ "channel_switch_scheme": "round_robin"
294
+ }
295
+ ```
296
+
297
+ A few notes about this:
298
+
299
+ * `threshold_bytes` is the default threshold of bytes which, if seen, a causes the alert function to be called
300
+ * `threshold_window` is the time window in which the `threshold_bytes` is analyzed.
301
+ * `devices_to_watch` is a list which can contain either strings (representing MACs) or dicts (which allow the specification of a `name` and `threshold`)
302
+ - `name` is simply what a label you want to be printed when this device is seen.
303
+ - `threshold` in the "Security camera" is how many bytes must be seen
304
+ * `channels_to_monitor` - list of 802.11 wifi channels to monitor. The list of channels your wifi card supports is printed when trackerjacker starts up. By default, all supported channels are monitored.
305
+ * `channel_switch_scheme` - either `default`, `round_robin`, or `traffic_based`. `traffic_based` determines the channels of most traffic, and probabilistically monitors them more.
306
+
307
+ ### Example: Enable/Disable monitor mode on interface
308
+
309
+ Trackerjacker comes with a few other utility functions relevant to WiFi hacking. One of these is the ability to turn on monitor mode on a specific interface.
310
+
311
+ Enable monitor mode:
312
+
313
+ trackerjacker --monitor-mode-on -i wlan0
314
+
315
+ Disable monitor mode:
316
+
317
+ trackerjacker --monitor-mode-off -i wlan0mon
318
+
319
+ Note that trackerjacker will automatically enable/disable monitor mode if necessary. This functionality is just useful if you want to enable monitor mode on an interface for use with other applications (or for quicker starup of trackerjacker, if you plan to be starting/exiting to test stuff).
320
+
321
+ ### Example: Set adapter channel
322
+
323
+ trackerjacker --set-channel 11 -i wlan0
324
+
325
+ Note that trackerjacker will automatically switch channels as necessary during normal map/track actions. This option is just useful if you want to set the channel on an interface for use with other applications.
326
+
327
+ ## Recommended hardware
328
+
329
+ * Panda PAU07 N600 Dual Band (nice, small, 2.4GHz and 5GHz)
330
+ * Panda PAU09 N600 Dual Band (higher power, 2.4GHz and 5GHz)
331
+ * Alfa AWUS052NH Dual-Band 2x 5dBi (high power, 2.4GHz and 5GHz, large, ugly)
332
+ * TP-Link N150 (works well, but not dual band)
333
+
334
+ ## Roadmap
335
+
336
+ - [x] Hosted in PyPI
337
+ - [x] Radio signal strength for APs
338
+ - [x] Radio signal strength for individual macs
339
+ - [x] Build map by data exchanged (exclude beacons)
340
+ - [x] Packet count by AP
341
+ - [x] Packet count by MAC
342
+ - [x] Easier way to input per-device tracking thresholds
343
+ - [x] Plugin system
344
+ - [x] Fox hunt mode
345
+ - [x] Tracking by SSID (and not just BSSID)
346
+ - [x] Basic macOS (OS X) support (pre-alpha)
347
+ - [ ] Mapping a specific SSID
348
+ - [ ] Performance enhancement: not shelling out for channel switching
349
+ - [ ] "Jack" mode - deauth attacks
350
+
@@ -166,9 +166,9 @@ Note that, since this is YAML, you can easily use it as an input for other scrip
166
166
 
167
167
  ### Example: Track mode with trigger command
168
168
 
169
- Track mode allows you to specify some number of MAC addresses to watch, and if any specific devices exceeds the threshold (in bytes), specified here with the `-t 4000` (specifying an alert threshold of 4000 bytes) an alert will be triggered.
169
+ Track mode allows you to specify some number of MAC addresses to watch, and if any specific devices exceeds the threshold (in bytes), specified here with the `--threshold 4000` (specifying an alert threshold of 4000 bytes) an alert will be triggered.
170
170
 
171
- trackerjacker --track -m 3c:2e:ff:31:32:59 --t 4000 --trigger-command "./alert.sh" --channels-to-monitor 10,11,12,44
171
+ trackerjacker --track -m 3c:2e:ff:31:32:59 --threshold 4000 --trigger-command "./alert.sh" --channels-to-monitor 10,11,12,44
172
172
  Using monitor mode interface: wlan1337
173
173
  Monitoring channels: {10, 11, 12, 44}
174
174
 
@@ -297,10 +297,6 @@ Note that trackerjacker will automatically switch channels as necessary during n
297
297
  - [x] Fox hunt mode
298
298
  - [x] Tracking by SSID (and not just BSSID)
299
299
  - [x] Basic macOS (OS X) support (pre-alpha)
300
- - [ ] macOS support: get signal strength values correct (will be fixed in https://github.com/secdev/scapy/pull/1381
301
- - [ ] macOS support: reverse airport binary to determine how to set true monitor mode
302
- - [ ] macOS support: diverse interface support (not just `en0`)
303
- - [ ] macOS support: get interface supported channels
304
300
  - [ ] Mapping a specific SSID
305
301
  - [ ] Performance enhancement: not shelling out for channel switching
306
302
  - [ ] "Jack" mode - deauth attacks
@@ -1,4 +1,4 @@
1
- scapy==2.5.0
1
+ scapy>=2.5.0
2
2
  pyaml>=17.12.1
3
3
  ruamel.yaml>=0.15.35
4
4
 
@@ -1,5 +1,5 @@
1
1
  [metadata]
2
- description-file = README.md
2
+ description_file = README.md
3
3
 
4
4
  [pep8]
5
5
  max-line-length = 120
@@ -28,10 +28,10 @@ setup(
28
28
  url = 'https://github.com/calebmadrigal/trackerjacker',
29
29
  version = get_version(),
30
30
  description = 'Finds and tracks wifi devices through raw 802.11 monitoring',
31
- long_description_content_type='text/x-rst',
31
+ long_description_content_type='text/markdown',
32
32
  long_description = get_readme(),
33
33
  author = 'Caleb Madrigal',
34
- author_email = 'caleb.madrigal@gmail.com',
34
+ author_email = 'caleb@gods.art',
35
35
  license = 'MIT',
36
36
  keywords = ['hacking', 'network', 'wireless', 'packets', 'scapy'],
37
37
  install_requires = requirements,
@@ -53,11 +53,13 @@ setup(
53
53
  'Programming Language :: Python :: 3.10',
54
54
  'Programming Language :: Python :: 3.11',
55
55
  'Programming Language :: Python :: 3.12',
56
+ 'Programming Language :: Python :: 3.13',
57
+ 'Programming Language :: Python :: 3.14',
58
+ 'Programming Language :: Python :: 3.15',
56
59
  'Programming Language :: Python :: Implementation :: CPython',
57
60
  'Topic :: System :: Networking',
58
61
  'Topic :: System :: Networking :: Monitoring',
59
62
  'Topic :: Security',
60
63
  'Operating System :: POSIX :: Linux',
61
- 'Operating System :: MacOS'
62
64
  ],
63
65
  )
@@ -33,18 +33,21 @@ LOG_NAME_TO_LEVEL = {'DEBUG': 10, 'INFO': 20, 'WARNING': 30, 'ERROR': 40, 'CRITI
33
33
  def make_logger(log_path=None, log_level_str='INFO'):
34
34
  logger = logging.getLogger('trackerjacker')
35
35
  formatter = logging.Formatter('%(asctime)s: (%(levelname)s): %(message)s')
36
+
36
37
  if log_path:
37
38
  log_handler = logging.FileHandler(log_path)
38
39
  log_handler.setFormatter(formatter)
39
- # Print errors to stderr if logging to a file
40
- stdout_handler = logging.StreamHandler(sys.stderr)
41
- stdout_handler.setLevel('ERROR')
42
- stdout_handler.setFormatter(logging.Formatter('%(message)s'))
43
- logger.addHandler(stdout_handler)
40
+ logger.addHandler(log_handler)
41
+
42
+ stderr_handler = logging.StreamHandler(sys.stderr)
43
+ stderr_handler.setLevel(logging.ERROR)
44
+ stderr_handler.setFormatter(logging.Formatter('%(message)s'))
45
+ logger.addHandler(stderr_handler)
44
46
  else:
45
47
  log_handler = logging.StreamHandler(sys.stdout)
46
48
  log_handler.setFormatter(logging.Formatter('%(message)s'))
47
- logger.addHandler(log_handler)
49
+ logger.addHandler(log_handler)
50
+
48
51
  log_level = LOG_NAME_TO_LEVEL.get(log_level_str.upper(), 20)
49
52
  logger.setLevel(log_level)
50
53
  return logger
@@ -119,9 +122,15 @@ class TrackerJacker:
119
122
  else: # track mode
120
123
  channel_switch_scheme = 'traffic_based'
121
124
 
125
+ print(f'devices_to_watch = {devices_to_watch}, aps_to_watch = {aps_to_watch}')
122
126
  self.devices_to_watch_set = set([dev['mac'].lower() for dev in devices_to_watch if 'mac' in dev])
123
127
  self.aps_to_watch_set = set([ap['bssid'].lower() for ap in aps_to_watch if 'bssid' in ap])
124
128
 
129
+ if len(self.devices_to_watch_set) > 0:
130
+ print(f'Tracking devices: {self.devices_to_watch_set}')
131
+ if len(self.aps_to_watch_set) > 0:
132
+ print(f'Tracking Access Points: {self.aps_to_watch_set}')
133
+
125
134
  if self.do_track:
126
135
  # Build trigger hit function
127
136
  if trigger_plugin:
@@ -149,57 +158,60 @@ class TrackerJacker:
149
158
  time_per_channel)
150
159
 
151
160
  def process_packet(self, pkt):
152
- if pkt.haslayer(scapy.Dot11):
153
- looking_for_specifics_and_none_found = self.aps_to_watch_set or self.devices_to_watch_set
154
-
155
- try:
156
- frame = dot11_frame.Dot11Frame(pkt,
157
- int(self.iface_manager.current_channel),
158
- iface=self.iface_manager.iface)
159
- except Exception as e:
160
- # Thank you DEF CON (https://github.com/secdev/scapy/issues/1552)
161
- self.logger.warning('Error decoding Dot11Frame: %s', e)
162
- return
163
-
164
- if self.do_map:
165
- self.log_newly_found(frame)
166
-
167
- if self.display_all_packets:
168
- print('\t', pkt.summary())
169
-
170
- # See if any APs we care about (if we're looking for specific APs)
171
- if self.aps_to_watch_set:
172
- if frame.bssid not in self.aps_to_watch_set:
173
- looking_for_specifics_and_none_found = False
174
-
175
- # See if any MACs we care about (if we're looking for specific MACs)
176
- if self.devices_to_watch_set:
177
- matched_macs = self.devices_to_watch_set & frame.macs
178
- if matched_macs:
179
- looking_for_specifics_and_none_found = False
180
-
181
- # Display matched packets (if specified)
182
- if self.display_matching_packets and not self.display_all_packets:
183
- print('\t', pkt.summary())
184
-
185
- # If we are looking for specific APs or Devices and none are found, no further processing needed
186
- if looking_for_specifics_and_none_found:
187
- return
188
-
189
- # If map mode enabled, do it. Note that we don't exclude non-matching MACs from the mapping
190
- # (which is why this isn't under the 'if matched_matcs' block).
191
- # Note: we update the map whether do_map is true or false since it's used for tracking; just don't save map
192
- self.dot11_map.add_frame(frame)
193
- if self.do_map:
194
- if time.time() - self.map_last_save >= self.map_save_interval:
195
- self.dot11_map.save_to_file(self.map_file)
196
- self.map_last_save = time.time()
197
-
198
- if self.do_track:
199
- self.dot11_tracker.add_frame(frame, pkt)
200
-
201
- # Update device tracking (for traffic-based)
202
- self.iface_manager.add_frame(frame)
161
+ try:
162
+ if pkt.haslayer(scapy.Dot11):
163
+ looking_for_specifics_and_none_found = self.aps_to_watch_set or self.devices_to_watch_set
164
+
165
+ try:
166
+ frame = dot11_frame.Dot11Frame(pkt,
167
+ int(self.iface_manager.current_channel),
168
+ iface=self.iface_manager.iface)
169
+ except Exception as e:
170
+ # Thank you DEF CON (https://github.com/secdev/scapy/issues/1552)
171
+ self.logger.warning('Error decoding Dot11Frame: %s', e)
172
+ return
173
+
174
+ if self.do_map:
175
+ self.log_newly_found(frame)
176
+
177
+ if self.display_all_packets:
178
+ print('\t', pkt.summary())
179
+
180
+ # See if any APs we care about (if we're looking for specific APs)
181
+ if self.aps_to_watch_set:
182
+ if frame.bssid not in self.aps_to_watch_set:
183
+ looking_for_specifics_and_none_found = False
184
+
185
+ # See if any MACs we care about (if we're looking for specific MACs)
186
+ if self.devices_to_watch_set:
187
+ matched_macs = self.devices_to_watch_set & frame.macs
188
+ if matched_macs:
189
+ looking_for_specifics_and_none_found = False
190
+
191
+ # Display matched packets (if specified)
192
+ if self.display_matching_packets and not self.display_all_packets:
193
+ print('\t', pkt.summary())
194
+
195
+ # If we are looking for specific APs or Devices and none are found, no further processing needed
196
+ if looking_for_specifics_and_none_found:
197
+ return
198
+
199
+ # If map mode enabled, do it. Note that we don't exclude non-matching MACs from the mapping
200
+ # (which is why this isn't under the 'if matched_matcs' block).
201
+ # Note: we update the map whether do_map is true or false since it's used for tracking; just don't save map
202
+ self.dot11_map.add_frame(frame)
203
+ if self.do_map:
204
+ if time.time() - self.map_last_save >= self.map_save_interval:
205
+ self.dot11_map.save_to_file(self.map_file)
206
+ self.map_last_save = time.time()
207
+
208
+ if self.do_track:
209
+ self.dot11_tracker.add_frame(frame, pkt)
210
+
211
+ # Update device tracking (for traffic-based)
212
+ self.iface_manager.add_frame(frame)
213
+ except Exception as e:
214
+ self.logger.debug('Error in process_packet: {e}')
203
215
 
204
216
  def log_newly_found(self, frame):
205
217
  # Log newly-found things
@@ -282,10 +294,6 @@ def do_simple_tasks_if_specified(args):
282
294
 
283
295
 
284
296
  def main():
285
- if not os.getuid() == 0:
286
- print('trackerjacker requires r00t!', file=sys.stderr)
287
- sys.exit(errno.EPERM)
288
-
289
297
  argparse_args = config_management.get_arg_parser().parse_args()
290
298
 
291
299
  # Some command-line args specify to just perform a simple task and then exit
@@ -308,6 +316,11 @@ def main():
308
316
  # Setup logger
309
317
  logger = make_logger(config.pop('log_path'), config.pop('log_level'))
310
318
 
319
+ # Any actual trackerjacker usage requires root (monitor mode in scapy requires it)
320
+ if not os.getuid() == 0:
321
+ print('trackerjacker requires r00t!', file=sys.stderr)
322
+ sys.exit(errno.EPERM)
323
+
311
324
  try:
312
325
  tj = TrackerJacker(**dict(config, **{'logger': logger})) # pylint: disable=E1123
313
326
  tj.start()
@@ -45,7 +45,8 @@ class Dot11Tracker:
45
45
  self.last_alerted = {}
46
46
 
47
47
  # Same as self.arg = arg for every arg (except devices_to_watch and aps_to_watch)
48
- self.__dict__.update({k: v for k, v in locals().items() if k != 'aps_to_watch'})
48
+ #self.__dict__.update({k: v for k, v in locals().items() if k != 'aps_to_watch'})
49
+ self.__dict__.update({k: v for k, v in locals().items()})
49
50
 
50
51
  # If no particular things are specified to be watched, assume everything should be watched
51
52
  self.track_all = (not aps_to_watch and not devices_to_watch)
@@ -91,7 +92,7 @@ class Dot11Tracker:
91
92
  frame=frame,
92
93
  raw_frame=raw_frame)
93
94
 
94
- if self.power and frame.signal_strength > self.power:
95
+ if self.power and frame.signal_strength and frame.signal_strength > self.power:
95
96
  self.do_trigger_alert(mac,
96
97
  'mac',
97
98
  vendor=dev_node['vendor'],
@@ -288,7 +289,7 @@ class Dot11Tracker:
288
289
  elif self.trigger_command:
289
290
  try:
290
291
  # Start trigger_command in background process - fire and forget
291
- subprocess.Popen(self.trigger_command)
292
+ subprocess.run(self.trigger_command, shell=True)
292
293
  except Exception:
293
294
  raise TJException('Error occurred in trigger command: {}'.format(traceback.format_exc()))
294
295