Day 4 OSCP | Searching, Installing and Removing Tools

Reading Time: ( Word Count: )

December 9, 2020
Nextdoorsec-course

Let’s discuss how to search for, install, or remove tools in Kali Linux. In this post, 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.

 

Version Check

Let’s first check the version of Kali Linux we’re using by running “lsb_release -a” or “cat /etc/os-release. You can also test the “uname -a” command to see your running Debian version, check if your system runs on 32 or 64-bits and some other info.

  ┌──(kali㉿kali)-[~]      └─$ lsb_release -a No LSB modules are available. Distributor ID: Kali Description: Kali GNU/Linux Rolling Release: 2020.4 Codename: kali-rolling
  ┌──(kali㉿kali)-[~]      └─$ cat /etc/os-release PRETTY_NAME="Kali GNU/Linux Rolling" NAME="Kali GNU/Linux" ID=kali VERSION="2020.4" VERSION_ID="2020.4" VERSION_CODENAME="kali-rolling" ID_LIKE=debian ANSI_COLOR="1;31" HOME_URL="https://www.kali.org/" SUPPORT_URL="https://forums.kali.org/" BUG_REPORT_URL="https://bugs.kali.org/"
  ┌──(kali㉿kali)-[~]      └─$ lsb_release -a Linux kali 5.9.0-kali2-amd64 #1 SMP Debian 5.9.6-1kali1 (2020-11-11) x86_64 GNU/Linux

 

 

Apt-update

Now let us get the packages information from repositories. These repositories are websites that provide packages and their metadata. After getting the package information, we will locally compare them against our existing packages.

The “sudo apt update” command will download the metadata which includes information related to their versions, descriptions, etc. Just know that this command doesn’t update or upgrade any tool.

  ┌──(kali㉿kali)-[~]      └─$ sudo apt update Hit:1 http://archive-4.kali.org/kali kali-rolling InRelease Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date.

 

 

Apt upgrade or apt dist-upgrade

After the APT database has been updated, we can upgrade the installed packages to their latest versions using the sudo apt upgrade command.

If you want to upgrade a single package, add the package name after the apt upgrade command such as apt upgrade python3.

You can also upgrade the core system and the tools at the same time by running “sudo apt dist-upgrade” or an alternative is “sudo apt full-upgrade“.

After the process you can use “sudo apt autoremove“, to remove automatically installed packages (dependencies) that are no longer needed after the upgrade, it’ll save you some space.

  ┌──(kali㉿kali)-[~]      └─$ sudo apt upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
  ┌──(kali㉿kali)-[~]      └─$ sudo apt dist-upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
  ┌──(kali㉿kali)-[~]      └─$ sudo apt full-upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
  ┌──(kali㉿kali)-[~]      └─$ sudo apt autoremove Reading package lists... Done Building dependency tree Reading state information... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

 

 

Apt install & apt remove

The apt install” command can be used to add a package to the system with apt install followed by the package name.

  ┌──(kali㉿kali)-[~]      └─$ sudo apt install gedit Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: gedit-plugins The following NEW packages will be installed: gedit 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. ...

 

Similarly, we can remove a package with the command 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. Usually, it leaves small (modified) user configuration files behind, in case the removal was accidental. Adding the –purgeoption removes all the leftovers.

  ┌──(kali㉿kali)-[~]      └─$ sudo apt remove --purge gedit Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: gedit-common gir1.2-gtksource-4 gir1.2-peas-1.0 libamtk-5-0 libamtk-5-common libgtksourceview-4-0 libgtksourceview-4-common libpeas-1.0-0 libpeas-common libtepl-4-0 Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED: gedit* 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 2,024 kB disk space will be freed. Do you want to continue? [Y/n]

 

 

Installing tools offline with dpkg

dpkg stands for “Debian package” and is the core tool used to install, build, remove and manage Debian packages, 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. It is a low-level tool, whereas APT is a higher-level tool. 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.

Let’s practice by downloading and installing Google Chrome for Kali Linux using “dpkg”. Go to the following website to download the “.deb” package for your OS.
cd” to your Downloads/ page afterwards and sudo “dpkg -i google-chrome-stable_current_amd64.deb“. Now you should have Google Chrome on your Kali Linux.

If you’re not happy with your newly installed package, you can use “dpkg -r google-chrome-stable_current_amd64.deb” to remove it. Beware for leftovers!

Suppose we want to purge a package, a process which removes everything, including configuration files. This can be done using the “-P” option.

  ┌──(kali㉿kali)-[~/Downloads]      └─$ ls google-chrome-stable_current_amd64.deb
  ┌──(kali㉿kali)-[~/Downloads]      └─$ sudo dpkg -i google-chrome-stable_current_amd64.deb Selecting previously unselected package google-chrome-stable. (Reading database ... 270729 files and directories currently installed.) Preparing to unpack google-chrome-stable_current_amd64.deb ... Unpacking google-chrome-stable (87.0.4280.88-1) ... Setting up google-chrome-stable (87.0.4280.88-1) ...

 

Conclusion

After installing Kali Linux, I run by default “sudo apt dist-upgrade“, followed by “sudo apt update && apt upgrade -y“, a combo you can pick to update & upgrade the existing tools on your machine and automatically saying “yes” to confirm. When it’s finished, I run “sudo apt autoremove” to remove the unnecessary files installed during the upgrade process.

Aydan Arabadzha

Aydan Arabadzha

Author

Aydan, a cybersecurity ace and AI visionary, thrives on the frontlines of offensive security. His passion birthed NextdoorSec, a groundbreaking cybersecurity firm. A relentless pioneer, Aydan is persistently pushing boundaries, shaping the future of the digital world one byte at a time.

Other interesting articles

Automated vs Manual Penetration Testing

Automated vs Manual Penetration Testing

Pentesting is largely divided into two methodologies: Automated vs Manual Penetration Testing. Both have ...
8 Steps in Penetration Testing You Should Know

8 Steps in Penetration Testing You Should Know

Mastering the art of penetration testing has become a critical ability for security experts to combat cyber ...
Spear Phishing vs Whaling: What is the Difference

Spear Phishing vs Whaling: What is the Difference

Spear phishing is a particularly devious type of phishing assault in which the individual targeted plays a ...
How Often Should Penetration Testing Be Done

How Often Should Penetration Testing Be Done

Penetration testing is a crucial technique that involves simulating a cyberattack on networks, computer systems, ...
0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *