Kali Linux

How To Rebuild a Source Package In Kali Linux

How To Rebuild a Source Package In Kali Linux
Even though it's customized explicitly for penetration testing, Kali Linux is a flexible and highly customizable Linux distro. It allows you to customize things like the Desktop environment, packages, and even the kernel as long as you know what you are doing,

Let's discuss how we can modify installed packages and rebuild them from the source.

NOTE: Before we begin, you will need to include the source deb-src package URIs in the sources.list file.

Adding deb-src Packages

To add the deb-src package in Kali Linux sources.list file, edit the file in /etc/apt/sources.list and uncomment the deb-src line.

Next, update your source packages before proceeding.

NOTE: Ensure you have the dpkg-dev package installed.

Downloading Source Packages

The next step is to download the source package. For this example, we will use vim. Run the commands:

sudo apt-get update
sudo apt source vim

Next, navigate to the vim source package directory

cd vim-8.2.2434/

 Modify Package Source Code

The next step is to make changes to the source code as you see fit. I will not get into details because this will depend on the package you are modifying and your targeted needs.

sudo nano src/vimrun.c

Once you have made your appropriate modifications, save and close the file.

Check for Build Dependencies

Before rebuilding the source packages, you need to install the package dependencies. You can check the required dependencies using the command:

dpkg-checkbuilddeps

Running this command will display all the required dependencies before rebuilding the package. The result will be empty if no dependencies are required. For vim, you'll see an output similar to the one shown below:

dpkg-checkbuilddeps: error: Unmet build dependencies: autoconf cscope debhelper-compat (= 12) libacl1-dev libcanberra-dev libgpmg1-dev libgtk-3-dev liblua5.2-dev libperl-dev libselinux1-dev libncurses-dev libtool-bin libxaw7-dev libxpm-dev libxt-dev lua5.2 python3-dev ruby-dev tcl-dev docbook-utils docbook-xml ghostscript pdf2svg

Installing Build Dependencies

Once you have the list of required dependencies, simply use apt to install them as:

sudo apt-get install autoconf cscope debhelper-compat libacl1-dev libcanberra-dev libgpmg1-dev libgtk-3-dev liblua5.2-dev libperl-dev libselinux1-dev libncurses-dev libtool-bin libxaw7-dev libxpm-dev libxt-dev lua5.2 python3-dev ruby-dev tcl-dev docbook-utils docbook-xml ghostscript pdf2svg -y

 Building the Source Package

After fulfilling the required dependencies and saving the new source package changes, you can build the new package.

Use the command below to build the new package.

dpkg-buildpackage

Installing New Package

Once the build completes successfully, you should have a .deb package that you can install using dpkg.

sudo dpkg -i… /vim-???.deb

 Conclusion

This quick guide has shown you how to source, modify, and rebuild packages in Kali Linux. Rebuilding packages can be very useful when you want a customized version of a tool.

Thank you for reading.

Mouse left-click button not working on Windows 10
If you are using a dedicated mouse with your laptop, or desktop computer but the mouse left-click button is not working on Windows 10/8/7 for some rea...
Cursor jumps or moves randomly while typing in Windows 10
If you find that your mouse cursor jumps or moves on its own, automatically, randomly while typing in Windows laptop or computer, then some of these s...
How to reverse Mouse and Touchpads scrolling direction in Windows 10
Mouse and Touchpads not only make computing easy but more efficient and less time-consuming. We cannot imagine a life without these devices, but still...