Docker kali linux образы

TL;DR

I’m sure you have already been in the same situation than me. You’re working at a client’s office for a penetration test, a tight time slot for your tests, no downtime. You arrive a little late in the morning (thanks to the strikes) and your virtual machine containing all your tools doesn’t want to start (I knew I shouldn’t have play with my bootloader yesterday night tss).

No choice, you have to reinstall this machine. And rapidly !

Ho God finished ! Why dit it takes so long to install a s***y debian ??

F** why is it so long to boot ? And this dekstop pfff. Why there is no i3 default desktop .

kali@tools:~$ crackmapexec bash: crackmapexec: command not found 

FFF*** why CrackMapExec is not installed by default ??

STOP ! If you’ve already been is this situation before, this article is for you 😉 Have you ever heard of Docker ? Yes I hope ! Docker provides applications through containerisation technology. It’s a really mainstream and usefull technology.

I will not describe here how docker works, the docs is already very good : https://docs.docker.com/engine/docker-overview/

I think you’ve got it, we’re going to use Docker for our offensive use. So I wrote a small Dockerfile and docker-compose file to build a light kali image with usefull tools. Project : https://github.com/thibaudrobin/docker-kali-light. Let’s go into a little bit of detail.

1. Install docker

First you need to install Docker obviously. The documentation is really clear.

For Linux

For Windows :

  1. Open the official documentation : https://docs.docker.com/docker-for-windows/install
  2. Grab account credentials on BugMeNot : http://bugmenot.com/view/id.docker.com
  3. Go to https://hub.docker.com/?overlay=onboarding to download Docker client.
  4. Install Hyper-V : https://docs.microsoft.com/fr-fr/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v
    • Open a PowerShell console as an administrator.
    • Type command : Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

Warning : Warning, unfortunately it’s not possible to have Hyper-V with VMware or Virtualbox :'(. You will have to choose one of three systems.

2. Create a nice Dockerfile

Ok now that you have Docker, we can build our own Kali image. All the images are available online (https://www.kali.org/news/official-kali-linux-docker-images/) but none of them are really interresting. Below are all the tools I need :

aircrack-ng crackmapexec crunch curl dirb dirbuster dnsenum dnsrecon dnsutils dos2unix enum4linux exploitdb ftp git gobuster hashcat hping3 hydra impacket-scripts john joomscan masscan metasploit-framework mimikatz nasm ncat netcat-traditional nikto nmap patator php powersploit proxychains python-impacket python-pip python2 python3 recon-ng responder samba samdump2 smbclient smbmap snmp socat sqlmap sslscan sslstrip theharvester vim wafw00f weevely wfuzz whois wordlists wpscan 

If you check Kali metapackages (https://tools.kali.org/kali-metapackages), you will always see packages with too much tools or not enough. The kali-light metapackage is a real joke (there is 0 offensive tools wtf). Let’s build a REAL kali-light image without burp, firefox and all other useless tools in docker.

# Dockerfile kali-light # Official base image FROM kalilinux/kali-rolling # Apt RUN apt -y update && apt -y upgrade && apt -y autoremove && apt clean # Tools RUN apt install aircrack-ng crackmapexec crunch curl dirb dirbuster dnsenum dnsrecon dnsutils dos2unix enum4linux exploitdb ftp git gobuster hashcat hping3 hydra impacket-scripts john joomscan masscan metasploit-framework mimikatz nasm ncat netcat-traditional nikto nmap patator php powersploit proxychains python-impacket python-pip python2 python3 recon-ng responder samba samdump2 smbclient smbmap snmp socat sqlmap sslscan sslstrip theharvester vim wafw00f weevely wfuzz whois wordlists wpscan -y --no-install-recommends # Alias RUN echo "alias l='ls -al'" >> /root/.bashrc RUN echo "alias nse='ls /usr/share/nmap/scripts | grep '" >> /root/.bashrc RUN echo "alias scan-range='nmap -T5 -n -sn'" >> /root/.bashrc RUN echo "alias http-server='python3 -m http.server 8080'" >> /root/.bashrc RUN echo "alias php-server='php -S 127.0.0.1:8080 -t .'" >> /root/.bashrc RUN echo "alias ftp-server='python -m pyftpdlib -u \"admin\" -P \"S3cur3d_Ftp_3rv3r\" -p 2121'" >> /root/.bashrc # Set working directory to /root WORKDIR /root # Open shell CMD ["/bin/bash"] 

3. Build your new image

You can now create the image with command : docker build -t kali-light .

[th1b4ud@th1b4ud-pc ~]$ mkdir kali-light [th1b4ud@th1b4ud-pc ~]$ cd kali-light/ [th1b4ud@th1b4ud-pc kali-light]$ docker build -t kali-light . Sending build context to Docker daemon 3.072kB Step 1/11 : FROM kalilinux/kali-rolling ---> b379e18689e6 Step 2/11 : RUN apt -y update && apt -y upgrade && apt -y autoremove && apt clean ---> Running in 0abf61ba9ad5 [. ] Need to get 611 MB of archives. Step 11/11 : CMD ["/bin/bash"] ---> Running in 97bf4e6e2db5 Removing intermediate container 97bf4e6e2db5 ---> e38e1334fdca Successfully built e38e1334fdca Successfully tagged kali-light:latest 

As you can see, our new image has only 500MB of tools to download. It should download quickly. 😀

Читайте также:  Процесс загрузки ядра linux

4. Write Docker compose file

Now that we have built our new image, we can write a Docker compose file to facilitate container deployment. This will allow us to, for example, create a container with a directory shared with our host. In our case, we will share /mnt/share-kali-light from our host to /share directory in containers.

version: '3' services: kali-light: image: "kali-light" volumes: - /mnt/share-kali-light:/share 

5. Create containers

We can now deploy containers with the docker-compose command. First install it.

[th1b4ud@th1b4ud-pc kali-light]$ pip install docker-compose --user Collecting docker-compose 

And always in working directory launch docker-compose.

[th1b4ud@th1b4ud-pc kali-light]$ sudo mkdir /mnt/share-kali-light [th1b4ud@th1b4ud-pc kali-light]$ docker-compose run kali-light root@08cb02395204:~# l total 16 drwx------ 1 root root 4096 Jan 26 04:20 . drwxr-xr-x 1 root root 4096 Feb 8 15:09 .. -rw-r--r-- 1 root root 844 Feb 8 01:36 .bashrc -rw-r--r-- 1 root root 148 Jan 17 17:22 .profile 

We can verify that we have our shared directory.

[th1b4ud@th1b4ud-pc kali-light]$ echo "OK" > /mnt/share-kali-light/OK root@08cb02395204:~# l /share/; cat /share/OK total 12 drwxr-xr-x 2 1000 1000 4096 Feb 8 15:13 . drwxr-xr-x 1 root root 4096 Feb 8 15:09 .. -rw-r--r-- 1 1000 1000 3 Feb 8 15:12 OK OK 

By exiting the container with the command ‘exit’ we can see that it is still present. We can easily remove it with the docker container rm command.

[th1b4ud@th1b4ud-pc kali-light]$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 08cb02395204 kali-light "/bin/bash" 4 minutes ago Exited (0) 4 seconds ago kali-light_kali-light_run_9e9e44eb9410 [th1b4ud@th1b4ud-pc kali-light]$ docker container rm 08 08 [th1b4ud@th1b4ud-pc kali-light]$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 

We can also launch container from others directory.

[th1b4ud@th1b4ud-pc ~]$ docker-compose -f /home/th1b4ud/kali-light/docker-compose.yml run kali-light root@07a9e76dfb70:~# 

6. Create some alias

Usefull alias for your .bashrc. Don’t forget to change the location of the project !

echo "alias kali='docker-compose -f $HOME/kali-light/docker-compose.yml run kali-light'" >> .bashrc && source .bashrc 

Источник

Читайте также:  Linux ssh server enable

Docker kali linux образы

Kali provides official Kali Docker images that are updated once a week on Docker Hub. You can thus easily build your own Kali containers on top of those that we provide. We offer various images to try and suit your needs, all with a different variation of Kali Linux as they use unique branches for the source.

Please note, all the images below do not come with the “default” metapackage. You will need to apt update && apt -y install kali-linux-headless .

Here’s a quick review of the various images available (for more detailed information, see our branch page). First those that you might reasonably want to use:

  • kalilinux/kali-rolling is the main image that you should likely use, tracking the continuously-updated kali-rolling package repository, just like the default images.
  • kalilinux/kali-last-release is built from the kali-last-snapshot repository, it is tracking the last versioned release (e.g. 2019.4, 2020.1, etc.) and will not get any update until the next release.

And those that you will likely not need except in very special cases:

  • kalilinux/kali-bleeding-edge is exactly like kalilinux/kali-rolling with the “kali-bleeding-edge” repository enabled.
  • kalilinux/kali-experimental is exactly like kalilinux/kali-rolling with the kali-experimental repository enabled. Might be useful to test some not-yet-ready updates uploaded to “kali-experimental” by Kali developers who are looking for feedback.
  • kalilinux/kali-dev is an image tracking the kali-dev repository used by Kali developers to merge updates coming from Debian and changes maintained by Kali Linux. It can be useful to rebuild (or do test rebuild of) Kali packages.

If you want to improve our official Docker images, have a look at the kali-docker project in our GitLab. We use GitLab CI to automate the build of our Docker images.

Читайте также:  Линукс минт мате настройки

Updated on: 2023-Mar-06
Author: rhertzog

Источник

Docker kali linux образы

To use the Kali Linux Docker image, we will do the following commands:

[email protected]:~$ docker pull docker.io/kalilinux/kali-rolling [email protected]:~$ [email protected]:~$ docker run --tty --interactive kalilinux/kali-rolling ┌──(root㉿e4ae79503654)-[/] └─# ┌──(root㉿e4ae79503654)-[/] └─# exit [email protected]:~$ 

Please note, that this does not allow for systemd functionality, which would allow access to items such as systemctl . There are ways to get systemd to work with Docker, however they include modifying the Dockerfile and docker run flags. At this time this will not be covered.

Please also note, all the images below do not come with the “default” metapackage. You will need to apt update && apt -y install kali-linux-headless .

To resume an exited container we will complete the following:

[email protected]:~$ docker container list --all CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d36922fa21e8 kalilinux/kali-rolling "/bin/bash" 2 minutes ago Exited (0) About a minute ago lucid_heyrovsky [email protected]:~$ [email protected]:~$ docker start d36922fa21e8 [email protected]:~$ 

After you execute the following command you will attach to the Docker container, however you must press return once to fully see the prompt:

[email protected]:~$ docker attach d36922fa21e8 ┌──(root㉿d36922fa21e8)-[/] └─# 

This will resume the container in whatever state you left it after running the initial docker run command or the last docker start and docker attach sequence.

Finally, if you’re done with the container you can remove it with the following command:

[email protected]:~$ docker rm d36922fa21e8 d36922fa21e8 [email protected]:~$ 

Updated on: 2023-Mar-06
Author: gamb1t

Источник

Оцените статью
Adblock
detector