From ebb8fef3fca4ac8cd56f11078cb3ce1fb205b6e8 Mon Sep 17 00:00:00 2001 From: jayofelony Date: Tue, 5 Mar 2024 19:54:47 +0100 Subject: [PATCH] Update build Signed-off-by: jayofelony --- bin/pwnagotchi | 172 +++++++++++++++++++++++++---------------------- pyproject.toml | 60 +++++++++++++++++ requirements.txt | 20 ++---- 3 files changed, 157 insertions(+), 95 deletions(-) create mode 100644 pyproject.toml diff --git a/bin/pwnagotchi b/bin/pwnagotchi index 66bc9ed1..df5a8724 100755 --- a/bin/pwnagotchi +++ b/bin/pwnagotchi @@ -19,85 +19,83 @@ from pwnagotchi import fs from pwnagotchi.utils import DottedTomlEncoder, parse_version as version_to_tuple -def do_clear(display): - logging.info("clearing the display ...") - display.clear() - sys.exit(0) +def pwnagotchi_cli(): + def do_clear(display): + logging.info("clearing the display ...") + display.clear() + sys.exit(0) + def do_manual_mode(agent): + logging.info("entering manual mode ...") -def do_manual_mode(agent): - logging.info("entering manual mode ...") - - agent.mode = 'manual' - agent.last_session.parse(agent.view(), args.skip_session) - if not args.skip_session: - logging.info( - "the last session lasted %s (%d completed epochs, trained for %d), average reward:%s (min:%s max:%s)" % ( - agent.last_session.duration_human, - agent.last_session.epochs, - agent.last_session.train_epochs, - agent.last_session.avg_reward, - agent.last_session.min_reward, - agent.last_session.max_reward)) - - while True: - display.on_manual_mode(agent.last_session) - time.sleep(5) - if grid.is_connected(): - plugins.on('internet_available', agent) - - -def do_auto_mode(agent): - logging.info("entering auto mode ...") - - agent.mode = 'auto' - agent.start() - - while True: - try: - # recon on all channels - agent.recon() - # get nearby access points grouped by channel - channels = agent.get_access_points_by_channel() - # for each channel - for ch, aps in channels: - agent.set_channel(ch) - - if not agent.is_stale() and agent.any_activity(): - logging.info("%d access points on channel %d" % (len(aps), ch)) - - # for each ap on this channel - for ap in aps: - # send an association frame in order to get for a PMKID - agent.associate(ap) - # deauth all client stations in order to get a full handshake - for sta in ap['clients']: - agent.deauth(ap, sta) - time.sleep(1) # delay to not trigger nexmon firmware bugs - - # An interesting effect of this: - # - # From Pwnagotchi's perspective, the more new access points - # and / or client stations nearby, the longer one epoch of - # its relative time will take ... basically, in Pwnagotchi's universe, - # Wi-Fi electromagnetic fields affect time like gravitational fields - # affect ours ... neat ^_^ - agent.next_epoch() + agent.mode = 'manual' + agent.last_session.parse(agent.view(), args.skip_session) + if not args.skip_session: + logging.info( + "the last session lasted %s (%d completed epochs, trained for %d), average reward:%s (min:%s max:%s)" % ( + agent.last_session.duration_human, + agent.last_session.epochs, + agent.last_session.train_epochs, + agent.last_session.avg_reward, + agent.last_session.min_reward, + agent.last_session.max_reward)) + while True: + display.on_manual_mode(agent.last_session) + time.sleep(5) if grid.is_connected(): plugins.on('internet_available', agent) - except Exception as e: - if str(e).find("wifi.interface not set") > 0: - logging.exception("main loop exception due to unavailable wifi device, likely programmatically disabled (%s)", e) - logging.info("sleeping 60 seconds then advancing to next epoch to allow for cleanup code to trigger") - time.sleep(60) + def do_auto_mode(agent): + logging.info("entering auto mode ...") + + agent.mode = 'auto' + agent.start() + + while True: + try: + # recon on all channels + agent.recon() + # get nearby access points grouped by channel + channels = agent.get_access_points_by_channel() + # for each channel + for ch, aps in channels: + time.sleep(0.2) + agent.set_channel(ch) + + if not agent.is_stale() and agent.any_activity(): + logging.info("%d access points on channel %d" % (len(aps), ch)) + + # for each ap on this channel + for ap in aps: + # send an association frame in order to get for a PMKID + agent.associate(ap) + # deauth all client stations in order to get a full handshake + for sta in ap['clients']: + agent.deauth(ap, sta) + time.sleep(1) # delay to not trigger nexmon firmware bugs + + # An interesting effect of this: + # + # From Pwnagotchi's perspective, the more new access points + # and / or client stations nearby, the longer one epoch of + # its relative time will take ... basically, in Pwnagotchi's universe, + # Wi-Fi electromagnetic fields affect time like gravitational fields + # affect ours ... neat ^_^ agent.next_epoch() - else: - logging.exception("main loop exception (%s)", e) + if grid.is_connected(): + plugins.on('internet_available', agent) + + except Exception as e: + if str(e).find("wifi.interface not set") > 0: + logging.exception("main loop exception due to unavailable wifi device, likely programmatically disabled (%s)", e) + logging.info("sleeping 60 seconds then advancing to next epoch to allow for cleanup code to trigger") + time.sleep(60) + agent.next_epoch() + else: + logging.exception("main loop exception (%s)", e) -if __name__ == '__main__': def add_parsers(parser): """ Adds the plugins and google subcommands @@ -169,21 +167,23 @@ if __name__ == '__main__': allowed = re.compile("(?!-)[A-Z\d-]{1,63}(?=3.9" +authors = [ + {name = "Evilsocket", email = "evilsocket@gmail.com"}, + {name = "Jayofelony", email = "oudshoorn.jeroen@gmail.com"} +] +maintainers = [ + {name = "Jayofelony", email = "oudshoorn.jeroen@gmail.com"} +] +description = "(⌐■_■) - Deep Reinforcement Learning instrumenting bettercap for WiFI pwning." +readme = "README.md" +license = {file = "LICENSE.md"} +classifiers = [ + 'Programming Language :: Python :: 3', + 'Development Status :: 5 - Production/Stable', + 'License :: OSI Approved :: GNU General Public License (GPL)', + 'Environment :: Console', +] + +[project.urls] +Homepage = "https://pwnagotchi.org/" +Documentation = "https://pwnagotchi.org/" +Repository = "https://github.com/jayofelony/pwnagotchi.git" +Issues = "https://github.com/jayofelony/pwnagotchi/issues" + +[project.scripts] +pwnagotchi_cli = "bin.pwnagotchi:pwnagotchi_cli" \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 384bbb81..ab51bdcb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ gym -shimmy; platform_machine!="armv6l" +shimmy pycryptodome requests PyYAML @@ -18,17 +18,9 @@ dbus-python toml python-dateutil websockets -torch; platform_machine=="aarch64" -torch>=2.0.1; platform_machine!="aarch64" - -torchvision; platform_machine=="aarch64" -torchvision>=0.15.2; platform_machine!="aarch64" - -stable_baselines3==1.8.0; platform_machine=="armv6l" -stable_baselines3; platform_machine!="armv6l" - -RPi.GPIO; platform_release!="6.1.31-sun50iw9" -OPi.GPIO; platform_release=="6.1.31-sun50iw9" - -rpi_hardware_pwm; platform_release!="6.1.31-sun50iw9" +torch +torchvision +stable_baselines3 +RPi.GPIO +rpi_hardware_pwm pydrive2 \ No newline at end of file