Docker and Kali Linux
Recently the guys from Offensive Security released Kali Linux for Docker which is great news.
So firstly what is Docker?
In simplistic terms it allows you can create the application you want to use and have it run really on anything without the need to create Virtual Machines running a guest Operating System. Imagine running your code on a system that doesn’t need an operating system loaded first, very cool if you ask me.
So what does this mean?
Well for one it allows us to create a template for an application that can be almost spun up in a controlled container easily. Containers allow segmentation of applications and as such means that I can spin up an Ubuntu image and then run different applications each isolated and protected.
Now Kali Linux is a great tool for penetration and security testing and normally requires a full Virtual Machine to work, however using Docker I can create a single Host and run multiple application and images.
How do you use it?
Well first lets spin up a host we can use, for this I am going to use DigitalOcean. Once you have an account simply click to create a Droplet.
For this “Droplet” I am going to call it “Docker” and then use the $5 a month image.
Next we need to select the operating system for the image as well as select from the applications what we need which is “Docker“.
Once we have it set we simply choose to create it which according to the site should be 60 seconds.
Once it loads you should see the configuration options that are available in the web user interface.
Now we need to connect to the “Droplet” which you can do once you get the email that it has been created along with the root username and password needed.
Now I can either connect using the web page or SSH into the “Droplet“.
You are asked to reset the password sent at first login, make sure you use a decent and complicated one (have to say that). Once we are in we can run the following simple command:
This will return the current version of “Docker“.
Next we can run commands to display the containers and images that we have. For now let’s focus on images by running the following command.
docker ps –a
This returns us nothing at the moment, once we have images it will list them.
So how do we get Kali Linux on our new “Droplet”?
This is really easy using the following three commands. This will pull down the image of “Kali Linux” to a “Docker” container
docker pull kalilinux/kali-linux-docker
Once completed we can then run the image which will load the image into its container and then give me a command prompt for the “Kali Linux” instance.
docker run -t -i kalilinux/kali-linux-docker /bin/bash
This should then change the command line to be the command line from “Kali“. First thing I am going to run an update.
apt-get update && apt-get upgrade
Due to the image been trimmed down, to utilize something like “Metasploit” you will need to install it. This can be done using a standard “apt-get” command.
apt-get install metasploit
Once it has completed you are able to then run “Metasploit” using the standard command.
As a note as it configures it for the first time it may come back and say “-killed”, no worries re-run the command and it will work fine.
Once it has been built it should then work as expected.
Now if we exit out of the “Kali Image” we can now run “docker ps –a” and we now should our image and the associated container.
All in all you probably wouldn’t need to launch a Virtual Machine, you would utilize something like “boot2docker” which installs all the pieces you need so you can run something like “Kali Linux” on a workstation easily without needing to setup everything.
If you want to use “DigitalOcean” then use this link: https://www.digitalocean.com/?refcode=36bda18dc83c