Now let’s say you want to install the awesome tool called Metasploit (which is like the Swiss Army knife of hacking). Instead of going through the hassle of downloading and compiling it yourself, you can simply run this command:
# This script updates the package list, upgrades existing packages, and installs the Metasploit framework.
# Update the package list using the apt-get command.
apt-get update
# Upgrade existing packages using the apt-get command with the -y flag to automatically answer yes to prompts.
apt-get upgrade -y
# Install the Metasploit framework using the apt-get command.
apt-get install metasploit-framework
This will automatically check for any updates or upgrades to your system (which is always a good idea), and then proceed with the installation of Metasploit. Pretty sweet, right?
But what if you want to customize your Kali setup even further? Well, that’s where the “sources” come in. These are basically like extra repositories that we can add on top of our default ones (which is called “main”). For example:
# This script adds extra repositories to the sources.list file in order to customize the Kali setup.
# The first line adds the main repository with the "kali-rolling" release, along with the "contrib" and "non-free" components.
echo 'deb http://http.kali.org/kali kali-rolling main contrib non-free' >> /etc/apt/sources.list
# The second line adds the security repository with the "kali-rolling/updates" release, along with the "main", "contrib", and "non-free" components.
echo 'deb http://security.kali.org/kali-security kali-rolling/updates main contrib non-free' >> /etc/apt/sources.list
This will add the “kali-rolling” and “kali-security” repositories to our list of sources, which should give us access to even more tools and packages (including security updates). And if you want to remove any of these repositories later on, just run:
# This script removes the "kali-tools-common" package and any other packages from the "kali-tools" repository that are no longer needed.
# It also creates a list of all the repositories currently in use and removes any empty lines from the list.
# Remove the "kali-tools-common" package and any other packages from the "kali-tools" repository that are no longer needed.
apt-get purge kali-tools-common -y
# Create a list of all the repositories currently in use and save it to a temporary file.
apt-cache policy kali-tools | grep 'Candidate' | awk '{print $2}' | sort -u > /tmp/kali_repos.txt
# Remove any empty lines from the list of repositories.
sed '/^$/d' < /tmp/kali_repos.txt | xargs sudo apt-get remove -y
This will purge the “kali-tools-common” package (which is a dependency for many other tools), and then list all of our current repositories using “apt-cache policy”. We’ll pipe this output to grep, which will filter out any blank lines or headers. Then we’ll use awk to extract the candidate version number from each line, sort it alphabetically (using -u for unique), and save it to a temporary file called /tmp/kali_repos.txt. Finally, we’ll pipe this list of repositories through xargs, which will execute “apt-get remove” on each one with the “-y” flag (which means “yes” to any confirmation prompts).
The Kali repositories explained in simple English. Now go out and hack something cool!