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,45 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.
apt update
--------------
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:
kali@kali:~$ sudo apt update
apt upgrade
-------------------
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.
"While you can upgrade your Kali
Linux installation at any time, it’s a good idea to take a snapshot of the virtual machine in a clean state (before any changes have been made) before doing so. This has two major benefits. First of all, it will ensure that you have a snapshot of a tested build that will work for all exercises and secondly, if you encounter issues and have to contact our support team, they will know the versions of tools you are using and how they behave. For an actual penetration test, these same concerns will apply. You will learn more about how to balance having the newest tools with having a trusted build as you gain more experience and familiarity with Kali
Linux."
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:
kali@kali:~$ apt-cache search pure-ftpd
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:
kali@kali:~$ apt show resource-agents
In the output above, apt show clarifies why the resource-agents application was mysteriously
showing up in the previous search for pure-ftpd.
apt install
-------------
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:
kali@kali:~$ sudo apt install pure-ftpd
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
kali@kali:~$ sudo apt remove --purge pure-ftpd
Excellent! You are now able to search, install, upgrade and remove tools in Kali
Linux. Let’s
explore one last command in this module: dpkg.
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.
kali@kali:~$ sudo dpkg -i man-db_2.7.0.2-5_amd64.deb