Summary - Kali Linux Revealed

9.5. Summary
In this chapter, we learned about modifying Kali source packages, which are the basic building
blocks of all applications shipped in Kali. We also discovered how to customize and install the Kali
kernel. Then we discussed the live-build environment and discussed how to build a customized
Kali Linux ISO. We also demonstrated how to create both encrypted and unencrypted Kali USB
installs.
9.5.1. Summary Tips for Modifying Kali Packages
Modifying Kali packages is usually a task for Kali contributors and developers, but you might have
specific needs not fulfilled by the official packages and knowing how to build a modified package
can be very valuable, especially if you want to share your changes, deploy them internally, or
cleanly roll the software back to a previous state.
When you need to modify a piece of software, it might be tempting to download the source, make
the changes, and use the modified software. However, if your application requires a system-wide
setup (e.g. with a
make install
step), then it will pollute your file system with files unknown to
dpkg
and will soon create problems that cannot be caught by package dependencies. In addition,
this type of software modification is more tedious to share.
When creating a modified package, the general process is always the same: grab the source pack-
age, extract it, make your changes, and then build the package. For each step, there are often
multiple tools that can handle each task.
To start rebuilding a Kali package, first download the source package, which is composed of a
*.dsc
(Debian Source Control) file and of additional files referenced from that control file.
251
Chapter 9 — Advanced Usage
Source packages are stored on HTTP-accessible mirrors. The most efficient way to obtain them is
with
apt source source-package-name
, which requires that you add a deb-src line to the
/etc/
apt/sources.list
file and update the index files with
apt update
.
Additionally, you can use
dget
(from the devscripts package) to download a
.dsc
file directly
together with its accompanying files. For Kali-specific packages whose sources are hosted in a
Git repository on
gitlab.com/kalilinux/packages
9
, you can retrieve the sources with
git clone
https://gitlab.com/kalilinux/packages/source-package.git
.
After downloading sources, install the packages listed in the source package’s build dependencies
with
sudo apt build-dep ./
. This command must be run from the package’s source directory.
Updates to a source package consist of a combination of some of the following steps:
• The required first step is changing the version number to distinguish your package from
the original with
dch --local version-identifier
, or modify other package details with
dch
.
• Applying a patch with
patch -p1 <patch-file
or modifying
quilt
’s patch series.
• Tweaking build options, usually found in the package’s
debian/rules
file, or other files in
the
debian/
directory.
After modifying a source package, you can build the binary package with
dpkg-buildpackage
-us -uc -b
from the source directory, which will generate an unsigned binary package. The pack-
age can then be installed with
dpkg -i package-name_version_arch.deb
.
9.5.2. Summary Tips for Recompiling the Linux Kernel
As an advanced user, you may wish to recompile the Kali kernel. You may want to slim down the
standard Kali kernel, which is loaded with many features and drivers, add non-standard drivers
or features, or apply kernel patches. Beware though: a misconfigured kernel may destabilize your
system and you must be prepared to accept that Kali cannot ensure security updates for your
custom kernel.
For most kernel modifications, you will need to install a few packages with
apt install
build-essential libncurses5-dev fakeroot
.
The command
apt-cache search ^linux-source
should list the latest kernel version packaged
by Kali, and
apt install linux-source-version-number
installs a compressed archive of the
kernel source into
/usr/src
.
The source files should be extracted with
tar -xaf
into a directory other than
/usr/src
(such as
~/kernel
).
When the time comes to configure your kernel, keep these points in mind:
9
https://gitlab.com/kalilinux/packages
252
Kali Linux Revealed
• Unless you are an advanced user, you should first populate a kernel configuration file.
The preferred method is to borrow Kali’s standard configuration by copying
/boot/
config-
|