From 69597103b5607628197d8a373df375da82e0ed02 Mon Sep 17 00:00:00 2001 From: Ben Lebherz Date: Thu, 14 Nov 2019 15:57:43 +0100 Subject: [PATCH 1/3] use f-strings and double quotes in gps plugin --- pwnagotchi/plugins/default/gps.py | 42 ++++++++++++++++--------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/pwnagotchi/plugins/default/gps.py b/pwnagotchi/plugins/default/gps.py index 883e77c2..6a6b9dda 100644 --- a/pwnagotchi/plugins/default/gps.py +++ b/pwnagotchi/plugins/default/gps.py @@ -9,41 +9,43 @@ from pwnagotchi.ui.view import BLACK class GPS(plugins.Plugin): - __author__ = 'evilsocket@gmail.com' - __version__ = '1.0.0' - __license__ = 'GPL3' - __description__ = 'Save GPS coordinates whenever an handshake is captured.' + __author__ = "evilsocket@gmail.com" + __version__ = "1.0.0" + __license__ = "GPL3" + __description__ = "Save GPS coordinates whenever an handshake is captured." def __init__(self): self.running = False self.coordinates = None def on_loaded(self): - logging.info("gps plugin loaded for %s" % self.options['device']) + logging.info(f"gps plugin loaded for {self.options['device']}") def on_ready(self, agent): - if os.path.exists(self.options['device']): - logging.info("enabling bettercap's gps module for %s" % self.options['device']) + if os.path.exists(self.options["device"]): + logging.info( + f"enabling bettercap's gps module for {self.options['device']}" + ) try: - agent.run('gps off') + agent.run("gps off") except Exception: pass - agent.run('set gps.device %s' % self.options['device']) - agent.run('set gps.baudrate %d' % self.options['speed']) - agent.run('gps on') + agent.run(f"set gps.device {self.options['device']}") + agent.run(f"set gps.baudrate {self.options['speed']}") + agent.run("gps on") self.running = True else: - logging.warning('no GPS detected') + logging.warning("no GPS detected") def on_handshake(self, agent, filename, access_point, client_station): if self.running: info = agent.session() - self.coordinates = info['gps'] - gps_filename = filename.replace('.pcap', '.gps.json') + self.coordinates = info["gps"] + gps_filename = filename.replace(".pcap", ".gps.json") - logging.info("saving GPS to %s (%s)" % (gps_filename, self.coordinates)) - with open(gps_filename, 'w+t') as fp: + logging.info(f"saving GPS to {gps_filename} ({self.coordinates})") + with open(gps_filename, "w+t") as fp: json.dump(self.coordinates, fp) def on_ui_setup(self, ui): @@ -98,10 +100,10 @@ class GPS(plugins.Plugin): ) def on_ui_update(self, ui): - if self.coordinates and all([ - # avoid 0.000... measurements - self.coordinates["Latitude"], self.coordinates["Longitude"] - ]): + # avoid 0.000... measurements + if self.coordinates and all( + [self.coordinates["Latitude"], self.coordinates["Longitude"]] + ): ui.set("latitude", f"{self.coordinates['Latitude']:.4f}") ui.set("longitude", f" {self.coordinates['Longitude']:.4f}") ui.set("altitude", f" {self.coordinates['Altitude']:.1f}m") From 59ae35372e57e5c6618a02778d73797e83096e2d Mon Sep 17 00:00:00 2001 From: Josh Bauer Date: Thu, 14 Nov 2019 21:15:12 -0500 Subject: [PATCH 2/3] fixed check for nonzero lat/long --- pwnagotchi/plugins/default/webgpsmap.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pwnagotchi/plugins/default/webgpsmap.py b/pwnagotchi/plugins/default/webgpsmap.py index b20d49de..fc8cedc9 100644 --- a/pwnagotchi/plugins/default/webgpsmap.py +++ b/pwnagotchi/plugins/default/webgpsmap.py @@ -338,7 +338,7 @@ class PositionFile: lat = self._json['Latitude'] if self.type() == PositionFile.GEO: lat = self._json['location']['lat'] - if lat > 0: + if lat != 0: return lat raise ValueError("Lat is 0") except KeyError: @@ -351,7 +351,7 @@ class PositionFile: lng = self._json['Longitude'] if self.type() == PositionFile.GEO: lng = self._json['location']['lng'] - if lng > 0: + if lng != 0: return lng raise ValueError("Lng is 0") except KeyError: From 5111490c709c6f812bdde5d4a8e3dc141a2b5d3d Mon Sep 17 00:00:00 2001 From: Wystan Schmidt Date: Thu, 14 Nov 2019 20:13:50 -0700 Subject: [PATCH 3/3] Added rssi info to logging messages Signed-off-by: Wystan Schmidt --- pwnagotchi/agent.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pwnagotchi/agent.py b/pwnagotchi/agent.py index ba8bd16c..35774dd5 100644 --- a/pwnagotchi/agent.py +++ b/pwnagotchi/agent.py @@ -337,8 +337,9 @@ class Agent(Client, Automata, AsyncAdvertiser, AsyncTrainer): (ap, sta) = ap_and_station self._last_pwnd = ap['hostname'] if ap['hostname'] != '' and ap[ 'hostname'] != '' else ap_mac - logging.warning("!!! captured new handshake on channel %d: %s (%s) -> %s [%s (%s)] !!!" % ( \ + logging.warning("!!! captured new handshake on channel %d, %d dBm: %s (%s) -> %s [%s (%s)] !!!" % ( \ )) ap['channel'], + ap['rssi'], sta['mac'], sta['vendor'], ap['hostname'], ap['mac'], ap['vendor'])) plugins.on('handshake', self, filename, ap, sta) @@ -393,8 +394,8 @@ class Agent(Client, Automata, AsyncAdvertiser, AsyncTrainer): self._view.on_assoc(ap) try: - logging.info("sending association frame to %s (%s %s) on channel %d [%d clients]..." % ( \ - ap['hostname'], ap['mac'], ap['vendor'], ap['channel'], len(ap['clients']))) + logging.info("sending association frame to %s (%s %s) on channel %d [%d clients], %d dBm..." % ( \ + ap['hostname'], ap['mac'], ap['vendor'], ap['channel'], len(ap['clients']), ap['rssi'])) self.run('wifi.assoc %s' % ap['mac']) self._epoch.track(assoc=True) except Exception as e: @@ -414,8 +415,8 @@ class Agent(Client, Automata, AsyncAdvertiser, AsyncTrainer): self._view.on_deauth(sta) try: - logging.info("deauthing %s (%s) from %s (%s %s) on channel %d ..." % ( - sta['mac'], sta['vendor'], ap['hostname'], ap['mac'], ap['vendor'], ap['channel'])) + logging.info("deauthing %s (%s) from %s (%s %s) on channel %d, %d dBm ..." % ( + sta['mac'], sta['vendor'], ap['hostname'], ap['mac'], ap['vendor'], ap['channel'], ap['rssi'])) self.run('wifi.deauth %s' % sta['mac']) self._epoch.track(deauth=True) except Exception as e: