Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
Jeroen Oudshoorn
2023-11-02 20:04:28 +01:00
parent 645fbbc054
commit 12d3bf2f86
2 changed files with 49 additions and 130 deletions

View File

@ -145,50 +145,49 @@ build {
} }
} }
#build { build {
# name = "Raspberry Pi 32 Pwnagotchi" name = "Raspberry Pi 32 Pwnagotchi"
# sources = ["source.arm.rpi32-pwnagotchi"] sources = ["source.arm.rpi32-pwnagotchi"]
provisioner "file" {
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" { provisioner "file" {
# destination = "/usr/bin/" destination = "/etc/systemd/system/"
# sources = [ sources = [
# "../builder/data/usr/bin/pwnlib", "../builder/data/etc/systemd/system/pwngrid-peer.service",
# "../builder/data/usr/bin/bettercap-launcher", "../builder/data/etc/systemd/system/pwnagotchi.service",
# "../builder/data/usr/bin/pwnagotchi-launcher", "../builder/data/etc/systemd/system/bettercap.service",
# "../builder/data/usr/bin/monstop", ]
# "../builder/data/usr/bin/monstart", }
# "../builder/data/usr/bin/hdmion", provisioner "file" {
# "../builder/data/usr/bin/hdmioff", destination = "/etc/update-motd.d/01-motd"
# ] source = "../builder/data/etc/update-motd.d/01-motd"
# } }
# provisioner "shell" { provisioner "shell" {
# inline = ["chmod +x /usr/bin/*"] inline = ["chmod +x /etc/update-motd.d/*"]
# } }
provisioner "shell" {
# provisioner "file" { inline = ["apt-get -y --allow-releaseinfo-change update", "apt-get -y dist-upgrade", "apt-get install -y --no-install-recommends ansible"]
# destination = "/etc/systemd/system/" }
# sources = [ provisioner "ansible-local" {
# "../builder/data/etc/systemd/system/pwngrid-peer.service", command = "ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 PWN_VERSION=${var.pwn_version} PWN_HOSTNAME=${var.pwn_hostname} ansible-playbook"
# "../builder/data/etc/systemd/system/pwnagotchi.service", extra_arguments = ["--extra-vars \"ansible_python_interpreter=/usr/bin/python3\""]
# "../builder/data/etc/systemd/system/bettercap.service", playbook_file = "../builder/raspberrypi32.yml"
# ] }
# } }
# 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 --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 = "../builder/raspberrypi32.yml"
# }
#}
build { build {
name = "Orange Pi Pwnagotchi" name = "Orange Pi Pwnagotchi"

View File

@ -209,9 +209,6 @@
dest: /boot/userconf dest: /boot/userconf
content: | content: |
pi:$6$3jNr0GA9KIyt4hmM$efeVIopdMQ8DGgEPCWWlbx3mJJNAYci1lEXGdlky0xPyjqwKNbwTL5SrCcpb4144C4IvzWjn7Iv.QjqmU7iyT/ pi:$6$3jNr0GA9KIyt4hmM$efeVIopdMQ8DGgEPCWWlbx3mJJNAYci1lEXGdlky0xPyjqwKNbwTL5SrCcpb4144C4IvzWjn7Iv.QjqmU7iyT/
tags:
- base
- config
- name: change hostname - name: change hostname
lineinfile: lineinfile:
@ -221,9 +218,6 @@
state: present state: present
when: lookup('file', '/etc/hostname') == "raspberrypi" when: lookup('file', '/etc/hostname') == "raspberrypi"
register: hostname register: hostname
tags:
- base
- config
- name: add hostname to /etc/hosts - name: add hostname to /etc/hosts
lineinfile: lineinfile:
@ -232,9 +226,6 @@
line: "127.0.1.1\t{{pwnagotchi.hostname}}" line: "127.0.1.1\t{{pwnagotchi.hostname}}"
state: present state: present
when: hostname.changed when: hostname.changed
tags:
- base
- config
- name: disable sap plugin for bluetooth.service - name: disable sap plugin for bluetooth.service
lineinfile: lineinfile:
@ -242,26 +233,17 @@
regexp: '^ExecStart=/usr/lib(exec)?/bluetooth/bluetoothd$' regexp: '^ExecStart=/usr/lib(exec)?/bluetooth/bluetoothd$'
line: 'ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=sap' line: 'ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=sap'
state: present state: present
tags:
- config
- base
- name: configure dphys-swapfile - name: configure dphys-swapfile
lineinfile: lineinfile:
path: /etc/dphys-swapfile path: /etc/dphys-swapfile
regexp: "^CONF_SWAPSIZE=.*$" regexp: "^CONF_SWAPSIZE=.*$"
line: "CONF_SWAPSIZE=2048" line: "CONF_SWAPSIZE=2048"
tags:
- config
- base
- name: Create custom plugin directory - name: Create custom plugin directory
file: file:
path: '{{ pwnagotchi.custom_plugin_dir }}' path: '{{ pwnagotchi.custom_plugin_dir }}'
state: directory state: directory
tags:
- pwnagotchi
- build
- name: update apt package cache - name: update apt package cache
apt: apt:
@ -293,23 +275,17 @@
repo: 'https://github.com/the-tcpdump-group/libpcap.git' repo: 'https://github.com/the-tcpdump-group/libpcap.git'
dest: /usr/local/src/libpcap dest: /usr/local/src/libpcap
version: libpcap-1.9 version: libpcap-1.9
tags:
- base
- name: build and install libpcap into /usr/local/lib - name: build and install libpcap into /usr/local/lib
shell: "./configure && make && make install" shell: "./configure && make && make install"
args: args:
executable: /bin/bash executable: /bin/bash
chdir: /usr/local/src/libpcap chdir: /usr/local/src/libpcap
tags:
- base
- name: remove libpcap build folder - name: remove libpcap build folder
file: file:
state: absent state: absent
path: /usr/local/src/libpcap path: /usr/local/src/libpcap
tags:
- base
############################################################### ###############################################################
# Install nexmon to fix wireless scanning (takes 2.5G of space) # Install nexmon to fix wireless scanning (takes 2.5G of space)
@ -319,9 +295,6 @@
- name: build and install nexmon as needed - name: build and install nexmon as needed
include_tasks: nexmon.yml include_tasks: nexmon.yml
loop: "{{ boards }}" loop: "{{ boards }}"
tags:
- base
- build_nexmon
# some pizero2w have the pizeroW wifi chip # some pizero2w have the pizeroW wifi chip
# could this be a link instead of a copy? and force, only if not a link? # could this be a link instead of a copy? and force, only if not a link?
@ -359,7 +332,6 @@
repo: https://github.com/Sniffleupagus/pwnagotchi-snflpgs.git repo: https://github.com/Sniffleupagus/pwnagotchi-snflpgs.git
dest: /usr/local/src/pwnagotchi dest: /usr/local/src/pwnagotchi
register: pwnagotchigit register: pwnagotchigit
tags: pwnagotchi
# is this even necessary? Can't we just link from /home/pi/pwnagotchi to /usr/local/{bin,lib,etc} # is this even necessary? Can't we just link from /home/pi/pwnagotchi to /usr/local/{bin,lib,etc}
# then just git update in the home dir and encourage hacking? # then just git update in the home dir and encourage hacking?
@ -369,7 +341,6 @@
args: args:
chdir: /usr/local/src/pwnagotchi chdir: /usr/local/src/pwnagotchi
when: (pwnagotchigit.changed) or (pip_packages['pwnagotchi'] is undefined) or (pip_packages['pwnagotchi'] != pwnagotchi_version) when: (pwnagotchigit.changed) or (pip_packages['pwnagotchi'] is undefined) or (pip_packages['pwnagotchi'] != pwnagotchi_version)
tags: pwnagotchi
- name: install 32-bit pwnagotchi wheel and dependencies with 32-bit torch wheels - name: install 32-bit pwnagotchi wheel and dependencies with 32-bit torch wheels
pip: pip:
@ -383,26 +354,21 @@
#QEMU_CPU: arm1176 #QEMU_CPU: arm1176
QEMU_UNAME: "{{ kernel.full }}" QEMU_UNAME: "{{ kernel.full }}"
when: (pwnagotchigit.changed) or (pip_packages['pwnagotchi'] is undefined) or (pip_packages['pwnagotchi'] != pwnagotchi_version) when: (pwnagotchigit.changed) or (pip_packages['pwnagotchi'] is undefined) or (pip_packages['pwnagotchi'] != pwnagotchi_version)
tags:
- pwnagotchi
- name: copy pwnagotchi wheel to staging dir - name: copy pwnagotchi wheel to staging dir
ansible.builtin.copy: ansible.builtin.copy:
src: "{{ lookup('fileglob', '/usr/local/src/pwnagotchi/dist/pwnagotchi*.whl') }}" src: "{{ lookup('fileglob', '/usr/local/src/pwnagotchi/dist/pwnagotchi*.whl') }}"
dest: "{{ staging }}/wheels" dest: "{{ staging }}/wheels"
tags: pwnagotchi
- name: create /usr/local/share/pwnagotchi/ folder - name: create /usr/local/share/pwnagotchi/ folder
file: file:
path: /usr/local/share/pwnagotchi/ path: /usr/local/share/pwnagotchi/
state: directory state: directory
tags: pwnagotchi
- name: remove pwnagotchi folder - name: remove pwnagotchi folder
file: file:
state: absent state: absent
path: /usr/local/src/pwnagotchi path: /usr/local/src/pwnagotchi
tags: pwnagotchi
########################################## ##########################################
# #
@ -484,16 +450,13 @@
file: file:
path: /etc/pwnagotchi path: /etc/pwnagotchi
state: directory state: directory
tags: pwnagotchi
- name: check if user configuration exists - name: check if user configuration exists
stat: stat:
path: /etc/pwnagotchi/config.toml path: /etc/pwnagotchi/config.toml
register: user_config register: user_config
tags: pwnagotchi
- name: create /etc/pwnagotchi/config.toml - name: create /etc/pwnagotchi/config.toml
tags: pwnagotchi
copy: copy:
dest: /etc/pwnagotchi/config.toml dest: /etc/pwnagotchi/config.toml
content: | content: |
@ -526,7 +489,6 @@
when: not user_config.stat.exists when: not user_config.stat.exists
- name: set up pi user crontab to kick wifi.recon on bettercap - name: set up pi user crontab to kick wifi.recon on bettercap
tags: pwnagotchi
copy: copy:
dest: /tmp/pi-crontab dest: /tmp/pi-crontab
content: | content: |
@ -556,7 +518,6 @@
*/5 * * * * /home/pi/bin/bcinfo.py -qw >/dev/null 2>&1 */5 * * * * /home/pi/bin/bcinfo.py -qw >/dev/null 2>&1
- name: install pi crontab - name: install pi crontab
tags: pwnagotchi
command: "crontab -u pi /tmp/pi-crontab" command: "crontab -u pi /tmp/pi-crontab"
args: args:
chdir: /tmp chdir: /tmp
@ -564,7 +525,6 @@
ignore_errors: true ignore_errors: true
- name: delete /tmp/pi-crontab - name: delete /tmp/pi-crontab
tags: pwnagotchi
file: file:
state: absent state: absent
path: /tmp/pi-crontab path: /tmp/pi-crontab
@ -578,14 +538,6 @@
file: file:
path: /boot/ssh path: /boot/ssh
state: touch state: touch
tags: base
- name: disable wlan0 in dhcpcd.conf
lineinfile:
dest: /etc/dhcpcd.conf
insertafter: EOF
line: "denyinterfaces wlan0"
tags: base
- name: adjust /boot/config.txt - name: adjust /boot/config.txt
lineinfile: lineinfile:
@ -593,7 +545,6 @@
insertafter: EOF insertafter: EOF
line: '{{ item }}' line: '{{ item }}'
with_items: "{{system.boot_options}}" with_items: "{{system.boot_options}}"
tags: pwnagotchi
- name: adjust /etc/modules - name: adjust /etc/modules
lineinfile: lineinfile:
@ -601,7 +552,6 @@
insertafter: EOF insertafter: EOF
line: '{{ item }}' line: '{{ item }}'
with_items: "{{system.modules}}" with_items: "{{system.modules}}"
tags: pwnagotchi
- name: change root partition - name: change root partition
replace: replace:
@ -609,7 +559,6 @@
backup: no backup: no
regexp: "root=PARTUUID=[a-zA-Z0-9\\-]+" regexp: "root=PARTUUID=[a-zA-Z0-9\\-]+"
replace: "root=/dev/mmcblk0p2" replace: "root=/dev/mmcblk0p2"
tags: base
- name: configure /boot/cmdline.txt - name: configure /boot/cmdline.txt
lineinfile: lineinfile:
@ -619,14 +568,12 @@
backup: no backup: no
regexp: '(.*)$' regexp: '(.*)$'
line: '\1 modules-load=dwc2,g_ether' line: '\1 modules-load=dwc2,g_ether'
tags: pwnagotchi
- name: clone Sniffleupagus pwny utils - name: clone Sniffleupagus pwny utils
git: git:
repo: https://github.com/Sniffleupagus/pwnagotchi-utils.git repo: https://github.com/Sniffleupagus/pwnagotchi-utils.git
dest: /home/pi/git/pwnagotchi-utils dest: /home/pi/git/pwnagotchi-utils
register: sniffleupagus_utils_fetched register: sniffleupagus_utils_fetched
tags: pwnagotchi
- name: grab list of utils - name: grab list of utils
ansible.builtin.find: ansible.builtin.find:
@ -634,7 +581,6 @@
patterns: '*.py' patterns: '*.py'
recurse: no recurse: no
register: sniffleupagus_utils register: sniffleupagus_utils
tags: pwnagotchi
- name: Create home bin directory - name: Create home bin directory
file: file:
@ -643,7 +589,6 @@
owner: 'pi' owner: 'pi'
group: 'pi' group: 'pi'
state: directory state: directory
tags: pwnagotchi
- name: copy to /home/pi/bin - name: copy to /home/pi/bin
ansible.builtin.copy: ansible.builtin.copy:
@ -654,7 +599,6 @@
owner: 'pi' owner: 'pi'
group: 'pi' group: 'pi'
with_items: '{{ sniffleupagus_utils.files }}' with_items: '{{ sniffleupagus_utils.files }}'
tags: pwnagotchi
# evil socket plugins # evil socket plugins
- name: clone pwnagotchi community plugin repository - name: clone pwnagotchi community plugin repository
@ -662,7 +606,6 @@
repo: https://github.com/evilsocket/pwnagotchi-plugins-contrib.git repo: https://github.com/evilsocket/pwnagotchi-plugins-contrib.git
dest: /usr/local/src/pwnagotchi-plugins-contrib dest: /usr/local/src/pwnagotchi-plugins-contrib
register: evilsocket_plugins_fetched register: evilsocket_plugins_fetched
tags: pwnagotchi
- name: grab list of plugins - name: grab list of plugins
ansible.builtin.find: ansible.builtin.find:
@ -670,7 +613,6 @@
patterns: '*.py' patterns: '*.py'
recurse: no recurse: no
register: evilsocket_plugins register: evilsocket_plugins
tags: pwnagotchi
- name: copy to custom plugins - name: copy to custom plugins
ansible.builtin.copy: ansible.builtin.copy:
@ -679,52 +621,24 @@
follow: yes follow: yes
with_items: '{{ evilsocket_plugins.files }}' with_items: '{{ evilsocket_plugins.files }}'
ignore_errors: true ignore_errors: true
tags: pwnagotchi
# MORE plugins
- name: clone Sniffleupagus plugins
git:
repo: https://github.com/Sniffleupagus/pwnagotchi_plugins.git
dest: /home/pi/git/pwnagotchi_plugins
register: sniffleupagus_plugins_fetched
tags: pwnagotchi
- name: grab list of plugins
ansible.builtin.find:
paths: /home/pi/git/pwnagotchi_plugins
patterns: '*.py'
recurse: no
register: sniffleupagus_plugins
tags: pwnagotchi
- name: copy to custom plugins
ansible.builtin.copy:
src: '{{ item.path }}'
dest: '{{ pwnagotchi.custom_plugin_dir }}'
follow: yes
with_items: '{{ sniffleupagus_plugins.files }}'
tags: pwnagotchi
- name: Add pwnlog alias - name: Add pwnlog alias
lineinfile: lineinfile:
dest: /home/pi/.bashrc dest: /home/pi/.bashrc
line: "\nalias pwnlog='tail -f -n300 /var/log/pwn*.log | sed --unbuffered \"s/,[[:digit:]]\\{3\\}\\]//g\" | cut -d \" \" -f 2-'" line: "\nalias pwnlog='tail -f -n300 /var/log/pwn*.log | sed --unbuffered \"s/,[[:digit:]]\\{3\\}\\]//g\" | cut -d \" \" -f 2-'"
insertafter: EOF insertafter: EOF
tags: pwnagotchi
- name: Add pwnver alias - name: Add pwnver alias
lineinfile: lineinfile:
dest: /home/pi/.bashrc dest: /home/pi/.bashrc
line: "\nalias pwnver='python3 -c \"import pwnagotchi as p; print(p.__version__)\"'" line: "\nalias pwnver='python3 -c \"import pwnagotchi as p; print(p.__version__)\"'"
insertafter: EOF insertafter: EOF
tags: pwnagotchi
- name: Add pwnkill alias to restart pwnagotchi with a signal - name: Add pwnkill alias to restart pwnagotchi with a signal
lineinfile: lineinfile:
dest: /home/pi/.bashrc dest: /home/pi/.bashrc
line: "\nalias pwnkill='sudo killall -USR1 pwnagotchi'" line: "\nalias pwnkill='sudo killall -USR1 pwnagotchi'"
insertafter: EOF insertafter: EOF
tags: pwnagotchi
- name: add firmware packages to hold - name: add firmware packages to hold
dpkg_selections: dpkg_selections:
@ -745,7 +659,6 @@
enabled: true enabled: true
state: stopped state: stopped
with_items: "{{ services.enable }}" with_items: "{{ services.enable }}"
tags: pwnagotchi
- name: remove golang build libraries - name: remove golang build libraries
file: file:
@ -799,6 +712,13 @@
state: absent state: absent
path: /root/.cache path: /root/.cache
- name: remove ssh keys
file:
state: absent
path: "{{ item }}"
with_fileglob:
- "/etc/ssh/ssh_host*_key*"
handlers: handlers:
- name: reload systemd services - name: reload systemd services
systemd: systemd: