Kali Linux 2017.3 on a Raspberry Pi Zero W
Pi Zero W Introduction
The Raspberry Pi Zero W is an upgraded version of the old Pi Zero, and now comes with Bluetooth and Wi-Fi built in. Unfortunately, the built-in Wi-Fi adapter does not support monitor mode or packet injection (by default – we can fix that!), but all is not lost because external USB adapters can be added via an USB OTG adapter.
The Pi Zero W is the same physical size as the old Pi Zero, a little wider than a stick of chewing gum, but manages to fit Bluetooth 4.0 and 802.11n wireless on board. Best of all, it’s still cheap. The original Pi Zero has an MSRP of only $5, and the Pi Zero W is $10, making it probably the cheapest way to run Kali on new hardware.
I should mention that if you want to run a desktop with full GUI, the Pi Zero W probably isn’t the platform for you. The processor and amount of RAM (512MB) that’s on this device isn’t really strong enough to run a desktop very snappily, so this is, for usability’s sake, a command-line-only device.
To get the Kali image on the Pi Zero W, you’ll need a few things.
- A Pi Zero W
- A microSD card, 8GB should do nicely
- A USB OTG cable
- A USB keyboard
- A micro HDMI to HDMI cable, or micro HDMI to HDMI adapter + an HDMI cable
- An HDMI display/monitor for initial configuration
- A 5V power source with microUSB connector
- An external USB Wi-Fi adapter that support monitor mode and injection if you’re going to need those things
- Optionally, a case or enclosure to keep things safe
Most likely the typical geek has most of this stuff lying around. The only semi-odd items are the OTG cable, which is a male microUSB to female USB type-A cable, and a micro HDMI to HDMI adapter / micro HDMI to HDMI cable.
Installation Steps
Thanks to our friend Re4son, the talent that brought us Kali Linux on the GPD Pocket, we’re now able to run Kali 2017-3 natively on the Pi Zero. (See his official site for this project here.)
- Download the Pi Zero W specific version from this site.
- Use a utility like Win32diskimager (Windows) or dd (Linux/macOS) to flash the image to a microSD card. For a macOS how-to, get yourself a microSD to USB adapter and click here. After the image is burned, insert the microSD card in the Pi Zero W.
- Connect a USB OTG adapter to the microUSB port on the Pi and attach a keyboard, connect an external monitor for initial setup via the microHDMI port, and finally, connect your AC to microUSB power source to the “PWR IN” port.
That’s it. When the Pi Zero W boots, you’ll be at a command prompt and you can log in with the default user of root with a password of toor.
Post-Installation Security Steps
Bluetooth isn’t enabled by default, so you’ll want to enable Bluetooth if you plan to use it.
systemctl enable bluetooth && systemctl enable hciuart
The SSH keys that come pre-installed on the image are the same SSH keys as everyone else SSH keys, so you’ll want to remove them and re-generate new ones.
cd /etc/ssh/ mkdir insecure_old mv ssh_host* insecure_old/ dpkg-reconfigure openssh-server
SSH is enabled by default on this image, and contrary to what I’ve read on other sites, you do NOT need to enable automatic login on the Pi in order to SSH to it.
You’ll want to change the default root password. This is simple enough.
passwd
Optional: Nexmon Drivers to Enable Monitor Mode and Frame Injection with Onboard Wi-Fi
re4son has provided us with an easy script to install the Nexmon drivers for the built-in Broadcom wireless chipset, which enables monitor mode and frame injection via the onboard adapter. Very cool. Installation is easy.
cd /usr/local/src/re4son-kernel_4* ./install.sh -x
If you have issues with these drivers, to remove them and roll back to the originals, just run:
cd /usr/local/src/re4son-kernel_4* ./install.sh -o
Just be aware that if you are connected through SSH and are only using the onboard wi-fi adapter, putting it in monitor mode will terminate your remote session and you’ll have to reboot the RPi0W or connect to it interactively to take the interface out of monitor mode.
Configuring Wireless from the Command Line
With the default installation, you won’t get a GUI, so you’ll have to configure your wireless network settings manually via the /etc/network/interfaces file. Use the command iwconfig to see what your onboard wireless LAN adapter is referred to (mine was wlan0). You can then use nano to edit the interfaces file.
nano /etc/network/interfaces
Change your file so it looks like this:
auto lo face lo net loopback auto wlan0 allow-hotplug wlan0 iface wlan0 inet dhcp wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Save that file with CTRL + O and then Enter to save, and CTRL + X to exit.
Back at the shell, run the following three commands, where “your_SSID” is the SSID that you’re trying to connect to:
/sbin/ip link set up wlan0 /sbin/iw wlan0 scan | grep SSID wpa_passphrase your_SSID >> /etc/wpa_supplicant/wpa_supplicant.conf
You’ll be prompted with a blinking cursor. Enter your WPA PSK and hit enter. That utility will then run the wpa_supplicant.conf file for you in the correct format. At this point it’s a good idea to edit the /etc/wpa_supplicant/wpa_supplicant.conf file and remove the line that contains the plain text version of your WPA2 password. Be sure to save the file before exiting.
Restart the system using the reboot command and when the system comes back up, go ahead and log in with your new password and check connectivity.
iwconfig
Running Updates
The next thing you’re going to want to do is run updates.
apt-get update apt-get upgrade
The second command will take quite a while to complete. After both commands are complete, you should be up and running. After fully updating, my install is using 57% of an 8GB microSD card.
Installation Additional Packages
It should be noted that re4son’s Kali image only comes with minimal packages installed by default. This is so you can custom tailor your RPi0W to your needs without bogging it down with unneeded software. Luckily, the image provides you with some canned apt packages than will install additional tools. You can use “apt-get install” to get any of these packages easily:
- kali-linux-forensic
- kali-linux-pwtools
- kali-linux-rfid
- kali-linux-sdr
- kali-linux-top10
- kali-linux-voip
- kali-linux-web
- kali-linux-wireless