The Kali VMware image contains the most common tools used in the field of penetration testing.
However, it is not practical to include every single tool present in the Kali repository in the VMware
image. Therefore, we’ll need to discuss how to search for, install, or remove tools. In this section,
we will be exploring the Advanced Package Tool (APT) toolset as well as other commands that are
useful in performing maintenance operations on the Kali Linux OS.
APT is a set of tools that helps manage packages, or applications, on a Debian-based system. Since Kali is based on Debian, we can use APT to install and remove applications, update packages, and even upgrade the entire system. The magic of APT lies in the fact that it is a complete package management system that installs or removes the requested package by recursively satisfying its requirements and dependencies.
Information regarding APT packages is cached locally to speed up any sort of operation that
involves querying the APT database. Therefore, it is always good practice to update the list of
available packages, including information related to their versions, descriptions, etc. We can do this with the apt update command as follows:
[email protected]:~$ sudo apt update Hit:1 http://kali.mirror.globo.tech/kali kali-rolling InRelease Reading package lists… Done Building dependency tree Reading state information… Done 699 packages can be upgraded. Run 'apt list --upgradable' to see them.
After the APT database has been updated, we can upgrade the installed packages and core system to the latest versions using the apt upgrade command.
In order to upgrade a single package, add the package name after the apt upgrade command
such as apt upgrade metasploit-framework .
apt-cache search and apt show
The apt-cache search command displays much of the information stored in the internal cached
package database. For example, let’s say we would like to install the pure-ftpd application via APT.
The first thing we have to do is to find out whether or not the application is present in the Kali Linux repositories. To do so, we would proceed by passing the search term on the command line:
[email protected]:~$ apt-cache search pure-ftpd mysqmail-pure-ftpd-logger - real-time logging system in MySQL - Pure-FTPd traffic-logg pure-ftpd - Secure and efficient FTP server pure-ftpd-common - Pure-FTPd FTP server (Common Files) pure-ftpd-ldap - Secure and efficient FTP server with LDAP user authentication pure-ftpd-mysql - Secure and efficient FTP server with MySQL user authentication pure-ftpd-postgresql - Secure and efficient FTP server with PostgreSQL user authentica resource-agents - Cluster Resource Agents
The output above indicates that the application is present in the repository. There are also a few
authentication extensions for the pure-ftpd application that may be installed if needed.
Interestingly enough, the resource-agents package is showing up in our search even though its
name does not contain the “pure-ftpd” keyword. The reason behind this is that apt-cache search
looks for the requested keyword in the package’s description rather than the package name itself.
To confirm that the resource-agents package description really contains the “pure-ftpd” keyword,
pass the package name to apt show as follows:
[email protected]:~$ apt show resource-agents Package: resource-agents Version: 1:4.2.0-2 ... Description: Cluster Resource Agents This package contains cluster resource agents (RAs) compliant with the Open Cluster Framework (OCF) specification, used to interface with various services in a High Availability environment managed by the Pacemaker resource manager. . Agents included: AoEtarget: Manages ATA-over-Ethernet (AoE) target exports AudibleAlarm: Emits audible beeps at a configurable interval ... NodeUtilization: Node Utilization Pure-FTPd: Manages a Pure-FTPd FTP server instance Raid1: Manages Linux software RAID (MD) devices on shared storage ...
In the output above, apt show clarifies why the resource-agents application was mysteriously
showing up in the previous search for pure-ftpd.
The apt install command can be used to add a package to the system with apt install
followed by the package name. Let’s continue with the installation of pure-ftpd:
[email protected]:~$ sudo apt install pure-ftpd Reading package lists… Done Building dependency tree Reading state information… Done The following additional packages will be installed: pure-ftpd-common The following NEW packages will be installed: pure-ftpd pure-ftpd-common 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 309 kB of archives. After this operation, 880 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://kali.mirror.globo.tech/kali kali-rolling/main amd64 pure-ftpd-common all Get:2 http://kali.mirror.globo.tech/kali kali-rolling/main amd64 pure-ftpd amd64 1.0.4 Fetched 309 kB in 4s (86.4 kB/s) Preconfiguring packages … ...
Similarly, we can remove a package with the command apt remove –purge .
apt remove –purge
The apt remove –purge command completely removes packages from Kali. It is important to
note that removing a package with apt remove removes all package data, but leaves usually small
(modified) user configuration files behind, in case the removal was accidental. Adding the –purge
option removes all the leftovers.
[email protected]:~$ sudo apt remove --purge pure-ftpd Reading package lists… Done Building dependency tree Reading state information… Done The following package was automatically installed and is no longer required: pure-ftpd-common Use 'sudo apt autoremove' to remove it. The following packages will be REMOVED: pure-ftpd* 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 581 kB disk space will be freed. Do you want to continue? [Y/n] y (Reading database … 388024 files and directories currently installed.) Removing pure-ftpd (1.0.47-3) … Cannot find cached rlinetd's config files for service ftp, ignoring remove request Processing triggers for man-db (2.8.5-2) … (Reading database … 388011 files and directories currently installed.) Purging configuration files for pure-ftpd (1.0.47-3) … Processing triggers for systemd (240-6) …
Excellent! You are now able to search, install, and remove tools in Kali Linux. Let’s explore one last
command in this module: dpkg.
dpkg is the core tool used to install a package, either directly or indirectly through APT. It is also the preferred tool to use when operating offline, since it does not require an Internet connection. Note that dpkg will not install any dependencies that the package might require. To install a package with dpkg , provide the -i or –install option and the path to the .deb package file. This assumes that the .deb file of the package to install has been previously downloaded or obtained in some other way.
[email protected]:~$ sudo dpkg -i man-db_18.104.22.168-5_amd64.deb (Reading database … 86425 files and directories currently installed.) Preparing to unpack man-db_22.214.171.124-5_amd64.deb … Unpacking man-db (126.96.36.199-5) over (188.8.131.52-4) … Setting up man-db (184.108.40.206-5) … Updating database of manual pages … Processing triggers for mime-support (3.58) … ...