Ubuntu18.04 uses Docker to install Kali-Linux detailed configuration tutorial


Insert picture description here

introduction

Kali Linux is an open source Debian-based special operating system for penetration testing. The system contains a series of artifacts for penetration testing.

Docker is currently the hottest open source application container, released in June 2014. It allows developers to package their applications and dependent packages into a portable container, and then publish to any popular Linux machine, it can also be virtualized.

Docker can be regarded as a shipping carton on the Internet-a tool that allows Internet software developers to neatly package their work and quickly deliver it to one computer after another.

Kali system developer Mati Aharoni believes: The beauty of combining Docker with Kali is that Kali is placed in a great, clean container. Since the release of the Docker version of Kali Linux, network security enthusiasts and penetration test engineers can fully control Kali on Windows, Mac or Linux.

The advantages of installing Kali-Linux virtual machine in Docker are: start up faster than virtual machine, can start in seconds, and can flexibly and automatically create and deploy images & containers through Dockerfile configuration file, improve work efficiency; Docker takes up less resources In addition to running Kali-Linux, it basically does not consume other system resources, ensuring application performance while minimizing system overhead.

Docker

View system version

cat /etc/issue
Ubuntu 18.04.3 LTS \n \l

Update system

sudo apt-get update && sudo apt-get upgrade

Install Docker

#安装 docker 软件包
sudo apt-get install docker.io 
#查看版本号
sudo docker -v
#启动服务
sudo systemctl start docker
#允许开机自启动
sudo systemctl enable docker
#查看运行状态
sudo systemctl status docker

docker
Add a mirror source to improve the download speed of the mirror. It is recommended to use Alibaba Cloud Mirror Accelerator . The following is the mirror source of the University of Science and Technology of China

sudo vim /etc/docker/daemon.json

{
“registry-mirrors”: [“https://docker.mirrors.ustc.edu.cn/”]
}

Pull Kali-Linux image

sudo docker pull kalilinux/kali-linux-docker

Insert picture description here
View mirror

sudo docker images

Create a container

sudo docker run -t -d -p 60000:22  -p 60001:5901 -p 60002:5902 -p 60003:5903 a1765e8e381e  /bin/sh -c "while true; do echo hello world; sleep 1; done"

-t tells docker to assign a pseudo terminal and bind it to the standard input of the container, -p specifies the mapping port, for example, port 60001 of the host machine is mapped to port 5901 of the virtual machine, -d keeps running in the background, -c executes some commands

Insert picture description here

View container

sudo docker ps

Insert picture description here

Kali Linux

System environment

Modify root password

# 进入 kalilinux 容器
sudo docker exec -it 1275cabd2cdc /bin/bash
# 修改 root 用户密码
passwd root

Modify the mirror source

# 阿里云镜像源
vi /etc/apt/sources.list

deb http://mirrors.aliyun.com/kali kali-rolling main non-free contrib
deb-src http://mirrors.aliyun.com/kali kali-rolling main non-free contrib

SSH service

# 更新系统
apt-get update && apt-get upgrade
# 安装所需软件
apt-get install vim net-tools openssh-server 
# 修改 vim 配置文件,允许 root 用户远程登录
vim /etc/ssh/sshd_config

Add PermitRootLogin yes under #PermitRootLogin prohibit-password
Insert picture description here

#启动 ssh 服务
service ssh start
#允许开机自启动
systemctl enable ssh

Remote Desktop

# 安装 xfce4 桌面环境
apt-get install kali-defaults kali-root-login desktop-base xfce4 xfce4-places-plugin xfce4-goodies
# 安装 vnc4server
apt-get install vnc4server
#启动 vncserver
vncserver :1 -localhost no -geometry 1928x1080

Insert picture description here

test

SSH

Insert picture description here

VNC

Insert picture description here
Insert picture description here

Troubleshooting

The host cannot access Kali remote desktop, or only Kali can access it locally

1. Host Telnet tests the open ports of the Kali virtual machine vncserver service

telnet 172.17.0.2 5902

Insert picture description here
2. Enter the virtual machine to check the port opening

netstat -an |grep 5902

Insert picture description here
3. Find the problem

The -localhost no parameter is not added when opening the vnc service, which causes the vnc service to only listen to port 5902 of the local machine

other

  1. Kali officially gave the Docker version, which is basically an empty system. You can run apt-get install kali-linux-all to install all the tools of kali, and the size is about 10G.
  2. After configuring Kali, it is recommended to commit the container, so that when the Kali system crashes due to configuration errors in the future, you can quickly rebuild the container with the submitted image.

reference

Guess you like

Origin blog.csdn.net/geeksoarsky/article/details/103485390