From a3c05b3e8538098ad5ce4941ab7ad9746527a3c5 Mon Sep 17 00:00:00 2001 From: Simone Margaritelli Date: Thu, 3 Oct 2019 11:27:51 +0200 Subject: [PATCH] example plugin --- README.md | 54 ++++++++++++++++++- .../rootfs/root/pwnagotchi/scripts/startup.sh | 2 - 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 50ef42e..7f23677 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,59 @@ Now you can use the `preview.py`-script to preview the changes: Pwnagotchi has a simple plugins system that you can use to customize your unit and its behaviour. You can place your plugins anywhere as python files and then edit the `config.yml` file (`main.plugins` value) to point to their containing folder. Check the [plugins folder](https://github.com/evilsocket/pwnagotchi/tree/master/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/) for a list of default -plugins and all the callbacks that you can define for your own customizations. +plugins and all the callbacks that you can define for your own customizations. + +Here's as an example the GPS plugin: + +```python +__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) +``` ### Random Info diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/startup.sh b/sdcard/rootfs/root/pwnagotchi/scripts/startup.sh index f158830..58b681c 100755 --- a/sdcard/rootfs/root/pwnagotchi/scripts/startup.sh +++ b/sdcard/rootfs/root/pwnagotchi/scripts/startup.sh @@ -9,5 +9,3 @@ if ifconfig | grep usb0 | grep RUNNING; then else sudo -H -u root /usr/bin/screen -dmS pwnagotchi -c /root/pwnagotchi/data/screenrc.auto fi - -