
Kali Linux VM 이미지 빌드 스크립트
Kali Linux 가상 머신(VM) 이미지 빌더, debos(와 fakemachine 및 KVM)를 통해.
이들은 Kali 팀이 kali.org/get-kali/에서 제공되는 공식 Kali Linux VM 이미지를 생성하는 데 사용하는 것과 동일한 build-scripts입니다.
더 많은 정보는 다음을 참조하세요: kali.org/docs/virtualization/.
지금 바로 당신의 Kali를 빌드하세요!
원하는 아키텍처와 일치하는 Linux 기반 호스트에서 빌드하는 것을 권장합니다.
kali-vm build-script를 사용할 준비를 하는 방법은 여러 가지가 있습니다. 다음 중 하나를 선택할 수 있습니다:
build.sh - 머신에서 직접 빌드build-in-container.sh - 컨테이너 내에서 빌드 (예: Docker 또는 Podman) 이 스크립트가 작동하려면 KVM이 필요합니다. 그러나 슈퍼 유저 권한은 필요하지 않습니다. BIOS/UEFI에서 KVM을 활성화하는 방법은 생략하겠습니다.
KVM이 필요한 이유는 빌드가 실제로 빌드 도구 debos에 의해 즉석에서 생성되는 가상 머신(VM) 내부에서 이루어지기 때문입니다. Debos는 내부적으로 fakemachine을 사용하며, 이는 다시 QEMU+KVM에 의존합니다.
먼저 git을 설치하고, 저장소가 로컬에 복제되었는지 확인하세요:```console
$ sudo apt-get install --no-install-recommends
git ca-certificates
$ git clone https://gitlab.com/kalilinux/build-scripts/kali-vm.git
$ cd ./kali-vm/
- - -
QEMU/KVM의 요구 사항으로 인해, `kvm` 그룹에 속해 있어야 합니다.
다음을 통해 확인할 수 있습니다:```console
$ # Not a part of the group
$ grep kvm /etc/group
kvm:x:104:
$
$ # In the group
$ grep kvm /etc/group
kvm:x:104:kali
$
If your username does not appear in the line returned (e.g. kali), it means that you are not in the group, and you must add yourself to the kvm group.
You can do that by doing:```console
$ sudo adduser $USER kvm
그런 다음 변경 사항이 적용되도록 **로그아웃한 후 다시 로그인**하세요. <!-- 터미널 앱을 닫았다가 다시 여는 것이 아니라, Xfce에서 로그아웃하는 것입니다! -->
...또는```console
$ newgrp kvm
build.sh를 사용하여 호스트에서 직접 빌드하려면, 빌드 의존성을 설치하세요:```console
$ sudo apt-get install --no-install-recommends
debos
linux-image-amd64
parted
dosfstools e2fsprogs
zerofree
7zip bmap-tools qemu-utils xz-utils
xkb-data
<!-- This should match what is in: [Dockerfile](https://gitlab.com/kalilinux/build-scripts/kali-vm/-/blob/main/Dockerfile) & [kali.org/docs/virtualization/](https://www.kali.org/docs/virtualization/)
Alt: $ sudo apt-get install 7zip debos dosfstools qemu-utils zerofree
xkb-data is optional, just helps to validate settings - doesn't take up that much space
-->
- - -
이제 `./build.sh`를 사용할 수 있으며, 이는 Kali VM 이미지를 여러분의 머신에서 바로 빌드합니다.
### 컨테이너 내부에서 빌드하기
_컨테이너 소프트웨어 설정은 건너뛰겠습니다._
컨테이너 내부에서 빌드하는 것을 선호한다면, 머신에 `docker` 또는 `podman` 중 하나를 설치하고 구성해야 합니다.
- `docker`는 사용자를 Docker 그룹에 추가하거나 root 계정을 사용해야 합니다 (예: `$ sudo ./build-in-container.sh`).
- `podman`은 rootful (예: `$ sudo ./build-in-container.sh`) 및 rootless (예: `$ ./build-in-container.sh`) 모두로 테스트되었습니다. rootless의 경우 추가로 `crun`이 필요합니다 (예: `$ sudo apt install crun`). 이는 `runc`가 사용자 네임스페이스에서 `/dev/kvm`에 접근할 수 없기 때문입니다.
- - -
`build-in-container.sh`는 `build.sh` 위에 있는 래퍼입니다. 이는 사용할 OCI 호환 컨테이너 엔진을 감지하고, [컨테이너 이미지](https://gitlab.com/kalilinux/build-scripts/kali-vm/-/blob/main/Dockerfile)가 없으면 생성한 다음, 컨테이너를 시작하여 내부에서 빌드를 수행합니다.
컨테이너 이미지를 제공하는 방법은 세 가지가 있습니다:```console
$ # Option #1 - Automated build (recommended)
$ ./build-in-container.sh
$ ./build-in-container.sh --force # If you need to rebuild the image from scratch
$
$
$
$ # Option #2 - Manual build
$ docker build -t kali-build/kali-vm .
$ # ...OR...
$ podman build -t kali-build/kali-vm .
$
$
$
$ # Option #3 - Use the pre-generated
$ docker pull registry.gitlab.com/kalilinux/build-scripts/kali-vm:latest
$ docker tag registry.gitlab.com/kalilinux/build-scripts/kali-vm:latest kali-build/kali-vm
$ # ...OR...
$ podman pull registry.gitlab.com/kalilinux/build-scripts/kali-vm:latest
$ podman tag registry.gitlab.com/kalilinux/build-scripts/kali-vm:latest kali-build/kali-vm
$
$ # ...then point the build at it:
$ ./build-in-container.sh # Locally built (automated or manual)
$ IMAGE=registry.gitlab.com/kalilinux/build-scripts/kali-vm:latest ./build-in-container.sh # Pre-generated
docker와 podman이 모두 설치되어 있는 경우, build-in-container.sh는 기본적으로 podman을 사용합니다. 이를 변경하려면 ./build-in-container.sh 앞에 CONTAINER=docker를 붙이세요:```console
$ CONTAINER=docker ./build-in-container.sh [...]
- - -
이제 이미지를 빌드하기 위해 `./build.sh` 대신 `./build-in-container.sh`를 사용할 수 있습니다.
## 도움말```console
$ ./build.sh --help
Usage: build.sh [OPTIONS] [-- <debos options>]
Build a Kali Linux VM image.
Build options:
-a, --arch ARCH Build an image for this architecture (default: amd64)
Supported: amd64
-b, --branch BRANCH Kali branch used to build the image (default: kali-rolling)
Supported: kali-rolling kali-dev kali-last-snapshot
-f, --format FORMAT Format to export the image to (default: ...depends on --variant)
Supported: hyperv ova ovf qemu raw vagrant virtualbox vmware
-k, --keep Keep intermediary build artifacts
-m, --mirror URL Mirror used to build the image (default: http://http.kali.org/kali)
-o, --output DIR Output directory (default: /home/kali/kali-vm/output)
-r, --rootfs ROOTFS Rootfs to use to build the image (default: none)
-v, --variant VARIANT Variant of image to build, see below for details (default: generic)
Supported: generic hyperv qemu rootfs virtualbox vmware
-x, --version VERSION What to name the image release as (default: rolling)
-z, --zip Compress image and metadata files after the build
-h, --help Show this help and exit
VM options:
-D, --desktop DESKTOP Desktop environment installed in the image (default: xfce)
Supported: xfce e17 gnome i3 kde lxde mate none
-H, --hostname HOSTNAME Set system host name (default: kali)
-K, --keyboard KEYBOARD Set keyboard layout (default: us)
See README.md for details
-L, --locale LOCALE Set locale (default: en_US.UTF-8)
-P, --packages PKGS Install extra packages (comma/space separated list)
-s, --size SIZE Size of the disk image in GB (default: 86)
-S, --swap SWAP Swap as a partition, a file, or none (default: file)
Supported: partition file none
-T, --toolset TOOLSET The selection of tools to include in the image (default: default)
Supported: default everything headless large none
-U, --userpass USERPASS Username and password, separated by a colon (default: kali:kali)
-Z, --timezone TIMEZONE Set timezone (default: America/New_York)
Use "same" as the value for -K/-L/-Z to inherit the host's current setting.
The different variants of images are:
generic Image with all virtualization support pre-installed, default format: raw
hyperv Image pre-configured for Hyper-V "Enhanced Session Mode", default format: hyperv
qemu Image with QEMU and SPICE guest agents pre-installed, default format: qemu
rootfs Not an image, a root filesystem (no bootloader/kernel), packed in a .tar.gz
virtualbox Image with VirtualBox guest utilities pre-installed, default format: virtualbox
vmware Image with Open VM Tools pre-installed, default format: vmware