diff --git a/.gitignore b/.gitignore index 3833e98..fc54ebf 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,7 @@ config.laptop.yml .idea packer_cache output-pwnagotchi +.DS_Store +build +dist +pwnagotchi.egg-info diff --git a/bin/pwnagotchi b/bin/pwnagotchi new file mode 100755 index 0000000..4733105 --- /dev/null +++ b/bin/pwnagotchi @@ -0,0 +1,106 @@ +#!/usr/bin/python3 +if __name__ == '__main__': + import argparse + import time + import os + import logging + + import pwnagotchi + import pwnagotchi.utils as utils + import pwnagotchi.plugins as plugins + + from pwnagotchi.log import SessionParser + from pwnagotchi.agent import Agent + from pwnagotchi.ui.display import Display + + parser = argparse.ArgumentParser() + + parser.add_argument('-C', '--config', action='store', dest='config', + default=os.path.join(os.path.abspath(os.path.dirname(pwnagotchi.__file__)), '/defaults.yml'), + help='Main configuration file.') + parser.add_argument('-U', '--user-config', action='store', dest='user_config', default='/etc/pwnagotchi/config.yml', + help='If this file exists, configuration will be merged and this will override default values.') + + parser.add_argument('--manual', dest="do_manual", action="store_true", default=False, help="Manual mode.") + parser.add_argument('--clear', dest="do_clear", action="store_true", default=False, + help="Clear the ePaper display and exit.") + + parser.add_argument('--debug', dest="debug", action="store_true", default=False, + help="Enable debug logs.") + + args = parser.parse_args() + config = utils.load_config(args) + utils.setup_logging(args, config) + + plugins.load(config) + + display = Display(config=config, state={'name': '%s>' % pwnagotchi.name()}) + agent = Agent(view=display, config=config) + + logging.info("%s@%s (v%s)" % (pwnagotchi.name(), agent._identity, pwnagotchi.version)) + + for _, plugin in plugins.loaded.items(): + logging.debug("plugin '%s' v%s loaded from %s" % (plugin.__name__, plugin.__version__, plugin.__file__)) + + if args.do_clear: + logging.info("clearing the display ...") + display.clear() + + elif args.do_manual: + logging.info("entering manual mode ...") + + log = SessionParser(config) + logging.info( + "the last session lasted %s (%d completed epochs, trained for %d), average reward:%s (min:%s max:%s)" % ( + log.duration_human, + log.epochs, + log.train_epochs, + log.avg_reward, + log.min_reward, + log.max_reward)) + + while True: + display.on_manual_mode(log) + time.sleep(1) + + if Agent.is_connected(): + plugins.on('internet_available', display, config, log) + + else: + logging.info("entering auto mode ...") + + 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() + # check for free channels to use + agent.check_channels(channels) + # 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) + + # 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, + # WiFi electromagnetic fields affect time like gravitational fields + # affect ours ... neat ^_^ + agent.next_epoch() + except Exception as e: + logging.exception("main loop exception") diff --git a/builder/pwnagotchi.yml b/builder/pwnagotchi.yml index ecd6251..fab9c2e 100644 --- a/builder/pwnagotchi.yml +++ b/builder/pwnagotchi.yml @@ -260,6 +260,21 @@ echo 0 >/sys/class/leds/led0/brightness sleep 0.3 + - name: create pwnagotchi-launcher script + copy: + dest: /usr/bin/pwnagotchi-launcher + mode: 0755 + content: | + #!/usr/bin/env bash + # blink 10 times to signal ready state + /usr/bin/bootblink 10 & + # start a detached screen session with bettercap + if ifconfig | grep usb0 | grep RUNNING; then + /usr/bin/pwnagotchi --manual + else + /usr/bin/pwnagotchi + fi + - name: create monstart script copy: dest: /usr/bin/monstart @@ -286,6 +301,13 @@ fi /root/pwnagotchi/scripts/startup.sh & + - name: create /etc/pwnagotchi/config.yml + blockinfile: + path: /etc/pwnagotchi/config.yml + create: yes + block: | + # put here your custom configuration overrides + - name: configure lo interface blockinfile: path: /etc/network/interfaces.d/lo-cfg diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/__init__.py b/pwnagotchi/__init__.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/__init__.py rename to pwnagotchi/__init__.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/agent.py b/pwnagotchi/agent.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/agent.py rename to pwnagotchi/agent.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ai/__init__.py b/pwnagotchi/ai/__init__.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ai/__init__.py rename to pwnagotchi/ai/__init__.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ai/epoch.py b/pwnagotchi/ai/epoch.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ai/epoch.py rename to pwnagotchi/ai/epoch.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ai/featurizer.py b/pwnagotchi/ai/featurizer.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ai/featurizer.py rename to pwnagotchi/ai/featurizer.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ai/gym.py b/pwnagotchi/ai/gym.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ai/gym.py rename to pwnagotchi/ai/gym.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ai/parameter.py b/pwnagotchi/ai/parameter.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ai/parameter.py rename to pwnagotchi/ai/parameter.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ai/reward.py b/pwnagotchi/ai/reward.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ai/reward.py rename to pwnagotchi/ai/reward.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ai/train.py b/pwnagotchi/ai/train.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ai/train.py rename to pwnagotchi/ai/train.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ai/utils.py b/pwnagotchi/ai/utils.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ai/utils.py rename to pwnagotchi/ai/utils.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/bettercap.py b/pwnagotchi/bettercap.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/bettercap.py rename to pwnagotchi/bettercap.py diff --git a/sdcard/rootfs/root/pwnagotchi/config.yml b/pwnagotchi/defaults.yml similarity index 99% rename from sdcard/rootfs/root/pwnagotchi/config.yml rename to pwnagotchi/defaults.yml index a93a7e8..cceac71 100644 --- a/sdcard/rootfs/root/pwnagotchi/config.yml +++ b/pwnagotchi/defaults.yml @@ -153,8 +153,8 @@ bettercap: scheme: http hostname: localhost port: 8081 - username: user - password: pass + username: pwnagotchi + password: pwnagotchi # folder where bettercap stores the WPA handshakes, given that # wifi.handshakes.aggregate will be set to false and individual # pcap files will be created in order to minimize the chances diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/de/LC_MESSAGES/voice.mo b/pwnagotchi/locale/de/LC_MESSAGES/voice.mo similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/de/LC_MESSAGES/voice.mo rename to pwnagotchi/locale/de/LC_MESSAGES/voice.mo diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/de/LC_MESSAGES/voice.po b/pwnagotchi/locale/de/LC_MESSAGES/voice.po similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/de/LC_MESSAGES/voice.po rename to pwnagotchi/locale/de/LC_MESSAGES/voice.po diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/el/LC_MESSAGES/voice.mo b/pwnagotchi/locale/el/LC_MESSAGES/voice.mo similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/el/LC_MESSAGES/voice.mo rename to pwnagotchi/locale/el/LC_MESSAGES/voice.mo diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/el/LC_MESSAGES/voice.po b/pwnagotchi/locale/el/LC_MESSAGES/voice.po similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/el/LC_MESSAGES/voice.po rename to pwnagotchi/locale/el/LC_MESSAGES/voice.po diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/fr/LC_MESSAGES/voice.mo b/pwnagotchi/locale/fr/LC_MESSAGES/voice.mo similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/fr/LC_MESSAGES/voice.mo rename to pwnagotchi/locale/fr/LC_MESSAGES/voice.mo diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/fr/LC_MESSAGES/voice.po b/pwnagotchi/locale/fr/LC_MESSAGES/voice.po similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/fr/LC_MESSAGES/voice.po rename to pwnagotchi/locale/fr/LC_MESSAGES/voice.po diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/it/LC_MESSAGES/voice.mo b/pwnagotchi/locale/it/LC_MESSAGES/voice.mo similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/it/LC_MESSAGES/voice.mo rename to pwnagotchi/locale/it/LC_MESSAGES/voice.mo diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/it/LC_MESSAGES/voice.po b/pwnagotchi/locale/it/LC_MESSAGES/voice.po similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/it/LC_MESSAGES/voice.po rename to pwnagotchi/locale/it/LC_MESSAGES/voice.po diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/mk/LC_MESSAGES/voice.mo b/pwnagotchi/locale/mk/LC_MESSAGES/voice.mo similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/mk/LC_MESSAGES/voice.mo rename to pwnagotchi/locale/mk/LC_MESSAGES/voice.mo diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/mk/LC_MESSAGES/voice.po b/pwnagotchi/locale/mk/LC_MESSAGES/voice.po similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/mk/LC_MESSAGES/voice.po rename to pwnagotchi/locale/mk/LC_MESSAGES/voice.po diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/nl/LC_MESSAGES/voice.mo b/pwnagotchi/locale/nl/LC_MESSAGES/voice.mo similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/nl/LC_MESSAGES/voice.mo rename to pwnagotchi/locale/nl/LC_MESSAGES/voice.mo diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/nl/LC_MESSAGES/voice.po b/pwnagotchi/locale/nl/LC_MESSAGES/voice.po similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/nl/LC_MESSAGES/voice.po rename to pwnagotchi/locale/nl/LC_MESSAGES/voice.po diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/ru/LC_MESSAGES/voice.mo b/pwnagotchi/locale/ru/LC_MESSAGES/voice.mo similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/ru/LC_MESSAGES/voice.mo rename to pwnagotchi/locale/ru/LC_MESSAGES/voice.mo diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/ru/LC_MESSAGES/voice.po b/pwnagotchi/locale/ru/LC_MESSAGES/voice.po similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/ru/LC_MESSAGES/voice.po rename to pwnagotchi/locale/ru/LC_MESSAGES/voice.po diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/se/LC_MESSAGES/voice.mo b/pwnagotchi/locale/se/LC_MESSAGES/voice.mo similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/se/LC_MESSAGES/voice.mo rename to pwnagotchi/locale/se/LC_MESSAGES/voice.mo diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/se/LC_MESSAGES/voice.po b/pwnagotchi/locale/se/LC_MESSAGES/voice.po similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/se/LC_MESSAGES/voice.po rename to pwnagotchi/locale/se/LC_MESSAGES/voice.po diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/voice.pot b/pwnagotchi/locale/voice.pot similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/locale/voice.pot rename to pwnagotchi/locale/voice.pot diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/log.py b/pwnagotchi/log.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/log.py rename to pwnagotchi/log.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/mesh/__init__.py b/pwnagotchi/mesh/__init__.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/mesh/__init__.py rename to pwnagotchi/mesh/__init__.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/mesh/advertise.py b/pwnagotchi/mesh/advertise.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/mesh/advertise.py rename to pwnagotchi/mesh/advertise.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/mesh/peer.py b/pwnagotchi/mesh/peer.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/mesh/peer.py rename to pwnagotchi/mesh/peer.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/mesh/utils.py b/pwnagotchi/mesh/utils.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/mesh/utils.py rename to pwnagotchi/mesh/utils.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/mesh/wifi.py b/pwnagotchi/mesh/wifi.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/mesh/wifi.py rename to pwnagotchi/mesh/wifi.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/__init__.py b/pwnagotchi/plugins/__init__.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/__init__.py rename to pwnagotchi/plugins/__init__.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/auto-backup.py b/pwnagotchi/plugins/default/auto-backup.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/auto-backup.py rename to pwnagotchi/plugins/default/auto-backup.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/auto-update.py b/pwnagotchi/plugins/default/auto-update.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/auto-update.py rename to pwnagotchi/plugins/default/auto-update.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/example.py b/pwnagotchi/plugins/default/example.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/example.py rename to pwnagotchi/plugins/default/example.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/gps.py b/pwnagotchi/plugins/default/gps.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/gps.py rename to pwnagotchi/plugins/default/gps.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/memtemp.py b/pwnagotchi/plugins/default/memtemp.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/memtemp.py rename to pwnagotchi/plugins/default/memtemp.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/onlinehashcrack.py b/pwnagotchi/plugins/default/onlinehashcrack.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/onlinehashcrack.py rename to pwnagotchi/plugins/default/onlinehashcrack.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/twitter.py b/pwnagotchi/plugins/default/twitter.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/twitter.py rename to pwnagotchi/plugins/default/twitter.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/ups_lite.py b/pwnagotchi/plugins/default/ups_lite.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/ups_lite.py rename to pwnagotchi/plugins/default/ups_lite.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/wpa-sec.py b/pwnagotchi/plugins/default/wpa-sec.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/plugins/default/wpa-sec.py rename to pwnagotchi/plugins/default/wpa-sec.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/__init__.py b/pwnagotchi/ui/__init__.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/__init__.py rename to pwnagotchi/ui/__init__.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/components.py b/pwnagotchi/ui/components.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/components.py rename to pwnagotchi/ui/components.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/display.py b/pwnagotchi/ui/display.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/display.py rename to pwnagotchi/ui/display.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/faces.py b/pwnagotchi/ui/faces.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/faces.py rename to pwnagotchi/ui/faces.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/fonts.py b/pwnagotchi/ui/fonts.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/fonts.py rename to pwnagotchi/ui/fonts.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/papirus/__init__.py b/pwnagotchi/ui/papirus/__init__.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/papirus/__init__.py rename to pwnagotchi/ui/papirus/__init__.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/papirus/epd.py b/pwnagotchi/ui/papirus/epd.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/papirus/epd.py rename to pwnagotchi/ui/papirus/epd.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/papirus/lm75b.py b/pwnagotchi/ui/papirus/lm75b.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/papirus/lm75b.py rename to pwnagotchi/ui/papirus/lm75b.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/state.py b/pwnagotchi/ui/state.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/state.py rename to pwnagotchi/ui/state.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/view.py b/pwnagotchi/ui/view.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/view.py rename to pwnagotchi/ui/view.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/waveshare/__init__.py b/pwnagotchi/ui/waveshare/__init__.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/waveshare/__init__.py rename to pwnagotchi/ui/waveshare/__init__.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/waveshare/v1/__init__.py b/pwnagotchi/ui/waveshare/v1/__init__.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/waveshare/v1/__init__.py rename to pwnagotchi/ui/waveshare/v1/__init__.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/waveshare/v1/epd2in13.py b/pwnagotchi/ui/waveshare/v1/epd2in13.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/waveshare/v1/epd2in13.py rename to pwnagotchi/ui/waveshare/v1/epd2in13.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/waveshare/v1/epdconfig.py b/pwnagotchi/ui/waveshare/v1/epdconfig.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/waveshare/v1/epdconfig.py rename to pwnagotchi/ui/waveshare/v1/epdconfig.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/waveshare/v2/__init__.py b/pwnagotchi/ui/waveshare/v2/__init__.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/waveshare/v2/__init__.py rename to pwnagotchi/ui/waveshare/v2/__init__.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/waveshare/v2/waveshare.py b/pwnagotchi/ui/waveshare/v2/waveshare.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/ui/waveshare/v2/waveshare.py rename to pwnagotchi/ui/waveshare/v2/waveshare.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/utils.py b/pwnagotchi/utils.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/utils.py rename to pwnagotchi/utils.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/voice.py b/pwnagotchi/voice.py similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/voice.py rename to pwnagotchi/voice.py diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/requirements.txt b/requirements.txt similarity index 100% rename from sdcard/rootfs/root/pwnagotchi/scripts/requirements.txt rename to requirements.txt diff --git a/sdcard/rootfs/root/pwnagotchi/data/screenrc.auto b/sdcard/rootfs/root/pwnagotchi/data/screenrc.auto deleted file mode 100644 index 9319672..0000000 --- a/sdcard/rootfs/root/pwnagotchi/data/screenrc.auto +++ /dev/null @@ -1,49 +0,0 @@ -defutf8 on - -shell -${SHELL} -defscrollback 1024 -startup_message off -altscreen on -autodetach on -zombie kr - -activity "activity in %n (%t)" -bell_msg "bell in %n (%t)" - -vbell on -vbell_msg "WTF DUDE ??!!" -vbellwait 1 - -# set terminal emulator to xterm mode -term xterm -# Make the output buffer large for (fast) xterms. -termcapinfo xterm* ti@:te@ -# tell screen how to set colors -termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm' -# allow bold colors -attrcolor b ".I" -# erase background with current bg color -defbce "on" - -# ctrl + { left, right } -bindkey ^[[1;5D prev -bindkey ^[[1;5C next -bindkey ^[[5D prev -bindkey ^[[5C next -bindkey ^[b prev -bindkey ^[f next -bindkey ^[[D prev -bindkey ^[[C next - -screen -t shell -screen -t auto-mode /bin/bash -c "/root/pwnagotchi/scripts/main.py" -screen -t bettercap /usr/bin/bettercap -caplet http-ui -eval "!/usr/bin/monstart; set wifi.interface mon0" - -select log - -backtick 1 0 0 cpuusage -backtick 2 5 5 memusage - -hardstatus alwayslastline -hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][cpu %1`][mem %2`][%{B} %m-%d %{W}%c %{g}]' - diff --git a/sdcard/rootfs/root/pwnagotchi/data/screenrc.manual b/sdcard/rootfs/root/pwnagotchi/data/screenrc.manual deleted file mode 100644 index 1d62528..0000000 --- a/sdcard/rootfs/root/pwnagotchi/data/screenrc.manual +++ /dev/null @@ -1,49 +0,0 @@ -defutf8 on - -shell -${SHELL} -defscrollback 1024 -startup_message off -altscreen on -autodetach on -zombie kr - -activity "activity in %n (%t)" -bell_msg "bell in %n (%t)" - -vbell on -vbell_msg "WTF DUDE ??!!" -vbellwait 1 - -# set terminal emulator to xterm mode -term xterm -# Make the output buffer large for (fast) xterms. -termcapinfo xterm* ti@:te@ -# tell screen how to set colors -termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm' -# allow bold colors -attrcolor b ".I" -# erase background with current bg color -defbce "on" - -# ctrl + { left, right } -bindkey ^[[1;5D prev -bindkey ^[[1;5C next -bindkey ^[[5D prev -bindkey ^[[5C next -bindkey ^[b prev -bindkey ^[f next -bindkey ^[[D prev -bindkey ^[[C next - -screen -t shell -screen -t manual-mode /bin/bash -c "/root/pwnagotchi/scripts/main.py --manual" -screen -t bettercap /usr/bin/bettercap -caplet http-ui -eval "!/usr/bin/monstart; set wifi.interface mon0" - -select log - -backtick 1 0 0 cpuusage -backtick 2 5 5 memusage - -hardstatus alwayslastline -hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][cpu %1`][mem %2`][%{B} %m-%d %{W}%c %{g}]' - diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/main.py b/sdcard/rootfs/root/pwnagotchi/scripts/main.py deleted file mode 100755 index 60469e8..0000000 --- a/sdcard/rootfs/root/pwnagotchi/scripts/main.py +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/python3 -import argparse -import time -import logging - -import pwnagotchi -import pwnagotchi.utils as utils -import pwnagotchi.plugins as plugins - -from pwnagotchi.log import SessionParser -from pwnagotchi.agent import Agent -from pwnagotchi.ui.display import Display - -parser = argparse.ArgumentParser() - -parser.add_argument('-C', '--config', action='store', dest='config', default='/root/pwnagotchi/config.yml', - help='Main configuration file.') -parser.add_argument('-U', '--user-config', action='store', dest='user_config', default='/root/custom.yml', - help='If this file exists, configuration will be merged and this will override default values.') - -parser.add_argument('--manual', dest="do_manual", action="store_true", default=False, help="Manual mode.") -parser.add_argument('--clear', dest="do_clear", action="store_true", default=False, - help="Clear the ePaper display and exit.") - -parser.add_argument('--debug', dest="debug", action="store_true", default=False, - help="Enable debug logs.") - -args = parser.parse_args() -config = utils.load_config(args) -utils.setup_logging(args, config) - -plugins.load(config) - -display = Display(config=config, state={'name': '%s>' % pwnagotchi.name()}) -agent = Agent(view=display, config=config) - -logging.info("%s@%s (v%s)" % (pwnagotchi.name(), agent._identity, pwnagotchi.version)) - -for _, plugin in plugins.loaded.items(): - logging.debug("plugin '%s' v%s loaded from %s" % (plugin.__name__, plugin.__version__, plugin.__file__)) - -if args.do_clear: - logging.info("clearing the display ...") - display.clear() - -elif args.do_manual: - logging.info("entering manual mode ...") - - log = SessionParser(config) - logging.info( - "the last session lasted %s (%d completed epochs, trained for %d), average reward:%s (min:%s max:%s)" % ( - log.duration_human, - log.epochs, - log.train_epochs, - log.avg_reward, - log.min_reward, - log.max_reward)) - - while True: - display.on_manual_mode(log) - time.sleep(1) - - if Agent.is_connected(): - plugins.on('internet_available', display, config, log) - -else: - logging.info("entering auto mode ...") - - 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() - # check for free channels to use - agent.check_channels(channels) - # 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) - - # 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, - # WiFi electromagnetic fields affect time like gravitational fields - # affect ours ... neat ^_^ - agent.next_epoch() - except Exception as e: - logging.exception("main loop exception") diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/startup.sh b/sdcard/rootfs/root/pwnagotchi/scripts/startup.sh deleted file mode 100755 index 4d8f959..0000000 --- a/sdcard/rootfs/root/pwnagotchi/scripts/startup.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -# blink 10 times to signal ready state -/usr/bin/bootblink 10 & - -# start a detached screen session with bettercap -if ifconfig | grep usb0 | grep RUNNING; then - sudo -H -u root /usr/bin/screen -dmS pwnagotchi -c /root/pwnagotchi/data/screenrc.manual -else - sudo -H -u root /usr/bin/screen -dmS pwnagotchi -c /root/pwnagotchi/data/screenrc.auto -fi diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..9761640 --- /dev/null +++ b/setup.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +from setuptools import setup, find_packages +import pwnagotchi + +required = [] +with open('requirements.txt') as fp: + for line in fp: + line = line.strip() + if line != "": + required.append(line) + +setup(name='pwnagotchi', + version=pwnagotchi.version, + description='Pwnagotchi is a cute AI that eats WPA handshakes.', + author='evilsocket && the dev team', + author_email='evilsocket@gmail.com', + url='https://pwnagotchi.ai/', + install_requires=required, + scripts=['bin/pwnagotchi'], + license='GPL', + classifiers=[ + 'Programming Language :: Python :: 3', + 'Development Status :: 5 - Production/Stable', + 'License :: OSI Approved :: GNU General Public License (GPL)', + 'Environment :: Console', + ]) \ No newline at end of file