J0hnMilt0n

J0hnMilt0n

Reverse Engineer | Android Modder

18 Oct 2022

Build Kali Docker on M1 Mac

Background:

I personally use M1 Macbook. It’s pretty tricky to install VMs on it. So why don’t we just use docker?

Install and run Kali docker

  • Download Docker Desktop for m1.

  • In terminal, download and run Kali docker image:

    docker run -it kalilinux/kali-rolling /bin/bash

  • In Kali shell, update and download essential tools:

    apt-get update & apt install kali-linux-default

  • Install RDP and XFCE:

    apt-get install kali-desktop-xfce xrdp

  • Add a user:

    adduser test

  • Give it sudo priv:

    usermod -aG sudo test

  • Exit from kali, use container id to commit to a new image(so you don’t have to repeat the above steps):

    docker commit xxxxxxxx kali:v1

  • Now, we need to know container is completely isolated from localhost unless you make it open a port:

    docker run -it -p 3389:3389 --expose=3389 kali

Use RDP connect to it

  • Back to kali, start rdp:

    sudo service xrdp start. You can also use status, stop, or restart to control this process.

  • Some RDP software only support ipv4. So we change it to ipv4: sudo nano /etc/xrdp/xrdp.ini and then change port=3389 to port=tcp://:3389.

  • Exit Kali, download Microsoft Remote Desktop. Yes, it can also be used to access Windows remote machines.

  • Type in 127.0.0.1 and you should connect to the kali.

Some bugs

  • When we restart the container after we stopped it, xrdp won’t work.

  • We need to manually remove old processes and start it:

    sudo rm /var/run/xrdp/xrdp* & sudo service xrdp start.

  • So I put it into a bash script.

#!/bin/bash

sudo rm /var/run/xrdp/xrdp*
sudo service xrdp start

etc

It’s faster than vm and super easy to rebuild.

You can always use ps aux to check running processes and netstat -ant for opening ports.


ref:

Categories

etc

Tags