diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml index 105ce2da..dd4c951e 100644 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -1,5 +1,6 @@ + diff --git a/.idea/misc.xml b/.idea/misc.xml index dc9ea490..6178365c 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/.idea/pwnagotchi.iml b/.idea/pwnagotchi.iml index 38d1fd89..ad51e808 100644 --- a/.idea/pwnagotchi.iml +++ b/.idea/pwnagotchi.iml @@ -4,7 +4,7 @@ - + diff --git a/Makefile b/Makefile index e64c9a2f..5db27a31 100644 --- a/Makefile +++ b/Makefile @@ -54,8 +54,6 @@ $(PWN_RELEASE).img: | $(PACKER) $(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 - sudo chown -R $$USER:$$USER builder/images - mv builder/images/* ../../../ # If any of these files are updated, rebuild the checksums. $(PWN_RELEASE).sha256: $(PWN_RELEASE).img diff --git a/builder/pwnagotchi.json b/builder/pwnagotchi.json index b7d3dff8..554c1653 100644 --- a/builder/pwnagotchi.json +++ b/builder/pwnagotchi.json @@ -7,7 +7,7 @@ "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", "target_image_size": 9368709120, "qemu_binary": "qemu-aarch64-static", - "output_filename": "images/pwnagotchi-{{user `pwn_version`}}-arm64.img" + "output_filename": "../../../pwnagotchi-{{user `pwn_version`}}-arm64.img" } ], "provisioners": [ @@ -87,6 +87,11 @@ "chmod +x /usr/bin/*" ] }, + { + "type": "file", + "source": "../builder/data/etc/update-motd.d/01-motd", + "destination": "/etc/update-motd.d/01-motd", + }, { "type": "shell", "inline": [ diff --git a/builder/pwnagotchi.json.pkr.hcl b/builder/pwnagotchi.json.pkr.hcl new file mode 100644 index 00000000..25f123c6 --- /dev/null +++ b/builder/pwnagotchi.json.pkr.hcl @@ -0,0 +1,121 @@ +# 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" + } + } +} +source "arm-image" "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" + qemu_binary = "qemu-aarch64-static" + target_image_size = 9368709120 +} + +# 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"] + + 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" + } + provisioner "shell" { + inline = ["chmod +x /usr/bin/*"] + } + provisioner "file" { + destination = "/etc/update-motd.d/01-motd" + source = "../builder/data/etc/update-motd.d/01-motd" + } + provisioner "shell" { + 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"] + } + provisioner "ansible-local" { + command = "ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 PWN_VERSION=${var.pwn_version} PWN_HOSTNAME=${var.pwn_hostname} ansible-playbook" + extra_arguments = ["--extra-vars \"ansible_python_interpreter=/usr/bin/python3\""] + playbook_file = "../builder/pwnagotchi.yml" + } +} diff --git a/builder/pwnagotchi.yml b/builder/pwnagotchi.yml index 654f4b0a..25ec666c 100644 --- a/builder/pwnagotchi.yml +++ b/builder/pwnagotchi.yml @@ -65,7 +65,6 @@ - libraspberrypi-dev - libraspberrypi-doc - libraspberrypi-bin - - ansible install: - bluez - raspberrypi-kernel-headers @@ -146,7 +145,7 @@ - libusb-1.0-0-dev - libnetfilter-queue-dev environment: - ARCHFLAGS: "-arch armv8" + ARCHFLAGS: "-arch arm64" tasks: - name: Create pi user @@ -154,7 +153,7 @@ name: pi password: "{{ 'raspberry' | password_hash('sha512') }}" shell: /bin/bash - update_password: on_create + generate_ssh_key: true - name: change hostname lineinfile: