Kali Linux, or simply Kali, is the newest Linux distribution from Offensive Security. It is the successor to the BackTrack Linux distribution. Unlike most Linux distributions, Kali Linux is used for the purposes of penetration testing. Penetration testing is a way of evaluating the security of a computer system or network by simulating an attack. Throughout this book, we will further explore some of the many tools that Kali Linux has made available.
This chapter covers the installation and setup of Kali Linux in different scenarios, from inserting the Kali Linux DVD to configuring the network.
For all the recipes in this and the following chapters, we will use Kali Linux using GNOME 64-bit as the Window Manager (WM) flavor and architecture (http://www.Kali.org/downloads/). The use of KDE as the WM is not covered in this book; however, you should be able to follow the recipes without much trouble.
The installation to a disk drive is one of the most basic operations. The achievement of this task will let us run Kali Linux without the DVD.
Note
Performing the steps covered in this recipe will erase your hard drive, making Kali Linux the primary operating system on your computer.
Before explaining the procedure, the following requirements need to be met:
A minimum of 8 GB of free disk space for the Kali Linux install (although, we recommend at least 25 GB to hold additional programs and wordlists generated with this book)
A minimum of 512MB of RAM
You can download Kali Linux at http://www.kali.org/downloads/
Let's begin with the installation.
Begin by inserting the Kali Linux Live DVD in the optical drive of your computer. You will ultimately come to the Kali Linux Live DVD Boot menu. Choose Graphical install.
Choose your language. In this case, we chose English.
Choose your location. In this case, we chose United States.
Choose your keyboard configuration. In this case, we chose American English.
The next section to complete is the network services section. Enter a hostname. In this case, we entered
Kali
.Next, we have to enter a domain name. In this case, we enter
kali.secureworks.com
.You will now be presented with the opportunity to choose the password for the root user by entering a password twice.
Choose your timezone. In this case, we chose Eastern.
We are now able to select our disk partition scheme. You will be presented with four options. Choose Guided - use entire disk, as this allows for easy partitioning.
At this step, you will need to acknowledge that your entire disc will be erased. Click on Continue.
Next, you have the option of choosing one of three partitioning schemes: All files in one partition, Separate/home partition, or Separate/home/user/var, and/tmp partitions. Considering Kali is being used more so for penetration testing purposes, a separation of partitions is not needed nor required (even though this is a great idea for your main desktop Linux distribution). In this case, choose All files in one partition and click on Continue.
Once you get to the screen which lets you know that changes are about to be made to your disks, choose Yes and click on Continue. Please note that this is the final chance to back out of having all of your data on your disc overwritten.
Next, you will be asked if you want to connect to a network mirror. A network mirror allows you to receive updates for Kali as they become available. In this case, we choose Yes and click on Continue.
You may skip the HTTP proxy page by clicking on Continue.
Finally, you will be asked to install the GRUB boot loader to the master boot record. Choose Yes and click on Continue.
You have now completed the installation of Kali Linux! Congratulations! Click on Continue and the system will reboot and bring you to the login page.
Having a Kali Linux USB drive provides us with the ability to persistently save system settings and permanently update and install new software packages onto the USB device, allowing us to carry our own personalized Kali Linux, with us at all times.
Thanks to tools such as Win32 Disk Imager, we can create a bootable Live USB drive of a vast majority of Linux distributions, including Kali Linux with persistent storage.
The following tools and preparations are needed in order to continue:
A FAT32-formatted USB drive with a minimum capacity of 8 GB
A Kali Linux ISO image
Win32 Disk Imager (http://sourceforge.net/projects/win32diskimager/files/latest/download)
You can download Kali Linux from http://www.kali.org/downloads/
Let's begin the process of installing Kali Linux to a USB drive:
Insert a formatted/writeable USB drive:
Start Win32 Disk Imager.
At the Image File location, click on the folder icon and select the location of the Kali Linux DVD ISO image:
Make sure that Space used to preserve files across reboots is set to 4096.
Select our USB drive and click on the OK button to start creating the bootable USB drive.
The process will take some time to complete while it extracts and copies the DVD files to the USB and installs the bootloader.
When the installation is complete, we're ready to reboot the computer and boot from the newly created Kali Linux USB drive with persistent memory:
This recipe will take you through the installation of Kali Linux in a completely isolated guest operating system within your host operating system using the well-known open source virtualization software: VirtualBox.
The required prerequisites are listed as follows:
Latest version of VirtualBox (version 4.2.16 as of the time of writing) (https://www.virtualbox.org/wiki/Downloads).
A copy of the Kali Linux ISO image. You can download a copy from http://www.Kali.org/downloads/.
Let's begin the process of installing Kali Linux in Virtualbox:
Launch VirtualBox and click on New to start the Virtual Machine Wizard:
Click on the Next button, type the name of the virtual machine, and choose the OS type as well as the version. In this case, we selected an operating system of Linux and Ubuntu (64 bit) as the version. Click on the Next button to continue:
Select the amount of base memory (RAM) to be allocated to the virtual machine. We're going to use the default value. Click on Next.
Create a new virtual hard disk for the new virtual machine. Click on the Next button:
A new wizard window will open. Leave the default VDI file type as we're not planning to use other virtualization software.
We'll leave the default option as the virtual disk storage details. Click on Next to continue.
Set the virtual disk file location and size:
Check whether the settings are correct and click on the Create button to start the virtual disk file creation.
We're back to the previous wizard with the summary of the virtual machine parameters. Click on Create to finish:
With the new virtual machine created, we're ready to install Kali Linux.
On the VirtualBox main window, highlight Kali Linux and then click on the Settings button:
Now that the basic installation steps have been followed, we will proceed to allow you to use your downloaded ISO file as a virtual disc. This will save you from having to burn a physical DVD to complete the installation. On the Settings screen, click on the Storage menu option:
Next, under Storage Tree, highlight the Empty disc icon underneath IDE Controller. This selects our virtual CD/DVD ROM drive. To the far right of the screen, under Attributes, click on the disc icon. In the pop up that follows, select your Kali Linux ISO file from the list. If the Kali Linux ISO file is not present, select the Choose a virtual CD/DVD disc file... option and locate your ISO. Once you have completed these steps, click on the OK button:
Click on the Start button and then click inside the new window and proceed with the installation. The installation steps are covered in the Installing to a hard disk drive recipe of this chapter.
In this recipe, we will demonstrate how to install Kali Linux as a virtual machine using VMware Tools.
The following requirements need to be fulfilled:
A previously installed Kali Linux VMware virtual machine
An Internet connection
Let's begin the process of installing Kali Linux on VMware:
With your virtual machine's guest operating system powered on and connected to the Internet, open a Terminal window and type the following command to prepare the kernel sources:
prepare-kernel-sources
On the VMware Workstation menu bar, navigate to VM | Install VMware Tools…:
Copy the VMware Tools installer to a temporary location and then change the location to the target directory:
cp /media/VMware\ Tools/VMwareTools-8.8.2-590212.tar.gz /tmp/; cd /tmp/
Untar the installer by issuing the following command:
tar zxpf VMwareTools-8.8.2-590212.tar.gz
Go to the VMware Tools' directory and run the installer:
cd vmware-tools-distrib/ ./vmware-install.pl
Press Enter to accept the default values in each configuration question; the same applies with the
vmware-config-tools.pl
script.Finally, reboot and we're done!
In the first step, we prepared our kernel source. Next, we virtually inserted the VMware Tools CD into the guest operating system. Then, we created the mount point and mounted the virtual CD drive. We copied and extracted the installer in a temporary folder and finally we ran the installer leaving the default values.
The first time we boot into our newly installed Kali Linux system, we will notice that the splash screen has disappeared. In order to manually fix it, we need to extract Initrd
, modify it, and then compress it again. Thankfully, there's an automated bash script created by Mati Aharoni (also known as "muts", creator of Kali Linux) that makes the whole process easier.
Kali Linux comes with several network services which may be useful in various situations and are disabled by default. In this recipe, we will cover the steps to set up and start each service using various methods.
The following requirement is needed in order to continue:
A connection to the network with a valid IP address
Let's begin the process of starting our default service:
Start the Apache server:
service apache2 start
We can verify the server is running by browsing to the localhost address.
To start the Secure Shell (SSH) service, SSH keys need to be generated for the first time:
sshd-generate
Start the Secure Shell server:
service ssh start
To verify the server is up and listening, use the
netstat
command:netstat -tpan | grep 22
Start the FTP server:
service pure-ftpd start
To verify the FTP server, use the following command:
netstat -ant | grep 21
To stop a service, just issue the following command:
service <servicename> stop
Where
<servicename>
stands for the network service we want to stop. For example:service apache2 stop
To enable a service at boot time, use the following command:
update-rc.d –f <servicename> defaults
Where
<servicename>
stands for the network service we want at boot time. For example:update-rc.d –f ssh defaults
At last we come to the final recipe of this chapter. In this recipe, we will see the steps needed to connect to our wireless network with security enabled by using Wicd Network Manager and supplying our encryption details. Setting up our wireless network enables us to use Kali Linux wirelessly. In a true, ethical penetration test, not having to depend on an Ethernet cable enables us to have all of the freedoms of a regular desktop.
Let's begin setting up the wireless network:
From the desktop, start the network manager by clicking on the Applications menu and navigating to Internet | Wicd Network Manager or by issuing the following command at the Terminal window:
wicd-gtk --no-tray
Wicd Network Manager will open with a list of available networks:
Click on the Properties button to specify the network details. When done, click on OK: