Docker and Kali Linux
Docker helps developers build, share, run, and verify applications anywhere with containers. More info on containers here.
A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.
A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.
My notes on Docker can be found here.
Introduction
This will be a guide on setting up Kali Linux in a docker container. Including pulling a new image, setting it up with prefer tools, services, configs, and a GUI if we want. Then covering how to save the image to a file to use on other machines or upload to docker hub to share.
Links
Kali Rolling Docker Image on Docker Hub
Using Kali Docker Images
Grab the latest rolling docker image with
Followed by
NOTE: all the images do not come with the βdefaultβ metapackage. You will need to run:
Installing tools
Itβs pretty simple and basic from here - run
Eg.
Setting up a share
To get file sharing setup between our container and host, we need to have a directory setup for that. On our host, we make a folder wherever we want. Create a quick file in that directory so we can verify the share is working after we run it.
Now when running our Kali image with these parameters:
When in our container, if we go to the /home/share directory, we can see the file we created on our host in the Share directory we made.
Getting a Graphical User Interface(GUI)
Most the tools we run in Kali will be CLI based but sometimes we may need/want a GUI. To get a gui running we need to run
Then we install the XFCE desktop environment with
Since we chose port 13389
for our port to forward, we need to edit the xrdp config
Change the line that says
to
Then start the xrdp service
Verify the XRDP service is running
Before we start the RDP session, we need to change the root password with
Adding a new non-root user
Some tools don't play wel when running as root, so we should make a new user. To do this, we run
Type in the password, then you can press ENTER
when asked for full name, room number, etc.
OPTIONAL: To add the new user to the sudoers file. This will make sure the new user can permissions with as a super user.
We can change to the newly created user with
Making a custom image
While in your container, install all your tools, setup configs, etc. It is important to keep the container running with all your settings, tools and configs! Exit the container and keep it running with
Then run
Save the container in an image you can transfer to other machines with
Now load the image on the new machine with
Now run the new container with all of our settings
I've added that as an alias in my terminal
Conclusion
Thatβs it! Now you have a nice, custom Kali docker image setup with our tools, users, settings, and configs that donβt require any setup or even an internet connection!
Last updated