Quantcast
Viewing latest article 2
Browse Latest Browse All 9

Rebuilding a Package from Source

On occasion, we need to rebuild a Kali package from source. Fortunately, this is as simple as apt-getting the package sources, modifying them to your needs, and then rebuilding them using Debian tools. In this example, we will recompile the libfreefare package in order to add some extra hardcoded Mifare access keys into the mifare-format tool.

Downloading the Package Source

# Get the source package
apt-get source libfreefare
cd libfreefare-0.3.4~svn1469/

Edit the Package Source Code

Make the changes needed to the source code of the package. In our case, we modify an example file, mifare-classic-format.c.

nano examples/mifare-classic-format.c

Check for Build Dependencies

Check for any build dependencies the package may have. These need to be installed before you can build the package.

dpkg-checkbuilddeps

The output should be similar to the following, depending on what packages you already have installed. If dpkg-checkbuilddeps returns no output, that means you do not have any missing dependencies and can proceed with the build.

dpkg-checkbuilddeps: Unmet build dependencies: dh-autoreconf libnfc-dev

Install Build Dependencies

Install any build dependencies if needed, as shown in the output of dpkg-checkbuilddeps:

apt-get install dh-autoreconf libnfc-dev

Build the Modified Package

With all of the dependencies installed, it is a simple matter of invoking dpkg-buildpackage to build your new version.

dpkg-buildpackage

Install the New Package

If all went well, you should be able to install your newly-created package.

dpkg -i ../libfreefare*.deb

Viewing latest article 2
Browse Latest Browse All 9

Trending Articles