Setting up Kali Linux in Docker on Windows 10

09/01/2017

2 minutes to read

In this article

This blog is updated at https://ciberesponce.com

A few times now, I find myself wondering why I need a full blown VM. I like need to quickly get my tools up and running on any hardware I find myself on. Most of the time that is a fresh installed Windows 10 on my Surface Book—I like messing things up to a point of no return… what can I say?

As I illustrated the beauty of "Bash on Ubuntu on Windows" in the Azure Security Center's SQL-Injection Playbook, I realized there really must be a better way to bring Kali Linux over to Windows as well. As many know, Kali is a customized Linux distribution, based on Debian. I could, in theory, install Ubuntu and install the Kali repositories and go from there—in addition, I like to stay away from multiple repositories from multiple parties on the same packages. Possible, but a configuration nightmare to maintain and troubleshoot. Kali's official documentation seems to agree with me.

The next best thing is Containers. In the Windows world, this requires Windows 10 Anniversary Edition+. You'll be able to enable Containers, Install Docker, and pull a Kali Linux image all in 10 minutes or less (download speeds may vary ).

Installing the Containers Feature and Installing Docker

First, we must enable the "Containers" feature. Run (ctrl+r) "optionalfeatures".

And make sure this "Containers" option is checked off.

Once that completes, follow these instructions to install docker: https://docs.docker.com/docker-for-windows/install/. Grab the Stable channel Windows MSI and install it. Once you get it to install, you need to log out and log back in. NOTE: Although Docker stated it just needed a log-out/log-in, in order for the Docker service to run on my machine it required a reboot.

After logging back in, in your notifications, you should get a "Docker is starting…".

Pull Official Kali Linux Docker Image

We will be following the guidance here: https://www.kali.org/news/official-kali-linux-docker-images/

Open up your favorite command line interface (CLI). Then type "docker pull kalilinux/kali-linux-docker". This will pull the image from the Docker Store.

Now, let us enter an interactive bash session with that image by typing "docker run -t -I kalilinux/kali-linux-docker /bin/bash"

We are now in our fresh install of Kali. Since this install is meant to be the minimal, you need to grab the packages you actually care about. This helps keep the image small but does require a good Internet connection to get up and running.

Before installing any package, let's upgrade our Kali Linux and remove all packages we no longer need via "apt update && apt full-upgrade && apt auto-remove && apt-autoclean"

Installing the Metasploit Framework

Lastly, let us install the go-to package for most pentesters… Metasploit. A simple command of "apt install metasploit-framework ruby" will do the trick.

Just start up the PostgresSQL database that Metasploit uses, initialize the database, and to msfconsole we go!

Happy Hunting,

Andrew (@ciberesponce)