############################################################## #######Download and install Raspbian Lite 64Bit############### ############################################################## ######### 2023-02-21-raspios-bullseye-arm64-lite.img ######### ############################################################## #!/usr/bin/env bash # install all dependencies, bettercap and pwngrid, generate keys, download pwnagotchi on rpi WIFI_DEV="mon0" BETTERCAP_PKG="bettercap_linux_aarch64_v2.31.1.zip" PWDGRID_PKG="pwngrid_linux_aarch64_v1.10.3.zip" # raspbian bulleye lite dependencies cat > /tmp/dependencies << EOF rsync vim wget screen golang git build-essential dkms python3-pip python3-smbus unzip gawk libopenmpi-dev libatlas-base-dev libelf-dev libopenjp2-7 libtiff5 tcpdump lsof libgstreamer1.0-0 libavcodec58 libavformat58 libswscale5 libpcap-dev libusb-1.0-0-dev libnetfilter-queue-dev libopenmpi3 dphys-swapfile libraspberrypi0 libraspberrypi-dev libraspberrypi-doc libraspberrypi-bin libdbus-1-dev libdbus-glib-1-dev liblapack-dev libhdf5-dev libc-ares-dev libeigen3-dev fonts-dejavu fonts-dejavu-core fonts-dejavu-extra python3-pil python3-smbus libfuse-dev libatlas-base-dev libopenblas-dev libblas-dev bc libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev fonts-freefont-ttf fbi python3-flask python3-flask-cors python3-flaskext.wtf EOF sudo apt -q update for pkg in $(cat /tmp/dependencies) do sudo apt install -y $pkg done # 1. bettercap wget "https://github.com/bettercap/bettercap/releases/download/v2.31.1/$BETTERCAP_PKG" unzip $BETTERCAP_PKG DOWNLOAD_SHA256_DIGEST="$(cat bettercap_linux_aarch64_v2.31.1.sha256 | awk '{print $2}')" CALCULATED_SHA256="$(sha256sum bettercap | cut -d " " -f1)" if [ "$DOWNLOAD_SHA256_DIGEST" != "$CALCULATED_SHA256" ]; then echo "SHA256_DIGEST does not match" exit 1 fi ## ... check the sha256 digest before doing this ... sudo mv bettercap /usr/bin/ ## install the caplets and the web ui in /usr/local/share/bettercap and quit sudo bettercap -eval "caplets.update; ui.update; quit" || exit ## create system services sudo bash -c 'cat > /usr/bin/bettercap-launcher' << EOF #!/usr/bin/env bash /usr/bin/monstart if [[ \$(ifconfig | grep usb0 | grep RUNNING) ]] || [[ \$(cat /sys/class/net/eth0/carrier) ]]; then # if override file exists, go into auto mode if [ -f /root/.pwnagotchi-auto ]; then /usr/bin/bettercap -no-colors -caplet pwnagotchi-auto -iface mon0 else /usr/bin/bettercap -no-colors -caplet pwnagotchi-manual -iface mon0 fi else /usr/bin/bettercap -no-colors -caplet pwnagotchi-auto -iface mon0 fi EOF sudo chmod u+x /usr/bin/bettercap-launcher sudo bash -c 'cat > /etc/systemd/system/bettercap.service' << EOF [Unit] Description=bettercap api.rest service. Documentation=https://bettercap.org Wants=network.target #After=pwngrid.service [Service] Type=simple PermissionsStartOnly=true ExecStart=/usr/bin/bettercap-launcher Restart=always RestartSec=30 [Install] WantedBy=multi-user.target EOF sudo systemctl enable bettercap.service # 2. pwngrid # method to create pwngrid-peer.service sudo bash -c 'cat > /etc/systemd/system/pwngrid-peer.service' << EOF [Unit] Description=pwngrid peer service. Documentation=https://pwnagotchi.ai Wants=network.target [Service] Type=simple PermissionsStartOnly=true ExecStart=/usr/bin/pwngrid -keys /etc/pwnagotchi -address 127.0.0.1:8666 -client-token /root/.api-enrollment.json -wait -log /var/log/pwngrid-peer.log -iface $WIFI_DEV Restart=always RestartSec=30 [Install] WantedBy=multi-user.target EOF ## download and uncompress code wget "https://github.com/evilsocket/pwngrid/releases/download/v1.10.3/pwngrid_linux_aarch64_v1.10.3.zip" unzip pwngrid_linux_aarch64_v1.10.3.zip ## ... check the sha256 digest before doing this ... sudo mv pwngrid /usr/bin/ ## generate the keypair sudo pwngrid -generate -keys /etc/pwnagotchi ## create system service create_pwngrid_service if ! $PWN_GRID then sudo systemctl stop pwngrid-peer.service sudo systemctl disable pwngrid-peer.service ## disable dependency in bettercap service launch script sudo bash -c "sed -i 's/^After=pwngrid.service/#After=pwngrid.service/g' /etc/systemd/system/bettercap.service" else sudo systemctl enable pwngrid-peer.service fi # 3. pwnagotchi ## download and uncompress code wget "https://github.com/evilsocket/pwnagotchi/archive/v1.5.5.zip" unzip v1.5.5.zip cd pwnagotchi-1.5.5 || exit ################# second part ################# ## Modifying the http-ui.cap file sudo sed -i 's/set api.rest.username user/set api.rest.username pwnagotchi/' /usr/local/share/bettercap/caplets/http-ui.cap sudo sed -i 's/set api.rest.password pass/set api.rest.password pwnagotchi/' /usr/local/share/bettercap/caplets/http-ui.cap ## Install Python 3.7.x ## Add the repo for Python3.7: echo 'deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal main' | sudo tee -a /etc/apt/sources.list echo 'deb-src http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal main' | sudo tee -a /etc/apt/sources.list ## Download key and install python3.7 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA6932366A755776 sudo apt-get update sudo apt-get install -y python3.7 python3.7-dev python3.7-distutils ## Update some Python3.7 modules sudo python3.7 -m pip install --upgrade pip wheel setuptools ## Download and install tensorflow: sudo wget 'https://drive.google.com/uc?export=download&confirm=t&id=1D9IT2WC2mrWOixsNKohxiJJIlY2IzmQQ' -O tensorflow-1.15.0-cp37-cp37m-linux_aarch64.whl sudo python3.7 -m pip install tensorflow-1.15.0-cp37-cp37m-linux_aarch64.whl ## Due to a recent change to gfortran version 10, building scipy v1.3.1 will fail when using any 10.x version. ## Let's setup to use gfortran-9 by default instead sudo apt install -y gcc-9 gfortran-9 sudo unlink /usr/bin/gcc sudo ln -s /usr/bin/gcc-9 /usr/bin/gcc sudo unlink /usr/bin/gfortran sudo ln -s /usr/bin/gfortran-9 /usr/bin/gfortran ## modifying tensorflow/tensorflow-estimator and removing numpy from the requirements.txt sudo sed -i 's/tensorflow==1.13.1/tensorflow==1.15.0/' pwnagotchi-1.5.5/requirements.txt sudo sed -i 's/tensorflow-estimator==1.14.0/tensorflow-estimator==1.15.1/' pwnagotchi-1.5.5/requirements.txt sudo sed -i '/numpy==1.20.2/d' pwnagotchi-1.5.5/requirements.txt ## Last few bits needed to get through requirements.txt pip install scikit-build pip install cython sudo apt install -y cmake sudo pip uninstall numpy sudo pip install numpy --upgrade wget 'http://old.kali.org/kali/pool/main/libp/libpcap/libpcap0.8_1.9.1-4_arm64.deb' -O libpcap0.8_1.9.1-4_arm64.deb sudo dpkg -i libpcap0.8_1.9.1-4_arm64.deb wget https://go.dev/dl/go1.19.4.linux-arm64.tar.gz sudo rm -rf /usr/local/go sudo tar -C /usr/local -xzf /home/pi/go1.19.4.linux-arm64.tar.gz echo $PATH | grep "/usr/local/go/bin" ## Install requirements.txt followed by the Pwnagotchi sudo python3.7 -m pip install -r requirements.txt sudo python3.7 -m pip install . sudo apt --fix-broken install -y sudo pip install protobuf==3.8 sudo apt remove -y python3-mpi4py sudo python3.7 -m pip install --upgrade mpi4py #wget 'http://old.kali.org/kali/pool/main/libp/libpcap/libpcap0.8_1.9.1-4_arm64.deb' -O libpcap0.8_1.9.1-4_arm64.deb sudo dpkg -i libpcap0.8_1.9.1-4_arm64.deb wget https://go.dev/dl/go1.19.4.linux-arm64.tar.gz sudo rm -rf /usr/local/go sudo tar -C /usr/local -xzf /home/pi/go1.19.4.linux-arm64.tar.gz echo $PATH | grep "/usr/local/go/bin" sudo systemctl enable bettercap pwngrid-peer pwnagotchi ## Fix permissions errors sudo chmod 755 /usr/bin/bettercap sudo chown root:root /usr/bin/bettercap sudo chmod 755 /usr/bin/bettercap-launcher sudo chmod 755 /usr/bin/pwngrid sudo chown root:root /usr/bin/pwngrid sudo chmod 755 /usr/local/bin/pwnagotchi sudo chown root:root /usr/local/bin/pwnagotchi sudo chmod 711 /usr/bin/pwnagotchi-launcher sudo chmod +x /usr/bin/monstart sudo chmod +x /usr/bin/monstop sudo chmod +x /etc/systemd/system/pwnagotchi.service sudo chmod +x /etc/systemd/system/pwngrid-peer.service ## Copy the defaults.toml to config.toml and disable the screen sudo cp /usr/local/lib/python3.7/dist-packages/pwnagotchi/defaults.toml /etc/pwnagotchi/config.toml sudo sed -i 's/ui.display.enabled = true/ui.display.enabled = false/' /etc/pwnagotchi/config.toml