Skip to content

Instantly share code, notes, and snippets.

@someguycrafting
Last active May 19, 2022 06:27
Show Gist options
  • Save someguycrafting/ce830dd957e1098fcaa051e42fc18db1 to your computer and use it in GitHub Desktop.
Save someguycrafting/ce830dd957e1098fcaa051e42fc18db1 to your computer and use it in GitHub Desktop.
Raspberry PI 3 / Zero Wi-Fi monitor mode setup
#!/bin/bash
# Thanks to all the nice folks @seemoo-lab for making this possible.
# See: https://github.com/seemoo-lab/nexmon
# This script should be run as root (i.e: sudo ./nexmon.sh) from the /home/pi/ directory!
function info {
tput bold;
tput setaf 3;
echo $1;
tput sgr0;
}
info "=== Updating system ==="
apt update
apt remove wpasupplicant -y
apt autoremove -y
apt upgrade -y
info "=== Installing dependencies ==="
apt install raspberrypi-kernel-headers git libgmp3-dev gawk qpdf bison flex make -y
info "=== Cloning patched driver repo ==="
git clone https://github.com/seemoo-lab/nexmon.git
if [ -f /usr/lib/arm-linux-gnueabihf/libisl.so.10 ]
info "=== libisl exits, skipping build ==="
else
info "=== Building libisl ==="
cd /home/pi/nexmon/buildtools/isl-0.10
./configure
make
make install
ln -s /usr/local/lib/libisl.so /usr/lib/arm-linux-gnueabihf/libisl.so.10
fi
info "=== Building tools ==="
cd /home/pi/nexmon/
source setup_env.sh
make
info "=== Building patches ==="
cd /home/pi/nexmon/patches/bcm43430a1/7_45_41_46/nexmon/
make
info "=== Installing patches ==="
make backup-firmware
make install-firmware
info "=== Building monitor mode utility ==="
cd /home/pi/nexmon/utilities/nexutil/
make && make install
info "=== Setting reboot options for customized driver ==="
orig_driver_loc=$(modinfo brcmfmac | grep -o "filename:.*" | cut -f2 -d:)
mv $orig_driver_loc /home/pi/nexmon/brcmfmac.ko.orig
cp /home/pi/nexmon/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac_kernel49/brcmfmac.ko $orig_driver_loc
depmod -a
info "=== Installing Python libraries ==="
echo "Installing PIP ..."
apt install python3-pip -y
echo "Upgrading PIP ..."
pip3 install --upgrade pip
echo "Installing scapy"
apt install python3-scapy
echo "Installing netaddr"
pip3 install netaddr
info "[SETUP FINISHED]"
@SpielmannCode
Copy link

SpielmannCode commented Dec 9, 2021

Thanks a lot for posting this Script. It helped me a lot. However, when runing, i get a syntax error around the else command in line 29. Is there a then missing after the if statement?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment