Tuesday, March 22, 2022

How to use Kali Linux for raspberry pi zero W / 2W

This article discribe the the headless installation of Kali Linux on Raspberry Pi Zero W or the new Raspberry Pi Zero2 W. Headless means setup and connect to the Pi Zero without display and keyboard.

(1) Download "Pi-Tail" edition of Kali Linux from https://www.kali.org/get-kali/#kali-arm
pi zero W https://kali.download/arm-images/kali-2022.1/kali-linux-2022.1-raspberry-pi-zero-w-pitail-armel.img.xz
pi zero2 W https://kali.download/arm-images/kali-2022.1/kali-linux-2022.1-raspberry-pi-zero-2-w-pitail-armhf.img.xz

(2) Download balenaEtcher to flash the SD Card, suggest to use 32GB or above.

  If you use the Windows version of balenaEtcher, you don't need to download the image and decompress as it supports get from url, just input the download url and flash the image.

(3.1) After finish flashing, eject the SD card and put it back in order to modify the content for headless setup. Based on this https://github.com/Re4son/RPi-Tweaks/blob/master/pi-tail/Pi-Tail.HOWTO, you have to edit the wpa_supplicant.conf in the first partition of the SD Card.
Existing wpa_supplicant.conf
network={
	ssid="homenet"
	psk=68002fbdacc8812f89c06a2fb6542b2b1126853983a59e0076e5f56df9c5543b
        id_str="home"
        priority=2
}
Get wpa_passphase from linux package wpasupplicant
and the command
wpa_passphrase "MyHomeWifi" "MyPassword" will give you the required psk reuqired
Modify to
network={
	ssid="MyHomeWifi"
	psk=6ac0d834a918dfdb09c7d4581a1665f5f1969ef3967e25cd932eab7c75075d54
        id_str="home"
        priority=2
}

Existing interfaces
iface home inet dhcp
Modify to fixed IP for home
iface home inet static
    address 192.168.1.79
    netmask 255.255.255.0
    gateway 192.168.1.1


(3.2) Modify the mobile set-up
Existing wpa_supplicant.conf
# reading passphrase from stdin
network={
	ssid="mobile-1"
	psk=2b975ade78236c65480641296127688b223b1270e7ce175e7317b5bf6ca4795a
        id_str="mobile-1"
        priority=4
}
Modify to, after running wpa_passphrase "Samsung S22" "mysecretwords"
network={
	ssid="Samsung S22"
	psk=6136bd9f2dced6eced7ec23dc4abed6d8dcff707a148d150ab97905facb6ca33
        id_str="mobile-1"
        priority=4
}

Existing interfaces
iface mobile-1 inet static
    address 192.168.43.254
    netmask 255.255.255.0
    gateway 192.168.43.1
Modify to DHCP IP address for mobile-1
iface mobile-1 inet dhcp



After set-up of SD Card put it back to the Raspberry Pi Zero card slot and then power-up to connect.

(4) Use wifi connect to Raspberry pi using ssh, username is kali and password is kali
e.g. connect via home wifi with fixed IP 192.168.1.79 that was setup in Step 3.1 above
ssh kali@192.168.1.79


e.g. connect via mobile
First get the IP address for hotspot connection client information on your phone. Then use Terminal App such as Termux on your Android phone to start the ssh session with the IP address obtained.
ssh kali@192.168.99.121





(5) Additional configurations after connection
sudo apt update
sudo dpkg-reconfigure tzdata
sudo dpkg-reconfigure locales 


(6) HOWTO put wlan0 into monitor mode:
   wlan0 can be used both, in tethering and monitor mode at the same time.
   Monitor on (mon0):
    mon0up #This will create and start up a monitoring interface "mon0"
   Monitor off:
    mon0down #This will bring down and remove mon0

sudo mon0up
sudo airmon-ng
sudo airodump-ng mon0
sudo airodump-ng mon0 --bssid 34:8A:AE:33:74:4E --channel 4 --write mydump






No comments: