Sunday, 15 March 2015

Raspberry Pi 2 Model B and Kali Linux - quick setup

The new Raspberry Pi 2 Model B is approximately 6 times faster that its predecessor. It comes with:
  • QUAD Core Broadcom BCM2836 CPU
  • 1 GB RAM
  •  40 pin extended GPIO
  • Micro SD slot
  • 4x USB ports
  • HDMI
  • 4 pole Stereo output and Composite video port
  • CSI camera port & DSI display port
  • Micro USB power source
In order to install Kali Linux on the new Raspberry Pi you will need to download the new image for Raspberry Pi 2 (0.48G) version 1.1.0  from https://www.offensive-security.com/kali-linux-vmware-arm-image-download/ (filename: kali-1.1.0-rpi2.img.xz). 

[Extraction]
The .xz extension (for more info on xz see: http://tukaani.org/xz/) means that the image file is compressed and needs to be extracted. You can download the xz utilities using the command: 
apt-get install xz-utils 

Under Linux, in order to decompress the file you can use the command:
unxz filename.any.xz 
or the command xz -d filename.any.xz 

Since version 9.04 the package p7zip manages xz files and can extract them using the command:
7za e filename.any.xz

[Write Image to SD card]
First of all, it is very important to have a fast micro SD card. The performance of the Paspberry Pi can be dramatically affected if you do not use a fast enough card. I personally suggest the SanDisk Ultra microSDHC UHS-I Class 10 up to 48MB/s read (Memory Card with Adapter). You can get a 16GB card but I would recommend a 32GB. If you are concern about Read/Write speeds and you are willing to spend some money on the card, then you can try SanDisk Extreme PLUS up to 80MB/s read, or SanDisk Extreme PRO up to 95MB/s read. 

Under Linux you can use dd to write the bootable image file onto the SD card (link). 
Under Windows you can use Win32DiskImager (link). 

Using dd: Connect your SD card to your Linux, run the command mount and df -h to identify where the SD card is mounted. Assuming your SD card is mounted under /dev/sdb2 you can use the following dd command to write the image to the SD card:
dd if=kali-1.1.0-rpi2.img of=/dev/sdb2 bs=512k


Using Win32DiskImager: Connect your SD card to your Windows OS, and launch the application. The GUI is simple and straight forward. Select your Kali Linux image file you extracted (kali-1.1.0-rpi2.img)
and the drive letter of your connected SD card under the Device combo box (e.g. F:\). Just click the "Write" button and the process will start. 


[Boot]
Once the process is done, you can put the SD card to the Raspberry Pi and boot it by connecting the power supply. As always, the user is root and the password is toor
Make sure you change the root password by using the passwd command.
Also, change your SSH host keys as soon as possible as all ARM images are pre-configured with the same keys. In order to do this, run the following commands:
rm /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server
service ssh restart


Tip:
You can add the follwoing script to your ~/.bashrc in order to automate the extraction process of different files. Every time you want to extract a file the only thing you need to do is to type:
extract filename.any.ext 

extract () {
   if [ -f $1 ] ; then
      case $1 in
         *.tar.bz2) tar xvjf $1 && cd $(basename "$1" .tar.bz2) ;;
         *.tar.gz)  tar xvzf $1 && cd $(basename "$1" .tar.gz) ;;
         *.tar.xz)  tar Jxvf $1 && cd $(basename "$1" .tar.xz) ;;
         *.bz2)  bunzip2 $1 && cd $(basename "$1" /bz2) ;;
         *.rar)  unrar x $1 && cd $(basename "$1" .rar) ;;
         *.gz)  gunzip $1 && cd $(basename "$1" .gz) ;;
         *.tar)  tar xvf $1 && cd $(basename "$1" .tar) ;;
         *.tbz2)  tar xvjf $1 && cd $(basename "$1" .tbz2) ;;
         *.tgz)  tar xvzf $1 && cd $(basename "$1" .tgz) ;;
         *.zip)  unzip $1 && cd $(basename "$1" .zip) ;;
         *.Z)  uncompress $1 && cd $(basename "$1" .Z) ;;
         *.7z)  7z x $1 && cd $(basename "$1" .7z) ;;
         *)  echo "don't know how to extract '$1'..." ;;
      esac

   else
      echo "'$1' is not a valid file!"
   fi
}

No comments:

Post a Comment