new: gps coordinates are saved along with handshakes if gps is connected (related to )

This commit is contained in:
Simone Margaritelli 2019-10-02 19:41:50 +02:00
parent f6b3f705d3
commit 5725d8b239
3 changed files with 54 additions and 3 deletions
sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi

@ -45,6 +45,9 @@ class Agent(Client, AsyncAdvertiser, AsyncTrainer):
pass
return False
def config(self):
return self._config
def supported_channels(self):
return self._supported_channels
@ -336,6 +339,7 @@ class Agent(Client, AsyncAdvertiser, AsyncTrainer):
try:
for h in [e for e in self.events() if e['tag'] == 'wifi.client.handshake']:
filename = h['data']['file']
sta_mac = h['data']['station']
ap_mac = h['data']['ap']
key = "%s -> %s" % (sta_mac, ap_mac)
@ -347,7 +351,7 @@ class Agent(Client, AsyncAdvertiser, AsyncTrainer):
if apsta is None:
core.log("!!! captured new handshake: %s !!!" % key)
self._last_pwnd = ap_mac
plugins.on('handshake', self, ap_mac, sta_mac)
plugins.on('handshake', self, filename, ap_mac, sta_mac)
else:
(ap, sta) = apsta
self._last_pwnd = ap['hostname'] if ap['hostname'] != '' and ap[
@ -356,7 +360,7 @@ class Agent(Client, AsyncAdvertiser, AsyncTrainer):
ap['channel'],
sta['mac'], sta['vendor'],
ap['hostname'], ap['mac'], ap['vendor']))
plugins.on('handshake', self, ap, sta)
plugins.on('handshake', self, filename, ap, sta)
except Exception as e:
core.log("error: %s" % e)

@ -143,7 +143,7 @@ def on_channel_hop(agent, channel):
# called when a new handshake is captured, access_point and client_station are json objects
# if the agent could match the BSSIDs to the current list, otherwise they are just the strings of the BSSIDs
def on_handshake(agent, access_point, client_station):
def on_handshake(agent, filename, access_point, client_station):
pass

@ -0,0 +1,47 @@
__author__ = 'evilsocket@gmail.com'
__version__ = '1.0.0'
__name__ = 'gps'
__license__ = 'GPL3'
__description__ = 'Save GPS coordinates whenever an handshake is captured.'
__enabled__ = True # set to false if you just don't use GPS
import core
import json
import os
device = '/dev/ttyUSB0'
speed = 19200
running = False
def on_loaded():
core.log("GPS plugin loaded for %s" % device)
def on_ready(agent):
global running
if os.path.exists(device):
core.log("enabling GPS bettercap's module for %s" % device)
try:
agent.run('gps off')
except:
pass
agent.run('set gps.device %s' % device)
agent.run('set gps.speed %d' % speed)
agent.run('gps on')
running = True
else:
core.log("no GPS detected")
def on_handshake(agent, filename, access_point, client_station):
if running:
info = agent.session()
gps = info['gps']
gps_filename = filename.replace('.pcap', '.gps.json')
core.log("saving GPS to %s (%s)" % (gps_filename, gps))
with open(gps_filename, 'w+t') as fp:
json.dump(gps, fp)