2019-11-01 13:51:45 +01:00
|
|
|
import logging
|
|
|
|
import requests
|
|
|
|
import pwnagotchi.plugins as plugins
|
2019-10-25 16:57:05 +02:00
|
|
|
|
|
|
|
'''
|
2019-11-18 13:27:30 +02:00
|
|
|
You need an bluetooth connection to your android phone which is running PAW server with the GPS "hack" from Systemik and edited by shaynemk
|
2019-11-19 15:38:11 +02:00
|
|
|
GUIDE HERE: https://community.pwnagotchi.ai/t/setting-up-paw-gps-on-android
|
2019-10-25 16:57:05 +02:00
|
|
|
'''
|
|
|
|
|
|
|
|
|
2019-11-01 13:51:45 +01:00
|
|
|
class PawGPS(plugins.Plugin):
|
|
|
|
__author__ = 'leont'
|
2021-11-13 23:26:08 +01:00
|
|
|
__version__ = '1.0.1'
|
2019-11-01 13:51:45 +01:00
|
|
|
__name__ = 'pawgps'
|
|
|
|
__license__ = 'GPL3'
|
2021-11-13 23:26:08 +01:00
|
|
|
__description__ = 'Saves GPS coordinates whenever an handshake is captured. The GPS data is get from PAW on android.'
|
2019-10-25 16:57:05 +02:00
|
|
|
|
2019-11-01 13:51:45 +01:00
|
|
|
def on_loaded(self):
|
2021-11-13 23:26:08 +01:00
|
|
|
logging.info("[paw-gps] plugin loaded")
|
|
|
|
if 'ip' not in self.options or ('ip' in self.options and self.options['ip'] is None) or (len('ip' in self.options and self.options['ip']) is 0):
|
|
|
|
logging.info("[paw-gps] no IP Address defined in the config file, will uses paw server default (192.168.44.1:8080)")
|
2019-10-25 16:57:05 +02:00
|
|
|
|
2019-11-01 13:51:45 +01:00
|
|
|
def on_handshake(self, agent, filename, access_point, client_station):
|
2021-11-13 23:26:08 +01:00
|
|
|
if 'ip' not in self.options or ('ip' in self.options and self.options['ip'] is None or (len('ip' in self.options and self.options['ip']) is 0)):
|
2019-11-14 11:45:39 +02:00
|
|
|
ip = "192.168.44.1:8080"
|
2019-11-14 22:29:43 +02:00
|
|
|
else:
|
2019-11-14 22:29:58 +02:00
|
|
|
ip = self.options['ip']
|
2019-10-25 16:57:05 +02:00
|
|
|
|
2021-11-13 23:26:08 +01:00
|
|
|
try:
|
|
|
|
gps = requests.get('http://' + ip + '/gps.xhtml')
|
|
|
|
try:
|
|
|
|
gps_filename = filename.replace('.pcap', '.paw-gps.json')
|
|
|
|
logging.info("[paw-gps] saving GPS data to %s" % (gps_filename))
|
|
|
|
with open(gps_filename, 'w+t') as f:
|
|
|
|
f.write(gps.text)
|
|
|
|
except Exception as error:
|
|
|
|
logging.error(f"[paw-gps] encountered error while saving gps data: {error}")
|
|
|
|
except Exception as error:
|
|
|
|
logging.error(f"[paw-gps] encountered error while getting gps data: {error}")
|