Plugins throw events & priority

hi,

I want to play a sound if the quickdic plugin has found a password.
before I copy the plugin and change it for me:

is there a way for quickdic to throw an event “on_cracked”, which i receive in my sound plugin?

and a “priority” config value for plugins would be nice, so you can set the order in which the plugins receive events in the config.
default priority=0, can be configured lower (negative) for execute last and higher for execute first.

would that be easy to implement?

2 Likes

oh that’s a neat idea! … you can already do that, at any point you can propagate a custom even by calling:

plugins.on('cracked', any, argument, you, want, here)

And that’s gonna call on_cracked with those args for any plugin that’s implementing it :+1:

3 Likes

tested with plugin format before plugin classes, but does not work.
no error, but my function in souns.py is not called:

def on_cracked(agent, access_point_hostname):
    logging.info("on_cracked() called in sound-plugin!")
    play_my_sound(sys._getframe().f_code.co_name, str(access_point["hostname"]))

quickdic.py:

def on_handshake(agent, filename, access_point, client_station):
    global plugins
    display = agent._view

    result = subprocess.run(('/usr/bin/aircrack-ng '+ filename +' | grep "1 handshake" | awk \'{print $2}\''),shell=True, stdout=subprocess.PIPE)
    result = result.stdout.decode('utf-8').translate({ord(c) :None for c in string.whitespace})
    if not result:
        logging.info("[quickdic] No handshake")
        plugins.on('cracked', access_point)
    else:
        logging.info("[quickdic] Handshake confirmed")
        result2 = subprocess.run(('aircrack-ng -w `echo '+OPTIONS['wordlist_folder']+'*.txt | sed \'s/\ /,/g\'` -l '+filename+'.cracked -q -b '+result+' '+filename+' | grep KEY'),shell=True,stdout=subprocess.P
IPE)
        result2 = result2.stdout.decode('utf-8').strip()
        logging.info("[quickdic] "+result2)
        if result2 != "KEY NOT FOUND":
            key = re.search('\[(.*)\]', result2)
            pwd = str(key.group(1))
            set_text(str(access_point["hostname"])+":"+pwd)
            display.update(force=True)
            plugins.on('cracked', access_point)

what i do wrong?

idk man you’re using the old format, a lot of that code changed … can you try to update and see if it works with the latest refactor?

ok, i test after updating to MASTER

1 Like

don’t forget to

import pwnagotchi.plugins as plugins

Thats really cool!!

Yes, that was missing. i used the wrong way with “global plugins”

Works now :slight_smile:
i test today with v1.2.1 and make a pr

2 Likes

:+1: