Build Your Own Kali ISO – Introduction

Building a customized Kali ISO is easy, fun, and rewarding. You can configure virtually every aspect of your custom Kali ISO build using the Debian live-build scripts. These scripts allow one to easily build live system images by providing a framework that uses a configuration set to automate and customize all aspects of building the image. We have adopted these scripts and use them for the official Kali ISO releases.

Prerequisites

Ideally, you should build your custom Kali ISO from within a pre-existing Kali environment. However, if this is not the case for you, make sure you are using the latest version of live-build (in the 3.x branch which targets Debian wheezy).

Getting Ready

We first need to prepare the Kali ISO build environment with the following commands:

apt-get install git live-build cdebootstrap kali-archive-keyring
git clone git://git.kali.org/live-build-config.git
cd live-build-config
lb config

Configuring the Kali ISO Build (Optional)

Through the config directory, your ISO build supports significant customization options, which are well documented on the Debian live build 3.x page. However, for the impatient, the following configuration files are of particular interest:

config/package-lists/kali.list.chroot – contains the list of packages to install in the Kali ISO. You can choose specific packages to be installed, while dropping others. This is also where you can change your Kali ISO Desktop Environment (KDE, Gnome, XFCE, LXDE, etc).

hooks/ – The hooks directory allows us to hook scripts in various stages of the Kali ISO live build. For more information about hooks, refer to the live build manual. As an example, Kali adds its forensic menu this way:

$ cat config/hooks/forensic-menu.binary
#!/bin/sh

cat >>binary/isolinux/live.cfg <<END

label live-forensic
menu label ^Live (forensic mode)
linux /live/vmlinuz
initrd /live/initrd.img
append boot=live noconfig username=root hostname=kali noswap noautomount
END

Building the ISO

Before you generate your ISO, you can specify your required architecture, choosing either amd64 or i386. Also note that “lb build” requires root rights. If you do not specify an architecture, live build will generate an ISO with the same architecture as the host machine.

If you want to build a 64 bit ISO on a 32 bit Kali system, make sure you enable multi archi support:

dpkg --add-architecture amd64
apt-get update

Configure live-build to generate with a 64 bit or 32 bit ISO:

lb config --architecture amd64 # for 64 bit
# ...or...
lb config --architecture i386 # for 32 bit

lb build

The last command will take a while to complete, as it downloads all of the required packages needed to create your ISO. Good time for a coffee.

Building Kali Linux for older i386 architecture

The Kali Linux i386 ISO has PAE enabled. If you require a default kernel for older hardware, you need to rebuild a Kali Linux ISO. The rebuilding process is much the same as above, other than the 686-pae parameter that needs to be changed to 486 in auto/config :

apt-get install git live-build cdebootstrap kali-archive-keyring
git clone git://git.kali.org/live-build-config.git
cd live-build-config
sed -i 's/686-pae/486/g' auto/config
lb clean
lb config --architecture i386
lb build

Speeding up future builds

If you plan to build custom ISOs often, you might want to cache kali packages locally for future builds. This can easily be done by installing apt-cacher-ng, and configuring the http_proxy environment variable before every build.

apt-get install apt-cacher-ng
/etc/init.d/apt-cacher-ng start
export http_proxy=http://localhost:3142/
.... # setup and configure your live build
lb build