From 8f60b41a284efcd2f798aa439a6cdc75ef060faf 2018-11-25 02:44:12 From: Unknown Date: 2018-11-25 02:44:12 Subject: [PATCH] Nexmon --- diff --git a/README.md b/README.md index 21359ac..b718d6d 100644 --- a/README.md +++ b/README.md @@ -234,7 +234,13 @@ Path to a directory (`xf86-video-fbturbo`) of [hardware accelerated Xorg video d Install and enable the [Source code for ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) `vcgencmd`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling. ##### `VIDEOCORESRC_DIR`="" -Path to a directory (`userland`) of [Source code for ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) that will be copied, configured, build and installed inside the chroot. +Path to a directory (`userland`) of [Source code for a C-based firmware patching framework for Broadcom/Cypress WiFi chips that enables you to write your own firmware patches, for example, to enable monitor mode with radiotap headers and frame injection](https://github.com/seemoo-lab/nexmon.git) that will be copied, configured, build and installed inside the chroot. + +##### `ENABLE_NEXMON`=false +Install and enable the [Source code for a C-based firmware patching framework for Broadcom/Cypress WiFi chips that enables you to write your own firmware patches, for example, to enable monitor mode with radiotap headers and frame injection](https://github.com/seemoo-lab/nexmon.git). + +##### `NEXMON_DIR`="" +Path to a directory (`nexmon`) of [Source code for ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) that will be copied, configured, build and installed inside the chroot. ##### `ENABLE_IPTABLES`=false Enable iptables IPv4/IPv6 firewall. Simplified ruleset: Allow all outgoing connections. Block all incoming connections except to OpenSSH service. diff --git a/bootstrap.d/15-rpi-config.sh b/bootstrap.d/15-rpi-config.sh index f718b9c..56aab27 100644 --- a/bootstrap.d/15-rpi-config.sh +++ b/bootstrap.d/15-rpi-config.sh @@ -74,7 +74,7 @@ if [ "$ENABLE_PRINTK" = true ] ; then fi # Install udev rule for serial alias -install_readonly files/etc/99-com.rules "${ETC_DIR}/udev/rules.d/99-com.rules" +install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules" if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then diff --git a/bootstrap.d/44-nexmon_monitor_patch.sh b/bootstrap.d/44-nexmon_monitor_patch.sh new file mode 100644 index 0000000..5563518 --- /dev/null +++ b/bootstrap.d/44-nexmon_monitor_patch.sh @@ -0,0 +1,49 @@ +# +# Build and Setup fbturbo Xorg driver +# + +# Load utility functions +. ./functions.sh + +# Build nexmon firmware outside the build system, if we can. +cd "${basedir}" +git clone https://github.com/seemoo-lab/nexmon.git "${basedir}"/nexmon --depth 1 +cd "${basedir}"/nexmon +# Disable statistics +touch DISABLE_STATISTICS +source setup_env.sh +ls -lah /usr/lib/x86_64-linux-gnu/libl.a +ls -lah /usr/lib/x86_64-linux-gnu/libfl.a +make +cd buildtools/isl-0.10 +CC=$CCgcc +./configure +make +sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43430a1/7_45_41_46/nexmon/Makefile +sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43455c0/7_45_154/nexmon/Makefile +cd ${NEXMON_ROOT}/patches/bcm43430a1/7_45_41_46/nexmon +# Make sure we use the cross compiler to build the firmware. +# We use the x86 cross compiler because we're building on amd64 +unset CROSS_COMPILE +#export CROSS_COMPILE=${NEXMON_ROOT}/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- +make clean +# We do this so we don't have to install the ancient isl version into /usr/local/lib on systems. +LD_LIBRARY_PATH=${NEXMON_ROOT}/buildtools/isl-0.10/.libs make ARCH=arm CC=${NEXMON_ROOT}/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- +cd ${NEXMON_ROOT}/patches/bcm43455c0/7_45_154/nexmon +make clean +LD_LIBRARY_PATH=${NEXMON_ROOT}/buildtools/isl-0.10/.libs make ARCH=arm CC=${NEXMON_ROOT}/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- +# RPi0w->3B firmware +mkdir -p "${basedir}"/kali-${architecture}/lib/firmware/brcm +cp ${NEXMON_ROOT}/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${basedir}"/kali-${architecture}/lib/firmware/brcm/brcmfmac43430-sdio.nexmon.bin +cp ${NEXMON_ROOT}/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${basedir}"/kali-${architecture}/lib/firmware/brcm/brcmfmac43430-sdio.bin +wget https://raw.githubusercontent.com/RPi-Distro/firmware-nonfree/master/brcm/brcmfmac43430-sdio.txt -O "${basedir}"/kali-${architecture}/lib/firmware/brcm/brcmfmac43430-sdio.txt +# RPi3B+ firmware +cp ${NEXMON_ROOT}/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${basedir}"/kali-${architecture}/lib/firmware/brcm/brcmfmac43455-sdio.nexmon.bin +cp ${NEXMON_ROOT}/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${basedir}"/kali-${architecture}/lib/firmware/brcm/brcmfmac43455-sdio.bin +wget https://raw.githubusercontent.com/RPi-Distro/firmware-nonfree/master/brcm/brcmfmac43455-sdio.txt -O "${basedir}"/kali-${architecture}/lib/firmware/brcm/brcmfmac43455-sdio.txt +# Make a backup copy of the rpi firmware in case people don't want to use the nexmon firmware. +# The firmware used on the RPi is not the same firmware that is in the firmware-brcm package which is why we do this. +wget https://raw.githubusercontent.com/RPi-Distro/firmware-nonfree/master/brcm/brcmfmac43430-sdio.bin -O "${basedir}"/kali-${architecture}/lib/firmware/brcm/brcmfmac43430-sdio.rpi.bin +wget https://raw.githubusercontent.com/RPi-Distro/firmware-nonfree/master/brcm/brcmfmac43455-sdio.bin -O "${basedir}"/kali-${architecture}/lib/firmware/brcm/brcmfmac43455-sdio.rpi.bin +# This is required for any wifi to work on the RPi 3B+ +wget https://raw.githubusercontent.com/RPi-Distro/firmware-nonfree/master/brcm/brcmfmac43455-sdio.clm_blob -O "${basedir}"/kali-${architecture}/lib/firmware/brcm/brcmfmac43455-sdio.clm_blob diff --git a/files/udev/99-com.rules b/files/etc/99-com.rules similarity index 100% rename from files/udev/99-com.rules rename to files/etc/99-com.rules diff --git a/rpi23-gen-image.sh b/rpi23-gen-image.sh index 65cdbd6..68d0052 100755 --- a/rpi23-gen-image.sh +++ b/rpi23-gen-image.sh @@ -63,6 +63,7 @@ RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmr #enhanced kernel RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_BIS_KERNEL_URL} BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git} +NEXMON_URL=${NEXMON_URL:=https://github.com/seemoo-lab/nexmon.git} # Build directories WORKDIR=$(pwd) @@ -152,6 +153,8 @@ ENABLE_FBTURBO=${ENABLE_FBTURBO:=false} ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=false} VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""} FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""} +ENABLE_NEXMON=${ENABLE_NEXMON:=""} +NEXMON_DIR=${NEXMON_DIR:=""} ENABLE_HARDNET=${ENABLE_HARDNET:=false} ENABLE_IPTABLES=${ENABLE_IPTABLES:=false} ENABLE_SPLITFS=${ENABLE_SPLITFS:=false} @@ -468,6 +471,12 @@ if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then exit 1 fi +# Check if specified FBTURBOSRC_DIR directory exists +if [ -n "$NEXMON_DIR" ] && [ ! -d "$NEXMON_DIR" ] ; then + echo "error: '${NEXMON_DIR}' specified directory not found (NEXMON_DIR)!" + exit 1 +fi + # Check if specified CHROOT_SCRIPTS directory exists if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!"