# bananapim2zero armbian latest, DrS nexmon, pytorch, pwnagotchi # install armbian, do initial log in to set up root pw, pi user, etc # # on mine, "uname -a" says: # Linux bananana 6.1.30-sunxi #1 SMP Wed May 24 16:32:53 UTC 2023 armv7l GNU/Linux # I have not figured out how to get the correct version of linux headers installed # armbian-config keeps wanting to install a different version than my kernel # super frustrating.. I managed to get an armbian (jammy/edge, i think) with # 6.2.x kernel to install the 6.1.30-sunxi headers, tar'ed them up, and copied # them to my bananapi running the 6.1.30 kernel (bullseye). untar into /usr/src # and link to /lib/modules/6.1.30-sunxi/build sudo apt -y update sudo apt -y upgrade # follow this to have enough swap to build bettercap # I did this on the bananapi, but it wasn't using dphys-swapfile, so # some errors. It did add the swapfile in addition to the system # default zram swap. The big swap was needed for torch build # sudo fallocate -l 4G /var/swapfile sudo chmod 600 /var/swapfile sudo mkswap /var/swapfile # start the swap service sudo swapon /var/swapfile # make the service permantent sudo bash -c 'cat >> /etc/fstab' < /tmp/dependencies << EOF rsync vim wget screen git build-essential dkms python3-pip python3-smbus unzip gawk libopenmpi-dev libatlas-base-dev libelf-dev libopenjp2-7 libtiff6 tcpdump lsof libgstreamer1.0-0 libavcodec59 libavformat59 libswscale6 libusb-1.0-0-dev libnetfilter-queue-dev libopenmpi3 dphys-swapfile 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 libgl1-mesa-glx 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 # load them in groups of 5. quicker than individual, but doesn't fail all of them # if one goes wrong. cat /tmp/dependencies | xargs -n5 sudo apt install -y # RNDIS # # Skip RNDIS on pi3, pi4, others when you will use ethernet instead of # usb/otg/RNDIS to connect to a desktop computer # # Set up RNDIS (/boot/config.txt, cmdline.txt mods # # these work on raspberry pi: #sudo sh -c "echo 'dtoverlay=dwc2' >>/boot/config.txt" #sudo sh -c "echo -n ' modules-load=dwc2,g_ether' >>/boot/cmdline.txt" #sudo sh -c "echo -n 'options g_ether host_addr=f0:0d:ba:be:f0:0d dev_addr=58:70:77:6e:79:58' >/etc/modprobe.d/g_ether.conf" # use this on armbian echo "g_ether" | sudo tee /etc/modules sudo sh -c "echo -n 'options g_ether use_eem=0 host_addr=f0:0d:ba:be:f0:0d dev_addr=58:70:77:6e:79:58' >/etc/modprobe.d/g_ether.conf" # use this on all OS sudo bash -c 'cat >> /etc/network/interfaces.d/usb0-cfg' <>~/.bashrc #source ~/.bashrc # just install it from apt sudo apt -y install golang go version # see that it installed cd ~/git git clone --depth=1 https://github.com/bettercap/bettercap.git cd bettercap time make build # real 1m31.395s # user 3m18.378s # sys 0m15.582s 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 # copy manu caplet over auto, so bettercap http UI is always available sudo cp /usr/local/share/bettercap/caplets/pwnagotchi-manual.cap /usr/local/share/bettercap/caplets/pwnagotchi-auto.cap # 2. pwngrid cd ~/Downloads wget https://github.com/evilsocket/pwngrid/releases/download/v1.10.3/pwngrid_linux_armhf_v1.10.3.zip unzip pwngrid_linux_armhf_v1.10.3.zip sudo mv pwngrid /usr/bin/ ## generate the keypair sudo pwngrid -generate -keys /etc/pwnagotchi # Anyway…… # STABLE-BASELINES3 and PYTORCH # cd ~ sudo apt install python3-pip # just in case ### install torch from source (takes a long time) cd ~/git git clone --depth=1 https://github.com/pytorch/pytorch --recursive && cd pytorch # new python does not like pip installing packages, but I don't know # the "correct" way to do it, so "--break-system-packages" is is # try installing apt-versions first for i in $(grep -v ^# requirements.txt); do sudo apt -y install python3-$i; done # then pip versions sudo pip install -r requirements.txt --break-system-packages # some definitions ... but some of these don't actually work, so # I accidentally did a complete build from source, with all packages # and third parties it could manage. wow. export USE_CUDA=0 export USE_DISTRIBUTED=0 export USE_MLKDNN=0 export BUILD_TEST=0 export MAX_JOBS=1 # 4 is better for a while, but eventually get bogged # down in swap. I think 1 is better for now. WIP time python3 setup.py bdist_wheel # I forgot "time", so I don't know how long it took sudo python3 setup.py install cd ~/git git clone https://github.com/pytorch/vision.git cd /vision/ time python3 setup.py bdist_wheel # real 85m11.918s #user 70m1.210s #sys 6m16.943s sudo python3 setup.py install # set up dependancies for stable_baselines, instead of building wheels # for these. includes numpy and other time consuming pip installs sudo apt -y install python3-pandas python3-pandas-lib python3-matplotlib python3-cloudpickle sudo apt -y install python3-scipy python3-matplotlib python3-bottleneck python3-numexpr python3-odf python3-openpyxl python3-bs4 python3-html5lib python3-lxml python3-tables sudo apt -y install python3-pycryptodome python3-requests python3-yaml python3-scapy python3-tweepy python3-pil python3-flask python3-flask-cors python3-flaskext.wtf python3-dbus python3-toml python3-websockets python3-spidev sudo pip install stable-baselines3 --break-system-packages # PWNAGOTCHI ###sudo raspi-config # enable SPI interface if ! grep "^overlays=spi-spidev" /boot/armbianEnv.txt; then echo "overlays=spi-spidev" | sudo tee -a /boot/armbianEnv.txt #echo "dtparam=spi=on" | sudo tee -a /boot/config.txt #sudo dtparam spi=on fi # clone your fave repository (I haven't checked in the changes yet) cd ~/git git clone https://github.com/Sniffleupagus/pwnagotchi-snflpgs.git cd pwnagotchi-snflpgs # # requirements.txt for torch and stable-baselines3 # cat > requirements.txt << EOF pycryptodome>=3.9.4 requests>=2.21.0 PyYAML>=5.3.1 scapy>=2.4.3 torch>=2.0.1 torchvision>=0.15.2 stable-baselines3>=1.4.0 tweepy>=3.7.0 file-read-backwards>=2.0.0 inky>=1.2.0 smbus2>=0.3.0 Pillow>=5.4.1 spidev>=3.4 gast>=0.2.2 flask>=1.0.2 flask-cors>=3.0.7 flask-wtf>=0.14.3 dbus-python>=1.2.12 toml>=0.10.0 python-dateutil>=2.8.1 websockets>=8.1 EOF # handful of dependencies sudo pip install -r requirements.txt --break-system-packages sudo ln -s `pwd`/bin/pwnagotchi /usr/local/bin sudo ln -s `pwd`/pwnagotchi /usr/local/lib/python3.11/dist-packages/pwnagotchi sudo mkdir -p /usr/local/share/pwnagotchi/custom-plugins # set up /etc/pwnagotchi/config.toml # # led off, because the Led device isn't /sys/class/leds/led0, its the longer name # sudo bash -c 'cat > /etc/pwnagotchi/config.toml' << EOF main.name = "new_ai" main.custom_plugins = "/usr/local/share/pwnagotchi/custom-plugins" main.plugins.led.enabled = false ui.display.enabled = false ui.web.username = "pwny" ui.web.password = "pwny1234" EOF # Edit GIT_SRC_DIR/pwnagotchi/default.toml to remove ai.params.[alpha,epsilon,lr_schedule], not used in the MlpPolicy (leftover from MlpLstmPolicy) # diff --git a/pwnagotchi/defaults.toml b/pwnagotchi/defaults.toml # index c554968..95eaa36 100644 patch pwnagotchi/defaults.toml < 140 for ch in self._supported_channels) + self._extended_spectrum = any(ch > 150 for ch in self._supported_channels) self._histogram_size, self._observation_shape = featurizer.describe(self._extended_spectrum) Environment.params += [ EOP ########## end edits for gym.py ############# # system configuration from pwnagotchi sourcecode builder/data directory for file in `find builder/data -type f`; do dest=${file#builder/data} if [ -s $dest ]; then echo File $dest exists. Skipping else echo Copying $file to $dest sudo cp -p $file $dest fi done sudo systemctl enable bettercap sudo systemctl enable pwngrid-peer sudo systemctl enable pwnagotchi