Kali Linux 1.1.0 Git install Kernel Cross Compilation with Wireless Injection “Working” v2

OK so after some time of playing around and trying different things I have finally managed to simplify the process of installing Kali Linux on the Raspberry Pi 2 with “armhf” architecture and compiling the kernel with wi-fi injection working! Follow the the tutorial below and I will guide you step by step through each section and hopefully very soon you will also have your own custom image compiled with patched drivers for wireless injection 🙂

To follow along with this tutorial you will need the following items:
1) Raspberry Pi 2
2) Micro SD Card 8GB’s or more
3) Kali linux either installed on a physical machine or in a Virtual Machine
4) Time & patience
Step 1:
So as before you need to first create a directory and navigate to it.
mkdir name_of_your_choice (Remember it as you will need this later)
1 - Kali make dir
cd name_of_your_choice
1.1 - Kali change dir
Step 2:
git clone https://github.com/offensive-security/gcc-arm-linux-gnueabihf-4.7 to pull down for the “armhf” image creation
2 - Kali Git Clone
Output once finished it should look as follows
2.1 - Kali Git Clone Finish

Step 3:

Check your working directory with “pwd” and then “ls” to check the gcc-arm directory is there and use this information to export the path

3 - Check pwd and directory

Step 4:

Export the path with /root/Kali-Git being the working directory and gcc-arm-linux-gnueabihf-4.7/bin being the directory and bin directory contained within that you have just cloned from git

export PATH=${PATH}:/root/Kali-Git/gcc-arm-linux-gnueabihf-4.7/bin

4 - Export Kali

Step 5:

Clone the kali-arm-build-scripts from github

git clone https://github.com/offensive-security/kali-arm-build-scripts

5 - Clone Kali Arm Scripts

Output once finished it should look as follows

5.1 - Clone Kali Arm Scripts finish

Step 6:

Now as the Pi has a different architecture you need to modify the rpi.sh script in the cloned repository with the editor of your choice

6 - Change to Kali arm scripts dir

Step 7:

Don’t want to have to re-partition your Micro SD card afterwards? Don’t worry there is a place to make your life easier hidden within this script! If you have an 8GB card for example just calculate by 8 x 1000 and you get your size, my card in this case is a 16GB so unless you are using 16GB’s or higher do not copy in 16000 like below. Note however your card may not be the correct advertised size so make sure the size is what you think it is prior to setting it here. I however prefer to just re-size with gparted once finished as it takes far less time to be perfectly honest than to transfer a 16GB.img to my Micro SD card. You can also use the wiggle script afterwards to if you want an alternative method. Use whatever you are comfortable with.

4 -wiggle disk size change

Step 8:

Modifying two separate locations as outlined in the below image to say “armhf” instead of “armel”


7 - Change Kali architecture

Step 9:
Comment out the linux git clone like below with a # in front and instead add in the following 3.18 kernel instead
git clone -b rpi-3.18.y –depth 1 https://github.com/raspberrypi/linux ${basedir}/kernel
9 -Change kernel
Step 10:
I added in the following line as I was compiling on a 64bit machine so don’t use unless you need to and leave as is
export CROSS_COMPILE=${basedir}/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-
10 - kernel cross compilation
I also changed kernel.img to kernel7.img as per this thread on the raspberry pi forums
11.1 - kernel change
Step 11:
I also chose to comment out the last few lines at the end in order to be able to troubleshoot and not compress or build a sha1sum as you can see below and make sure to save it
8 - rpi script comment out

Step 12:

Copy the following pastebin script from here and create a new file in the kernel directory or alternatively run “wget http://pastebin.com/download.php?i=Rv3zpsiv -O rpi-3.18.config” from the terminal to do this for you and download it straight to the directory for you. I chose not to modify the kernel script in the end and leave as it was. If you don’t want to use the pastebin kernel version your can extract the kernel configuration yourself by simply installing Raspbian, booting up and then running “zcat /proc/config.gz > 3.18.config”  and copying this file onto your system in place of the downloaded or copy and pasted method.

12 - kernel create

Save the file contents

12 .1 - config save

Or with wget just download straight to /Kali-Git/kali-arm-build-scripts/kernel-configs

wget http://pastebin.com/download.php?i=Rv3zpsiv -O rpi-3.18.config

12 - wget raspbian kernel config

Step 13:
Install some dependencies via apt-get
sudo apt-get install linux-source -y
sudo apt-get install bc gcc gcc-4.6 libc-bin libc-dev-bin libc6 libc6-dev linux-libc-dev lib32ncurses5 -y make manpages-dev
Step 14:
I was getting an error on my previous attempt related to GLIBC_2.14 so I did some investigating and it turns out that due to debian being stable it will only use the following version 2.13 as seen below
14 GLIBC_2.14 kali linux
The GLIBC_2.14 error
OK, so you shouldn’t really do this but I said screw it as I had spent quite some time at this and I wasn’t going to give up easily, I did a bad thing and I installed libc6 from the debian experimental repository something that without would not have made this possible. If you follow through you should backup or create a snapshot of your system as I take no responsibility for you borking your system up! Take this as a warning and be careful.
To install the debian experimental repository I followed the following guide
First run “nano /etc/apt/sources.list” in order to edit the file, alternatively use a different editor if you want like vi or emacs!
15.1 - nano apt sources
Modify with the following two lines and save
deb http://ftp.debian.org/debian experimental main
deb http://ftp.debian.org/debian sid main
15.2 - nano apt sources
Run apt-get update
15.3 - apt-get update kali
Then install libc6
apt-get -t experimental install libc6-dev
15.4 - libc6 install kali
Verify the install went well and a newer version of GLIBC is available to you.
15.5 - libc6 installed check
Step 15:

The output should initiate as below when the rpi.sh script is run with the version number or name of your choice and be patient as depending on your internet connection this can take some time to complete

./rpi.sh name_of_custom_image

13 - run rpi script

When finished it should look something like this

13.1 - run rpi script finish

Step 16:
Now that this is done it is time to write the card with dd
dd if=your_image_here.img of=/dev/your_micro_sd bs=1M
14.2 Kali dd to disk - custom 2
Upon ejecting the Micro SD and plugging it into the Pi the kernel was not fully booting and giving me the following error, which was due to my 32GB Micro SD card as my 16GB was fine, but you may encounter similar so this is how I fixed it.
“panic: VFS: Unable to mount root fs on unknown-block”
I ejected the Micro SD card and then ran the following against it
sudo fsck.ext4 -fy /dev/sdc2
16 - fsck kali
Step 17:
I then also increased the size of the ext4 partition with gparted
Run “gparted” & from the terminal
12 - Gparted start
You want to unmount the partitions first so Right Click on the partitions and select Unmount
13 - Gparted unmount
After it should look like this with the key removed beside each partition
14 - Gparted unmounted
Now Right Click on the biggest partition that has data on it which is /dev/sdb in this case and select Resize/Move
15 - Gparted resize select
You will then be presented with the following window
16 - Gparted resize select slider
Simply move the slider along to allocate all the space and then select Resize/Move as it will be highlighted, you will also see the there is now 0 Free Space following the resize
17 - Gparted resize select slider 2
You may now think you are done as the unallocated space is gone but you need to press the green tick to start the process and the click Apply
18 - Gparted resize start and apply
Wait for a moment
19 - Gparted processing
Once finished click Close and eject your Micro SD and put it back into your Pi.
20 - Gparted Finish
Kernel in use:
0 - Kali Pi Kernel
After this the Pi was booting up without error, detecting my Alfa and Netgear card’s and working with wireless injection 🙂 Stay tuned for some follow up’s on testing your wireless injection, getting SSH configured and fully updating your new custom image!

2 thoughts on “Kali Linux 1.1.0 Git install Kernel Cross Compilation with Wireless Injection “Working” v2

Leave a Reply