By: Slade Griffin
Contextual Security Solutions | February 20, 2018 @ 4:24
Recently I realized that I often flippantly say “just install kali in a VM and…” do whatever. It dawned on me after a few questions from some students that I was assuming far too much from my own experience with those few words. I decided to write up a walkthrough for people wanting to set this up. If you are using other combinations of software, let me know and I will write up a similar walkthrough for your platform as I have time. This post is intended for technical readers who understand the basics of networking, virtualization, and system administration.
Download VirtualBox and the current extension pack. As of this writing, the URL to download is https://www.virtualbox.org/wiki/Downloads . The figure below has the two relevant parts of the page highlighted in the red box.
Go ahead and click the “Windows hosts” link and the “All supported platforms” link. You should end up with 2 files to install that look something like this.
Version numbers will change but for now, February of 2018, these are the current files. Now that you have the files double-click the VirtualBox-x.x.x-x-x.exe file and complete the setup using the defaults. Once VirtualBox is installed go back to the directory containing the files in the figure above and double-click to install the extension pack.
Now that VirtualBox and the extension pack are installed, let’s setup a virtual machine for Kali Linux.
Open the VirtualBox program and look near the top left of the window for the “New” button and click that.
After selecting new you will be prompted to provide some information about the type of system you want to install. You can name the system whatever you want in the “Name:” field. In the next field click the dropdown arrow and select Linux as the system “Type:”. My host system is 64-bit Windows 7 so I downloaded the 64-bit version of Kali (which is derived from Debian Linux) and will enter that in the “Version:”. These values are shown in the figure below.
The next set of input required is to select how much memory (RAM) you want to allocate to your virtual machine (VM). A minimum of two gigabytes is necessary to run Kali Linux well and VirtualBox calculates this in megabytes (MB) so some conversion is necessary. If you’re not familiar with converting these values, the following table should help.
The figure below shows that I have allocated 4 GB of RAM to this VM. You can choose to either move the slider, type in the box, or use the directional arrows to adjust the amount of memory allocated to your VM.
After selecting the appropriate amount of RAM for system, click the next button. You’ll now be presented with a dialog box for selecting a hard disk. The figure below gives 3 options and for the purposes of the walkthrough use the options shown.
The following screen asks what type of disk you want the software to create. There are extensive discussions online regarding the merits of each type of disk that this blog entry will not delve into. A short summary would be if you plan to export this image one day into VMWare, then please select the VMDK option. For our purposes today, we will use the options shown below.
The next screen asks how storage should be allocated, I choose dynamic and then click Next.
Following this requires us to select how big we want the virtual hard drive to be. This again is dependent on the resources available from the host, but I typically choose between 50 and 200 gigabytes depending on how much data I will be keeping on the system. This value is selected similar to the memory size screen we had earlier. Once you have selected the appropriate size of drive click Create.
This will bring you back to the main VirtualBox screen where we will next select the “Settings” button for the highlighted virtual machine as shown in the figure below.
The following screen options are highlighted, and you will select them from right to left. Click “Storage”, Empty, check “Live CD/DVD”, and then the down arrow to the bottom right of the disk icon and select the top option.
Now, navigate to the directory where you previously downloaded Kali Linux, select the .iso file and then click open. Your filename and location might be different, but it should look something like the image below.
Next confirm that the device is set to boot up from the kali-linux iso as shown below and click OK.
This should return you to the main screen where you can verify the highlighted settings in the figure below and then click Start.
The first screen you see will ask you what you want to do. Select either “Install” or “Graphical Install” and then hit enter. I will use the “Graphical Install” as it makes prettier pictures for the writeup.
The next screen will ask what language you want to use, select the appropriate language for yourself and click continue. Several screens follow this pattern and will be shown with no commentary.
You will now be asked to enter a password to protect the root account. I’d like to think that saying this should be a long complex password is common knowledge, but my password cracking experience says otherwise. Please use at least 12 characters with a sufficient amount of complexity that is something you can remember.
For the following screen you are free to choose different options but for this example we will use the default selection.
You should only have one option for choosing a disk and it should be the corresponding size that you chose earlier during the setup. The image below represents the 50GB value I previously selected even though the size is slightly different.
The following screen will need to have the default selection changed to yes before you continue.
The system should now be installing, and this can take quite some time depending on the speed of your host system. Don’t get discouraged, you’re almost there. The following screen will ask if you want to use a network mirror, make sure that yes is selected and click continue.
Several of you will be using a proxy device to access the Internet. If you are, you will need to either whitelist your host or enter your credentials in the following screen in order to access the network mirror. If your username was “bob” and your password was ”chickens” with a proxy IP address of 192.168.25.1 on port 8080 you would enter:
If you are using WCCP, or a transparent proxy mode, then you will not need the port number. Lastly, with respect to the proxy, you may have to use https in place of http depending on your environment.
On the following screen you will have to select the disk you partitioned in order to install the bootloader.
Your installation is finished and there is no media to remove so click continue. You’re almost a hacker but there’s one more thing I want to walk through with you. Your system should reboot, and you will end up at a login screen like the one pictured (Remember I used XFCE).
If you maximize your window however you will notice that the system does not resize and take advantage of your display’s capabilities. I’ve shown this below and highlighted the unused screen area with the red arrows. Go ahead and log in with your root username and the password you created earlier.
You will also get asked how to configure the launcher.
This should bring you to the Kali Linux desktop, glorious isn’t it? Let’s fix this screen resolution issue and also enable some other enhanced functionality we will cover in subsequent blogs about shared folders and clipboards.
Go ahead and click the Terminal icon which is highlighted in the figure below.
Once you have the terminal open run apt-get update to have your system check what package updates are available.
After the update is finished run apt-get upgrade.
This will print some text on the screen and then ask if you want to install the packages, enter Y and hit enter to upgrade your system.
The first time you run this can take quite a while so just wait until it’s done and then run apt-get dist-upgrade. During the upgrade you will be asked several questions as shown below. The first image shows postgresql upgrading which will pause on your screen. Hit q to continue.
Select the options shown in the following images with your arrow keys and hit enter to continue.
This command upgrades the distribution to the latest supported kernel and applies other system updates not included in a standard upgrade.
This will be similar to the previous sequence so select Y when prompted and wait for the distribution upgrade to complete. After this upgrade you will need to reboot your system which can be performed by either typing reboot at the command line and hitting enter or click on the word root in the upper right-hand corner of your screen and selecting logout.
Once the machine has rebooted, we need to install the appropriate kernel headers for your system. This is done by opening a terminal and running apt-get install linux-headers-$(uname -r). At times I have had to run apt-get update prior to installing the kernel headers so if it fails try that first.
You will need to reboot once this command is finished as well and then log back in. Go to the menu bar after you’ve logged back in as root and click devices, then select “Insert Guest Additions CD image…” as shown in the following image.
This will place an icon on your desktop as shown in the figure below. Right-click the icon and select “mount volume”.
Now open a terminal window and navigate to /media/cdrom0 as shown in the figure below. The commands you will run are as follows
Once that command has finished, reboot and log back in. If all of the commands completed successfully, you should be able to resize your VirtualBox window and have the virtual machine automatically resize to take advantage of the correct resolution as shown below.
There are many more tips and tricks I hope to follow up with such as sharing your clipboard, shared folders, and network settings for penetration testing but this has gotten very long. I look forward to writing some of those up soon.