So, I thought it was time to revisit this. There seems to be some confusion on how to actually buiild live iso's, so I thought I would make an article about it.
This is based on my desktop build scripts, you can find a quick walkthrough on that here Kali Desktop Light buildscript. I suggest you start there, since we're using that as a base for setting up the build environment.
To follow along, you'll need a Kali workstation, so install one if you haven't allready, and join me for some live-build fun.
So, okay. What is it we're trying to do ? We're trying to build a live version and installable version of Kali Linux, with some packages we'll need, and strip out the rest we don't need.
And why is this nice ?, because it allows us to take just what we need, and skip the rest, making a very light version. And this can be made to include just the tools we need, for a specific purpose. So, knowing how to do this, is very nice, and very handy sometimes :)
First, what is a buldscript. It's actually just a Bash script, running specific commands used for building live-systems. If you're not that sharp with Bash, here's a couple of tutorials.
https://devhints.io/bash
https://www.tutorialspoint.com/unix/unix-directories.htm
So, let's move on, shall we ? :)
This is the most basic buildscript we can make, so this is our base.
HDIR=/root
BDIR=live-build-config
### System Setup
cd $HDIR
## Update system
apt-get update
apt-get upgrade -y
## Install live-build packages
apt-get install live-build cdebootstrap -y
# Clone from Kali-org
git clone http://gitlab.com/kalilinux/build-scripts/live-build-config.git
#cd to live-build-config
cd $BDIR
cd kali-config
cp -r variant-light variant-desktop
mkdir -p variant-desktop/includes.chroot
mkdir -p variant-desktop/includes.chroot/etc
mkdir -p variant-desktop/package-lists
mkdir -p variant-desktop/includes.chroot/etc/apt/
mkdir -p variant-desktop/includes.chroot/boot/grub
#Write package list
cd variant-desktop
rm package-lists/kali.list.chroot
touch package-lists/kali.list.chroot
cat >> package-lists/kali.list.chroot << EOF
# Basic packages
kali-linux-core
kali-desktop-live
kali-desktop-xfce
kali-desktop-mate
kali-root-login
#Default settings for Kali
kali-defaults
kali-menu
kali-debtags
kali-archive-keyring
debian-installer-launcher
alsa-tools
locales-all
xorg
# Custom basic packages
mc
net-tools
sysv-rc-conf
openssh-server
So, let's have a look, and see how it works.
HDIR=/root
BDIR=live-build-config
### System Setup
cd $HDIR
Define a variable named HDIR, and set it to the root folder, define a variable called BDIR and set it to live-build-config directory. Last, go to the root directory, so we're ready for setting up all the fun stuff we'll need.
## Update system
apt-get update
apt-get upgrade -y
## Install live-build packages
apt-get install live-build cdebootstrap -y
# Clone from Kali-org
git clone http://gitlab.com/kalilinux/build-scripts/live-build-config.git
#cd to live-build-config
cd $BDIR
cd kali-config
Update APT and run a system upgrade. Install the tools we need, and last, pull the files from the Kali teams git we need for building. And jump into BDIR, the live-build-config directory, and from there, jump into the kali-config directory.
cp -r variant-light variant-desktop
mkdir -p variant-desktop/includes.chroot
mkdir -p variant-desktop/includes.chroot/etc
mkdir -p variant-desktop/package-lists
mkdir -p variant-desktop/includes.chroot/etc/apt/
Next, we copy the variant-light directory to our own called variant-desktop, and make a couple of directories under that, since we'll need them later.
#Write package list
cd variant-desktop
rm package-lists/kali.list.chroot
touch package-lists/kali.list.chroot
cat >> package-lists/kali.list.chroot << EOF
Here we wipe out the old package list, and make a new one. We tell the build process to write the files we mention next into the package list.
# Basic packages
kali-linux-core
kali-desktop-live
kali-desktop-xfce
kali-desktop-mate
kali-root-login
#Default settings for Kali
kali-defaults
kali-menu
kali-debtags
kali-archive-keyring
debian-installer-launcher
alsa-tools
locales-all
xorg
# Custom basic packages
mc
net-tools
sysv-rc-conf
openssh-server
So, here we define the basic packages we need for a minimal Kali system. And we close out the list like this
you-package-here
EOF
Last, we tell the script to run.
cd $HDIR/$BDIR
# Build iso image
# ./build.sh --distribution kali-rolling --variant desktop --verbose
exit 0
Keep this section commented out, so it doesn't run yet. That way you can run this script to populate the build directory in an easy way, and make changes if you like, and last run the build command manually from the live-build-config directory, like this
./build.sh --distribution kali-rolling --variant desktop --verbose
So, now we understand a bit about the build script itself, how do we find packages we would like to include ? Well I'm glad you asked. There's a couple of ways we can do that. We can install a system in the hand, and dump the package list out, and later import it on a newly installed system. Let's explore that option first.
root@xeon:/home/nx/dev# dpkg -l
Ønsket=Ukendt/Installér/(R)fjern/(P)udrens/tilbageHold
| Status=(N)ikke/Installeret/(C)Konfigfiler/Udpakket/(F)halvkonfig./
|/ Halvt-installeret/(W)afventer-udløser/(T)udløser-afventer
|| Fejl?=(ingen)/tilbilbageHoldt/geninstallation-kRæves/X=begge-problemer
|| / (Status, Fejl: store bogstaver=alvorligt)
||/ Navn Version Arkitektur Beskrivelse
+++-=============================================-===============================-============-=================================================================>
ii 0trace 0.01-3kali2 amd64 traceroute tool that can run within an existing TCP connection
ii aapt 1:10.0.0+r36-3 amd64 Android Asset Packaging Tool
ii accountsservice 0.6.55-3 amd64 query and manipulate user account information
ii acl 2.2.53-9 amd64 access control list - utilities
ii adduser 3.118 all add and remove users and groups
ii adwaita-icon-theme 3.38.0-1 all default icon theme of GNOME
ii aesfix 1.0.1-8 amd64 tool for correcting bit errors in an AES key schedule
ii aeskeyfind 1:1.0-8 amd64 tool for locating AES keys in a captured memory image
ii afflib-tools 3.7.19-1 amd64 Advanced Forensics Format Library (utilities)
ii afl++ 2.68c-1+b1 amd64 instrumentation-driven fuzzer for binary formats
ii afl++-clang 2.68c-1+b1
A bit of output from the command dpkg -l or you can use apt list --installed. And since we're lazy, or I am, so let's import a list of installed packages.
dpkg --get-selections | grep -v deinstall > installed_packages.txt
And, import it to APT on a new system.
dpkg --set-selections < installed_packages.txt
So, now let's talk about how we can find packages names, to include in our custom list. Let's try to find some Software Defined Radio tools.
#Search with apt-cache
apt-cache search sdr
airspy - Tiny and efficient software defined radio receiver - utilities
bladerf - Nuand bladeRF software-defined radio device (tools)
cubicsdr - Software Defined Radio receiver
cutesdr - simple demodulation and spectrum display program
dump1090-mutability - ADS-B Ground Station System for RTL-SDR
gnss-sdr - Global navigation satellite systems software defined receiver
gnuradio-dev - GNU Software Defined Radio toolkit development
gpsbabel - GPS file conversion plus transfer to/from GPS units
gqrx-sdr - Software defined radio receiver
gr-dab - Gnuradio blocks and tools for receiving DAB and DAB+ radio
gr-dab-dev - Development files for gr-dab (DAB/DAB+ receiver)
gr-hpsdr - gnuradio interface module for OpenHPSDR protocol 1
gr-iqbal - GNU Radio Blind IQ imbalance estimator and correction
gr-limesdr - LimeSDR blocks for GnuRadio
gr-osmosdr - Gnuradio blocks from the OsmoSDR project
gr-soapy - SoapySDR blocks for GnuRadio
hackrf - Software defined radio peripheral - utilities
hamradio-sdr - Debian Hamradio Software Defined Radio Packages
heartbleeder - test servers for OpenSSL CVE-2014-0160 aka Heartbleed
inspectrum - tool for visualising captured radio signals
ipmitool - utility for IPMI control with kernel driver or LAN interface (daemon)
kali-tools-sdr - Kali Linux SDR tools
kismet - wireless network and device detector (metapackage)
So, what if we want details on a package to see what it requires ?, We'll that's easy. We use the apt info command. Here it's details for the package called inspectrum.
root@xeon:/home/nx/dev# apt info inspectrum
Package: inspectrum
Version: 0.2.3-1
Priority: optional
Section: hamradio
Maintainer: Debian Hamradio Maintainers <This email address is being protected from spambots. You need JavaScript enabled to view it.>
Installed-Size: 276 kB
Depends: libc6 (>= 2.29), libfftw3-single3 (>= 3.3.5), libgcc-s1 (>= 3.0), libliquid2d, libqt5core5a (>= 5.15.1), libqt5gui5 (>= 5.2.0) | libqt5gui5-gles (>= 5.2.0), libqt5widgets5 (>= 5.0.2), libstdc++6 (>= 5.2)
Homepage: https://github.com/miek/inspectrum
Tag: uitoolkit::qt
Download-Size: 76,9 kB
APT-Manual-Installed: no
APT-Sources: http://http.kali.org/kali kali-rolling/main amd64 Packages
Description: tool for visualising captured radio signals
inspectrum is a tool for analysing captured signals, primarily from
software-defined radio receivers.
.
inspectrum supports the following file types:
*.cf32, *.cfile - Complex 32-bit floating point (GNURadio, osmocom_fft)
*.cs16 - Complex 16-bit signed integer (BladeRF)
*.cs8 - Complex 8-bit signed integer (HackRF)
*.cu8 - Complex 8-bit unsigned integer (RTL-SDR)
.
Features:
* Large (100GB+) file support
* Spectrogram with zoom/pan
* Plots of amplitude, frequency, phase and IQ samples
* Cursors for measuring period, symbol rate and extracting symbols
* Export of selected time period, filtered samples and demodulated data
If you want to know what all the Kali tools are called, try this
#search command to apt-cache
apt-cache search kali-tools
# result
kali-tools-802-11 - Kali Linux 802.11 attacks tools
kali-tools-bluetooth - Kali Linux bluetooth attacks tools
kali-tools-crypto-stego - Kali Linux Cryptography and Steganography tools
kali-tools-database - Kali Linux database assessment tools menu
kali-tools-exploitation - Kali Linux exploitation tools menu
kali-tools-forensics - Kali Linux forensic tools menu
kali-tools-fuzzing - Kali Linux fuzzing attacks tools
kali-tools-gpu - Kali Linux GPU tools
kali-tools-hardware - Kali Linux hardware attacks tools
kali-tools-information-gathering - Kali Linux information gathering menu
kali-tools-passwords - Kali Linux password cracking tools menu
kali-tools-post-exploitation - Kali Linux post exploitation tools menu
kali-tools-reporting - Kali Linux reporting tools menu
kali-tools-reverse-engineering - Kali Linux reverse engineering menu
kali-tools-rfid - Kali Linux RFID tools
kali-tools-sdr - Kali Linux SDR tools
kali-tools-sniffing-spoofing - Kali Linux sniffing & spoofing tools menu
kali-tools-social-engineering - Kali Linux social engineering tools menu
kali-tools-top10 - Kali Linux top 10 tools
kali-tools-voip - Kali Linux VoIP tools
kali-tools-vulnerability - Kali Linux vulnerability analysis menu
kali-tools-web - Kali Linux webapp assessment tools menu
kali-tools-windows-resources - Kali Linux Windows resources
kali-tools-wireless - Kali Linux wireless tools menu
kali-tools-headless - Kali Linux headless tools
#to install all metapackages, simply run
apt install kali-tools-*
So, let's take a break, and drink some coffee. Now we have covered the script, tools, build directory, and how to identify packages and get details on them, so we know how / what to include. Next, we should talk a bit about where to place different stuff, into what directories, so we can include them. So, see you in Custom Kali desktop build - chapter two