From b27acd8dbf3bdbcb12e781d1076d63237af3a750 Mon Sep 17 00:00:00 2001 From: Jeroen Oudshoorn Date: Sun, 29 Oct 2023 22:13:19 +0100 Subject: [PATCH] v2.5.1 Signed-off-by: Jeroen Oudshoorn --- Makefile | 8 +- bin/pwnagotchi | 2 +- builder/pwnagotchi.json.pkr.hcl | 131 ++++++++++++-------------------- builder/pwnagotchi.yml | 4 + pwnagotchi/_version.py | 2 +- pwnagotchi/agent.py | 16 ++-- pwnagotchi/ai/epoch.py | 2 +- pwnagotchi/ai/gym.py | 2 +- pwnagotchi/automata.py | 2 +- 9 files changed, 70 insertions(+), 99 deletions(-) diff --git a/Makefile b/Makefile index 5db27a31..a57d3671 100644 --- a/Makefile +++ b/Makefile @@ -51,9 +51,11 @@ $(SDIST): setup.py pwnagotchi $(PWN_RELEASE).img: | $(PACKER) # If the packer or ansible files are updated, rebuild the image. -$(PWN_RELEASE).img: $(SDIST) builder/pwnagotchi.json builder/pwnagotchi.yml $(shell find builder/data -type f) - sudo $(PACKER) plugins install github.com/solo-io/arm-image - cd builder && sudo $(UNSHARE) $(PACKER) build -var "pwn_hostname=$(PWN_HOSTNAME)" -var "pwn_version=$(PWN_VERSION)" pwnagotchi.json +$(PWN_RELEASE).img: $(SDIST) builder/pwnagotchi.json.pkr.hcl builder/pwnagotchi.yml $(shell find builder/data -type f) + + # sudo $(PACKER) plugins install github.com/solo-io/arm-image + # sudo $(PACKER) plugins install github.com/hashicorp/ansible + cd builder && packer init pwnagotchi.json.pkr.hcl && sudo $(UNSHARE) $(PACKER) build -var "pwn_hostname=$(PWN_HOSTNAME)" -var "pwn_version=$(PWN_VERSION)" pwnagotchi.json.pkr.hcl # If any of these files are updated, rebuild the checksums. $(PWN_RELEASE).sha256: $(PWN_RELEASE).img diff --git a/bin/pwnagotchi b/bin/pwnagotchi index 4ad489a7..5f0c88f9 100755 --- a/bin/pwnagotchi +++ b/bin/pwnagotchi @@ -79,7 +79,7 @@ def do_auto_mode(agent): # 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 + # Wi-Fi electromagnetic fields affect time like gravitational fields # affect ours ... neat ^_^ agent.next_epoch() diff --git a/builder/pwnagotchi.json.pkr.hcl b/builder/pwnagotchi.json.pkr.hcl index 25f123c6..a0fa4ebf 100644 --- a/builder/pwnagotchi.json.pkr.hcl +++ b/builder/pwnagotchi.json.pkr.hcl @@ -1,108 +1,75 @@ -# This file was autogenerated by the BETA 'packer hcl2_upgrade' command. We -# recommend double checking that everything is correct before going forward. We -# also recommend treating this file as disposable. The HCL2 blocks in this -# file can be moved to other files. For example, the variable blocks could be -# moved to their own 'variables.pkr.hcl' file, etc. Those files need to be -# suffixed with '.pkr.hcl' to be visible to Packer. To use multiple files at -# once they also need to be in the same folder. 'packer inspect folder/' -# will describe to you what is in that folder. - -# Avoid mixing go templating calls ( for example ```{{ upper(`string`) }}``` ) -# and HCL2 calls (for example '${ var.string_value_example }' ). They won't be -# executed together and the outcome will be unknown. - -# All generated input variables will be of 'string' type as this is how Packer JSON -# views them; you can change their type later on. Read the variables type -# constraints documentation -# https://www.packer.io/docs/from-1.5/variables#type-constraints for more info. -# "timestamp" template function replacement -locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") } - -# source blocks are generated from your builders; a source can be referenced in -# build blocks. A build block runs provisioner and post-processors on a -# source. Read the documentation for source blocks here: -# https://www.packer.io/docs/from-1.5/blocks/source packer { required_plugins { arm-image = { version = ">= 0.2.7" source = "github.com/solo-io/arm-image" } + ansible = { + version = ">= 1.1.0" + source = "github.com/hashicorp/ansible" + } } } -source "arm-image" "pwnagotchi" { + +variable "pwn_hostname" { + type = string +} + +variable "pwn_version" { + type = string +} + +source "arm-image" "rpi-pwnagotchi" { iso_checksum = "file:https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2023-05-03/2023-05-03-raspios-bullseye-arm64-lite.img.xz.sha256" iso_url = "https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2023-05-03/2023-05-03-raspios-bullseye-arm64-lite.img.xz" - output_filename = "../../../pwnagotchi-${var.pwn_version}-arm64.img" + output_filename = "../../../pwnagotchi-raspios-bullseye-${var.pwn_version}-arm64.img" qemu_binary = "qemu-aarch64-static" target_image_size = 9368709120 + qemu_args = ["-r", "6.1.21-v8+"] } +# "arm-image" "opi-pwnagotchi" { +# iso_checksum = "" +# iso_url = "https://drive.usercontent.google.com/download?id=12DgsOXXgpDTQLRBsh8cKqVGD2FUUMZDk&export=download&authuser=0&confirm=t&uuid=d97afcec-3979-44e2-838a-f17c576a87fb&at=APZUnTWoYAa6oVoxrZWwPP7o8Hn9:1698613336721" +# output_file ="../../../pwnagotchi-orangepi-jammy-${var.pwn_version}-arm64.img" +# qemu_binary = "qemu-aarch64-static" +# target_image_size = 9368709120 +# qemu_args = ["-r", "6.1.21-v8+"] +#} # a build block invokes sources and runs provisioning steps on them. The # documentation for build blocks can be found here: # https://www.packer.io/docs/from-1.5/blocks/build build { - sources = ["source.arm-image.pwnagotchi"] + name = "Pwnagotchi Torch 64bit" + sources = [ + "source.arm-image.rpi-pwnagotchi", + # "source.arm-image.opi-pwnagotchi", + ] provisioner "file" { - destination = "/usr/bin/pwnlib" - source = "../builder/data/usr/bin/pwnlib" - } - provisioner "file" { - destination = "/usr/bin/bettercap-launcher" - source = "../builder/data/usr/bin/bettercap-launcher" - } - provisioner "file" { - destination = "/usr/bin/pwnagotchi-launcher" - source = "../builder/data/usr/bin/pwnagotchi-launcher" - } - provisioner "file" { - destination = "/usr/bin/monstop" - source = "../builder/data/usr/bin/monstop" - } - provisioner "file" { - destination = "/usr/bin/monstart" - source = "../builder/data/usr/bin/monstart" - } - provisioner "file" { - destination = "/usr/bin/hdmion" - source = "../builder/data/usr/bin/hdmion" - } - provisioner "file" { - destination = "/usr/bin/hdmioff" - source = "../builder/data/usr/bin/hdmioff" - } - provisioner "file" { - destination = "/etc/network/interfaces.d/lo-cfg" - source = "../builder/data/etc/network/interfaces.d/lo-cfg" - } - provisioner "file" { - destination = "/etc/network/interfaces.d/wlan0-cfg" - source = "../builder/data/etc/network/interfaces.d/wlan0-cfg" - } - provisioner "file" { - destination = "/etc/network/interfaces.d/usb0-cfg" - source = "../builder/data/etc/network/interfaces.d/usb0-cfg" - } - provisioner "file" { - destination = "/etc/network/interfaces.d/eth0-cfg" - source = "../builder/data/etc/network/interfaces.d/eth0-cfg" - } - provisioner "file" { - destination = "/etc/systemd/system/pwngrid-peer.service" - source = "../builder/data/etc/systemd/system/pwngrid-peer.service" - } - provisioner "file" { - destination = "/etc/systemd/system/pwnagotchi.service" - source = "../builder/data/etc/systemd/system/pwnagotchi.service" - } - provisioner "file" { - destination = "/etc/systemd/system/bettercap.service" - source = "../builder/data/etc/systemd/system/bettercap.service" + destination = "/usr/bin/" + sources = [ + "../builder/data/usr/bin/pwnlib", + "../builder/data/usr/bin/bettercap-launcher", + "../builder/data/usr/bin/pwnagotchi-launcher", + "../builder/data/usr/bin/monstop", + "../builder/data/usr/bin/monstart", + "../builder/data/usr/bin/hdmion", + "../builder/data/usr/bin/hdmioff", + ] } provisioner "shell" { inline = ["chmod +x /usr/bin/*"] } + + provisioner "file" { + destination = "/etc/systemd/system/" + sources = [ + "../builder/data/etc/systemd/system/pwngrid-peer.service", + "../builder/data/etc/systemd/system/pwnagotchi.service", + "../builder/data/etc/systemd/system/bettercap.service", + ] + } provisioner "file" { destination = "/etc/update-motd.d/01-motd" source = "../builder/data/etc/update-motd.d/01-motd" @@ -111,7 +78,7 @@ build { inline = ["chmod +x /etc/update-motd.d/*"] } provisioner "shell" { - inline = ["apt-get -y --allow-releaseinfo-change update", "apt-get -y dist-upgrade", "apt-get install -y ansible"] + inline = ["apt-get -y --allow-releaseinfo-change update", "apt-get -y dist-upgrade", "apt-get install -y --no-install-recommends ansible"] } provisioner "ansible-local" { command = "ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 PWN_VERSION=${var.pwn_version} PWN_HOSTNAME=${var.pwn_hostname} ansible-playbook" diff --git a/builder/pwnagotchi.yml b/builder/pwnagotchi.yml index 408fca6c..fe1c5acb 100644 --- a/builder/pwnagotchi.yml +++ b/builder/pwnagotchi.yml @@ -147,6 +147,10 @@ ARCHFLAGS: "-arch aarch64" tasks: + - name: Show facts available on the system + debug: + var: ansible_facts + - name: Create pi user copy: dest: /boot/userconf diff --git a/pwnagotchi/_version.py b/pwnagotchi/_version.py index e59b17b4..b8c54948 100644 --- a/pwnagotchi/_version.py +++ b/pwnagotchi/_version.py @@ -1 +1 @@ -__version__ = '2.5.0' +__version__ = '2.5.1' diff --git a/pwnagotchi/agent.py b/pwnagotchi/agent.py index d3700502..02baade5 100644 --- a/pwnagotchi/agent.py +++ b/pwnagotchi/agent.py @@ -166,8 +166,8 @@ class Agent(Client, Automata, AsyncAdvertiser, AsyncTrainer): def _filter_included(self, ap): return self._filter is None or \ - self._filter.match(ap['hostname']) is not None or \ - self._filter.match(ap['mac']) is not None + self._filter.match(ap['hostname']) is not None or \ + self._filter.match(ap['mac']) is not None def set_access_points(self, aps): self._access_points = aps @@ -346,7 +346,7 @@ class Agent(Client, Automata, AsyncAdvertiser, AsyncTrainer): # give plugins access to the events try: - plugins.on('bcap_%s' % re.sub(r"[^a-z0-9_]+", "_", jmsg['tag'].lower()), self, jmsg) + plugins.on('bcap_%s' % re.sub(r"[^a-z0-9_]+", "_", jmsg['tag'].lower()), self, jmsg) except Exception as err: logging.error("Processing event: %s" % err) @@ -369,10 +369,7 @@ class Agent(Client, Automata, AsyncAdvertiser, AsyncTrainer): 'hostname'] != '' else ap_mac logging.warning( "!!! captured new handshake on channel %d, %d dBm: %s (%s) -> %s [%s (%s)] !!!", - ap['channel'], - ap['rssi'], - sta['mac'], sta['vendor'], - ap['hostname'], ap['mac'], ap['vendor']) + ap['channel'], ap['rssi'], sta['mac'], sta['vendor'], ap['hostname'], ap['mac'], ap['vendor']) plugins.on('handshake', self, filename, ap, sta) found_handshake = True self._update_handshakes(1 if found_handshake else 0) @@ -436,7 +433,7 @@ class Agent(Client, Automata, AsyncAdvertiser, AsyncTrainer): try: logging.info("sending association frame to %s (%s %s) on channel %d [%d clients], %d dBm...", - ap['hostname'], ap['mac'], ap['vendor'], ap['channel'], len(ap['clients']), ap['rssi']) + ap['hostname'], ap['mac'], ap['vendor'], ap['channel'], len(ap['clients']), ap['rssi']) self.run('wifi.assoc %s' % ap['mac']) self._epoch.track(assoc=True) except Exception as e: @@ -457,7 +454,8 @@ class Agent(Client, Automata, AsyncAdvertiser, AsyncTrainer): try: logging.info("deauthing %s (%s) from %s (%s %s) on channel %d, %d dBm ...", - sta['mac'], sta['vendor'], ap['hostname'], ap['mac'], ap['vendor'], ap['channel'], ap['rssi']) + sta['mac'], sta['vendor'], ap['hostname'], ap['mac'], ap['vendor'], ap['channel'], + ap['rssi']) self.run('wifi.deauth %s' % sta['mac']) self._epoch.track(deauth=True) except Exception as e: diff --git a/pwnagotchi/ai/epoch.py b/pwnagotchi/ai/epoch.py index 707b7488..2ba47212 100644 --- a/pwnagotchi/ai/epoch.py +++ b/pwnagotchi/ai/epoch.py @@ -44,7 +44,7 @@ class Epoch(object): # number of peers seen during this epoch self.num_peers = 0 # cumulative bond factor - self.tot_bond_factor = 0.0 # cum_bond_factor sounded really bad ... + self.tot_bond_factor = 0.0 # cum_bond_factor sounded worse ... # average bond factor self.avg_bond_factor = 0.0 # any activity at all during this epoch? diff --git a/pwnagotchi/ai/gym.py b/pwnagotchi/ai/gym.py index 6179e76e..c188d31d 100644 --- a/pwnagotchi/ai/gym.py +++ b/pwnagotchi/ai/gym.py @@ -99,7 +99,7 @@ class Environment(gym.Env): def step(self, policy): # create the parameters from the policy and update - # update them in the algorithm + # them in the algorithm self._apply_policy(policy) self._epoch_num += 1 diff --git a/pwnagotchi/automata.py b/pwnagotchi/automata.py index 29c77282..25d112a6 100644 --- a/pwnagotchi/automata.py +++ b/pwnagotchi/automata.py @@ -40,7 +40,7 @@ class Automata(object): support_factor = total_encounters / bond_factor return support_factor >= factor - # triggered when it's a sad/bad day but you have good friends around ^_^ + # triggered when it's a sad/bad day, but you have good friends around ^_^ def set_grateful(self): self._view.on_grateful() plugins.on('grateful', self)