Docker and Kali Linux
Last updated
Last updated
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.
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.
Kali Rolling Docker Image on Docker Hub
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:
Itβs pretty simple and basic from here - run
Eg.
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.
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
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
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
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!
Now we can use whatever RDP service we want to access our Kali Docker via GUI using localhost:13389
. I'm using Remmina, but you can use any software you choose that supports RDP. NOTE: Depending on your RDP software, you will need to choose the screen resolution you want. Otherise it will default as a 600x800 resolution.