Portable Kali on Raspberry Pi

Portable Kali on Raspberry Pi

The Idea:

As a cybersecurity enthusiast, I wanted a portable device for my pentesting adventures. The idea of carrying a full-fledged Kali Linux setup in my pocket was too tempting to resist. So, I decided to embark on a project to turn a Raspberry Pi into my ultimate portable hacking companion.

The Plan

My goal was to create a device with three network interfaces:

  1. eth0: For connecting to wired networks as a client
  2. wlan0: The Pi's internal Wi-Fi, which I planned to use for remote management
  3. wlan1: A USB Wi-Fi adapter for monitor mode and wireless testing

The Build:

Hardware

Setting Up the Basics

I started by gathering all the necessary components: a Raspberry Pi, a case, an LCD screen, and a USB Wi-Fi adapter. After installing Kali Linux on the Pi, I dove into the configuration.

First, I installed some essential packages:

sudo apt install -y build-essentials raspberrypi-kernel-headers bc dkms git linux-headers-$(uname -r) libelf-dev rfkill iw hostapd dnsmasq udhcpd tmux

Wifi Adapter

git clone https://github.com/morrownr/8821au-20210708.git
cd 8821au-20210708
sudo ./install-driver.sh

LCD Screen Setup:

The display has an online guide here: http://www.lcdwiki.com/3.5inch_RPi_Display

git clone https://github.com/lcdwiki/LCD-show-kali.git
chmod -R 755 LCD-show-kali
cd LCD-show-kali
sudo ./LCD35-show
sudo ./rotate.sh 180 (So my usb ports are on the top)

Shell Configuration

The goal here is to boot into a tmux session which will show on the LCD. That way I have the option to show the same content on the LCD and my remote shell (SSH).
I added the following to my .zshrc:

if [ -z "$SSH_CLIENT" ] && [ -z "$SSH_TTY" ]; then
    while true; do
        if [ -z "$TMUX" ]; then
            # Check if the "live" session exists
            if ! tmux has-session -t live 2>/dev/null; then
                # Create a new session "live"
                tmux new-session -d -s live 'neofetch; exec $SHELL'
            fi
            tmux attach -t live
        fi
        sleep 1
    done
fi

Network Magic

Remote Management Setup

I configured wlan0 to act as an access point:

Setting a static IP address

$ cat /etc/network/interfaces
    source-directory /etc/network/interfaces.d
    auto lo
    iface lo inet loopback
    # Allow the interface to start on system startup
    allow-hotplug wlan0
    iface wlan0 inet static
    address 192.168.123.1
    netmask 255.255.255.0
    gateway 192.168.123.1
  • Configured DHCP using dnsmasq by creating /etc/dnsmasq.d/hotspot.conf.
  • Set up the access point by editing /etc/hostapd/hostapd.conf.
  • Configured the DHCP server in /etc/udhcpd.conf

Ethernet Configuration

For the Ethernet port, I kept it simple. I created /etc/network/interfaces.d/eth0 to use DHCP:

auto eth0
allow-hotplug eth0
iface eth0 inet dhcp

The Result

After several hours of tinkering and debugging my portable Kali device was ready! I now have a powerful tool that fits in my pocket, complete with a screen for on-the-go use and remote management capabilities.