From 9ba23d77d1092628479064a88b8345161d9a5b56 Mon Sep 17 00:00:00 2001 From: jayofelony Date: Sun, 25 Feb 2024 13:35:23 +0100 Subject: [PATCH] Update Makefile Remove bananagotchi files --- Makefile | 2 - builder/data/64bit/bananagotchi.json.pkr.hcl | 80 --- builder/data/64bit/bananagotchi.yml | 514 ------------------- 3 files changed, 596 deletions(-) delete mode 100644 builder/data/64bit/bananagotchi.json.pkr.hcl delete mode 100644 builder/data/64bit/bananagotchi.yml diff --git a/Makefile b/Makefile index 3f411489..4e520fc2 100644 --- a/Makefile +++ b/Makefile @@ -44,8 +44,6 @@ packer: curl https://releases.hashicorp.com/packer/$(PACKER_VERSION)/packer_$(PACKER_VERSION)_linux_amd64.zip -o /tmp/packer.zip unzip /tmp/packer.zip -d /tmp sudo mv /tmp/packer /usr/bin/packer - git clone https://github.com/solo-io/packer-builder-arm-image /tmp/packer-builder-arm-image - cd /tmp/packer-builder-arm-image && go get -d ./... && go build image: clean packer cd builder && sudo /usr/bin/packer init combined.json.pkr.hcl && sudo $(UNSHARE) /usr/bin/packer build -var "pwn_hostname=$(PWN_HOSTNAME)" -var "pwn_version=$(PWN_VERSION)" combined.json.pkr.hcl diff --git a/builder/data/64bit/bananagotchi.json.pkr.hcl b/builder/data/64bit/bananagotchi.json.pkr.hcl deleted file mode 100644 index 0ca2585e..00000000 --- a/builder/data/64bit/bananagotchi.json.pkr.hcl +++ /dev/null @@ -1,80 +0,0 @@ -packer { - required_plugins { - ansible = { - source = "github.com/hashicorp/ansible" - version = ">= 1.1.1" - } - } -} - -variable "pwn_hostname" { - type = string -} - -variable "pwn_version" { - type = string -} - -source "arm-image" "bananagotchi" { - iso_checksum = "file:https://github.com/jayofelony/bananagotchi/releases/download/v1.0/bpim40.img.xz.sha256" - iso_url = "https://github.com/jayofelony/bananagotchi/releases/download/v1.0/bpim40.img.xz" - image_type = "armbian" - image_arch = "arm64" - qemu_args = ["-r", "6.1.31-sun50iw9"] - target_image_size = 9368709120 - output_filename = "../../../bananagotchi-${var.pwn_version}.img" -} - -# 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 { - name = "bananagotchi" - sources = ["source.arm-image.bananagotchi"] - - - provisioner "file" { - destination = "/usr/bin/" - sources = [ - "data/64bit/usr/bin/bettercap-launcher", - "data/64bit/usr/bin/hdmioff", - "data/64bit/usr/bin/hdmion", - "data/64bit/usr/bin/monstart", - "data/64bit/usr/bin/monstop", - "data/64bit/usr/bin/pwnagotchi-launcher", - "data/64bit/usr/bin/pwnlib", - ] - } - provisioner "shell" { - inline = ["chmod +x /usr/bin/*"] - } - - provisioner "file" { - destination = "/etc/systemd/system/" - sources = [ - "data/64bit/etc/systemd/system/bettercap.service", - "data/64bit/etc/systemd/system/pwnagotchi.service", - "data/64bit/etc/systemd/system/pwngrid-peer.service", - ] - } - - provisioner "file" { - destination = "/etc/update-motd.d/01-motd" - source = "data/64bit/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 --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" - extra_arguments = ["--extra-vars \"ansible_python_interpreter=/usr/bin/python3\""] - playbook_file = "data/64bit/bananagotchi.yml" - } -} \ No newline at end of file diff --git a/builder/data/64bit/bananagotchi.yml b/builder/data/64bit/bananagotchi.yml deleted file mode 100644 index 0fadefeb..00000000 --- a/builder/data/64bit/bananagotchi.yml +++ /dev/null @@ -1,514 +0,0 @@ ---- -- hosts: - - 127.0.0.1 - gather_facts: true - become: true - vars: - kernel: - min: "6.1" - full: "6.1.31-sun50iw9" - pwnagotchi: - hostname: "{{ lookup('env', 'PWN_HOSTNAME') | default('bananagotchi', true) }}" - version: "{{ lookup('env', 'PWN_VERSION') | default('pwnagotchi-torch', true) }}" - system: - boot_options: - - "dtoverlay=dwc2" - - "dtoverlay=spi1-3cs" - - "dtparam=i2c1=on" - - "dtparam=i2c_arm=on" - - "dtparam=spi=on" - - "gpu_mem=16" - modules: - - "i2c-dev" - services: - enable: - - bettercap.service - - fstrim.timer - - pwnagotchi.service - - pwngrid-peer.service - - zramswap.service - disable: - - apt-daily-upgrade.service - - apt-daily-upgrade.timer - - apt-daily.service - - apt-daily.timer - - bluetooth.service - - ifup@wlan0.service - packages: - caplets: - source: "https://github.com/jayofelony/caplets.git" - bettercap: - source: "https://github.com/jayofelony/bettercap.git" - url: "https://github.com/jayofelony/bettercap/releases/download/2.32.2/bettercap-2.32.2.zip" - ui: "https://github.com/bettercap/ui/releases/download/v1.3.0/ui.zip" - pwngrid: - source: "https://github.com/jayofelony/pwngrid.git" - url: "https://github.com/jayofelony/pwngrid/releases/download/v1.10.5/pwngrid-1.10.5-aarch64.zip" - apt: - downgrade: - - libpcap-dev_1.9.1-4_arm64.deb - - libpcap0.8-dbg_1.9.1-4_arm64.deb - - libpcap0.8-dev_1.9.1-4_arm64.deb - - libpcap0.8_1.9.1-4_arm64.deb - hold: - - firmware-atheros - - firmware-brcm80211 - - firmware-libertas - - firmware-misc-nonfree - - firmware-realtek - - libpcap-dev - - libpcap0.8 - - libpcap0.8-dbg - - libpcap0.8-dev - remove: - - avahi-daemon - - dhpys-swapfile - - libcurl-ocaml-dev - - libssl-ocaml-dev - - nfs-common - - triggerhappy - - wpasupplicant - install: - - aircrack-ng - - autoconf - - bc - - bison - - bluez - - build-essential - - curl - - dkms - - fbi - - flex - - fonts-dejavu - - fonts-dejavu-core - - fonts-dejavu-extra - - fonts-freefont-ttf - - g++ - - gawk - - gcc-arm-none-eabi - - git - - hcxtools - - libatlas-base-dev - - libavcodec59 - - libavformat59 - - libblas-dev - - libbluetooth-dev - - libbz2-dev - - libc-ares-dev - - libc6-dev - - libcap-dev - - libcurl-ocaml-dev - - libdbus-1-dev - - libdbus-glib-1-dev - - libeigen3-dev - - libelf-dev - - libffi-dev - - libfl-dev - - libfuse-dev - - libgdbm-dev - - libgl1-mesa-glx - - libgmp3-dev - - libgstreamer1.0-0 - - libhdf5-dev - - liblapack-dev - - libncursesw5-dev - - libnetfilter-queue-dev - - libopenblas-dev - - libopenjp2-7 - - libopenmpi-dev - - libopenmpi3 - - libpcap-dev - - libsqlite3-dev - - libssl-dev - - libssl-ocaml-dev - - libtiff6 - - libtool - - libusb-1.0-0-dev - - lsof - - make - - python3-dbus - - python3-flask - - python3-flask-cors - - python3-flaskext.wtf - - python3-gast - - python3-pil - - python3-pip - - python3-pycryptodome - - python3-requests - - python3-scapy - - python3-setuptools - - python3-smbus - - python3-smbus2 - - python3-spidev - - python3-tweepy - - python3-werkzeug - - python3-yaml - - qpdf - - rsync - - screen - - tcpdump - - texinfo - - time - - tk-dev - - unzip - - vim - - wget - - wl - - xxd - - zlib1g-dev - - zram-tools - - tasks: - # First we install packages - - name: install packages - apt: - name: "{{ packages.apt.install }}" - state: present - update_cache: yes - install_recommends: false - - - name: set resolv.conf - blockinfile: - dest: /etc/resolv.conf - state: present - block: | - nameserver 8.8.8.8 - nameserver 8.8.4.4 - insertafter: EOF - - - name: set g_ether and i2c-dev - blockinfile: - dest: /etc/modules-load.d/modules.conf - state: present - insertafter: EOF - block: | - i2c-dev - g_ether - - - name: change hostname - lineinfile: - dest: /etc/hostname - regexp: '^bananapim4zero' - line: "{{pwnagotchi.hostname}}" - state: present - when: lookup('file', '/etc/hostname') == "bananapim4zero" - register: hostname - - - name: add hostname to /etc/hosts - lineinfile: - dest: /etc/hosts - regexp: '^127\.0\.1\.1[ \t]+bananapim4zero' - line: "127.0.1.1\t{{pwnagotchi.hostname}}" - state: present - when: hostname.changed - - # Now we disable sap and a2dp, we don't use them on rpi - - name: disable sap plugin for bluetooth.service - lineinfile: - dest: /lib/systemd/system/bluetooth.service - regexp: '^ExecStart=/usr/libexec/bluetooth/bluetoothd$' - line: 'ExecStart=/usr/libexec/bluetooth/bluetoothd --noplugin=sap,a2dp' - state: present - - ########################################### - # - # libpcap v1.9 - build from source - # - ########################################### - - # check for presence, then it can re-run in later parts if needed - # use the "make" built in - - # install libpcap before bettercap and pwngrid, so they use it - - name: clone libpcap v1.9 from github - git: - repo: 'https://github.com/the-tcpdump-group/libpcap.git' - dest: /usr/local/src/libpcap - version: libpcap-1.9 - - - name: build and install libpcap into /usr/local/lib - shell: "./configure && make && make install" - args: - executable: /bin/bash - chdir: /usr/local/src/libpcap - - - name: remove libpcap build folder - file: - state: absent - path: /usr/local/src/libpcap - - - name: create symlink /usr/local/lib/libpcap.so.1.9.1 - file: - src: /usr/local/lib/libpcap.so.1.9.1 - dest: /usr/local/lib/libpcap.so.0.8 - state: link - - # install latest hcxtools - - - name: clone hcxtools - git: - repo: https://github.com/ZerBea/hcxtools.git - dest: /usr/local/src/hcxtools - - - name: install hcxtools - shell: "make && make install" - args: - executable: /bin/bash - chdir: /usr/local/src/hcxtools - - - name: remove hcxtools directory - file: - state: absent - path: /usr/local/src/hcxtools - - - name: Create custom plugin directory - file: - path: /usr/local/share/pwnagotchi/custom-plugins/ - state: directory - - - name: Create custom config directory - file: - path: /etc/pwnagotchi/conf.d/ - state: directory - - - name: clone pwnagotchi repository - git: - repo: https://github.com/jayofelony/pwnagotchi.git - dest: /usr/local/src/pwnagotchi - - - name: build pwnagotchi wheel - command: "pip3 install . --no-cache-dir --break-system-packages" - args: - chdir: /usr/local/src/pwnagotchi - - - name: remove pwnagotchi folder - file: - state: absent - path: /usr/local/src/pwnagotchi - - - name: create /usr/local/share/pwnagotchi/ folder - file: - path: /usr/local/share/pwnagotchi/ - state: directory - - - name: Install go-1.21 - unarchive: - src: https://go.dev/dl/go1.21.5.linux-arm64.tar.gz - dest: /usr/local - remote_src: yes - register: golang - - - name: Update .bashrc for go-1.21 - blockinfile: - dest: /home/pi/.bashrc - state: present - block: | - export GOPATH=$HOME/go - export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin - when: golang.changed - - - name: download pwngrid - git: - repo: "{{ packages.pwngrid.source }}" - dest: /usr/local/src/pwngrid - - - name: install pwngrid - shell: "export GOPATH=$HOME/go && export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin && go mod tidy && make && make install" - args: - executable: /bin/bash - chdir: /usr/local/src/pwngrid - - - name: remove pwngrid folder - file: - state: absent - path: /usr/local/src/pwngrid - - - name: download bettercap - git: - repo: "{{ packages.bettercap.source }}" - dest: /usr/local/src/bettercap - - - name: install bettercap 2.32.2 - shell: "export GOPATH=$HOME/go && export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin && go mod tidy && make && make install" - args: - executable: /bin/bash - chdir: /usr/local/src/bettercap - - - name: remove bettercap folder - file: - state: absent - path: /usr/local/src/bettercap - - #- name: download and install bettercap - # unarchive: - # src: "{{ packages.bettercap.url }}" - # dest: /usr/local/bin - # remote_src: yes - # exclude: - # - README.md - # - LICENSE.md - # mode: 0755 - - - name: clone bettercap caplets - git: - repo: "{{ packages.caplets.source }}" - dest: /tmp/caplets - register: capletsgit - - - name: install bettercap caplets - make: - chdir: /tmp/caplets - target: install - when: capletsgit.changed - - - name: download and install bettercap ui - unarchive: - src: "{{ packages.bettercap.ui }}" - dest: /usr/local/share/bettercap/ - remote_src: yes - mode: 0755 - - # to always have the bettercap webui available (because why not?) - - name: copy pwnagotchi-manual over pwnagotchi-auto caplet - ansible.builtin.copy: - src: /usr/local/share/bettercap/caplets/pwnagotchi-manual.cap - dest: /usr/local/share/bettercap/caplets/pwnagotchi-auto.cap - force: true - ignore_errors: true - - - name: create /etc/pwnagotchi folder - file: - path: /etc/pwnagotchi - state: directory - - - name: check if user configuration exists - stat: - path: /etc/pwnagotchi/config.toml - register: user_config - - - name: create /etc/pwnagotchi/config.toml - copy: - dest: /etc/pwnagotchi/config.toml - content: | - # Add your configuration overrides on this file any configuration changes done to default.toml will be lost! - # Example: - # ui.display.enabled = true - # ui.display.type = "waveshare_2" - when: not user_config.stat.exists - - - name: Delete motd - file: - state: absent - path: /etc/motd - - - name: Delete motd 10-uname - file: - state: absent - path: /etc/update-motd.d/10-uname - - - name: Add pwnlog alias - lineinfile: - dest: /home/pi/.bashrc - line: "\nalias pwnlog='tail -f -n300 /var/log/pwn*.log | sed --unbuffered \"s/,[[:digit:]]\\{3\\}\\]//g\" | cut -d \" \" -f 2-'" - insertafter: EOF - - - name: Add pwnver alias - lineinfile: - dest: /home/pi/.bashrc - line: "\nalias pwnver='python3 -c \"import pwnagotchi as p; print(p.__version__)\"'" - insertafter: EOF - - - name: Add pwnkill alias to restart pwnagotchi with a signal - lineinfile: - dest: /home/pi/.bashrc - line: "\nalias pwnkill='sudo killall -USR1 pwnagotchi'" - insertafter: EOF - - - name: add firmware packages to hold - dpkg_selections: - name: "{{ item }}" - selection: hold - with_items: "{{ packages.apt.hold }}" - - - name: disable unnecessary services - systemd: - name: "{{ item }}" - state: stopped - enabled: no - with_items: "{{ services.disable }}" - - - name: enable services - systemd: - name: "{{ item }}" - enabled: true - state: stopped - with_items: "{{ services.enable }}" - register: enabled - - - name: make /root readable, becauase that's where all the files are - file: - path: /root - mode: '755' - - - name: fix permissions on /home/pi - file: - path: /home/pi - owner: pi - group: pi - recurse: true - - - name: remove pre-collected packages zip - file: - path: /root/go_pkgs.tgz - state: absent - - - name: remove /root/go folder - file: - state: absent - path: /root/go - - - name: remove /usr/local/go folder - file: - state: absent - path: /usr/local/go - - - name: remove pip cache - file: - state: absent - path: /root/.cache/pip - - - name: remove ssh keys - file: - state: absent - path: "{{ item }}" - with_fileglob: - - "/etc/ssh/ssh_host*_key*" - - - name: regenerate ssh keys - shell: "dpkg-reconfigure openssh-server" - args: - executable: /bin/bash - - # Now we remove packages - - name: remove unnecessary apt packages - apt: - name: "{{ packages.apt.remove }}" - state: absent - purge: yes - register: removed - - - name: remove dependencies that are no longer required - apt: - autoremove: yes - when: removed.changed - - - name: clean apt cache - apt: - autoclean: true - when: removed.changed - - handlers: - - name: reload systemd services - systemd: - daemon_reload: yes - when: enabled.changed \ No newline at end of file