Customizing Kali Linux Live ISO Images with Preseed Files and PXE Booting

For example, `custom-kali`
2. Download the latest version of Kali Linux from their website (https://www.kali.org/downloads/) and extract it to the newly created directory using the following command:

# This script is used to download and extract the latest version of Kali Linux from their website.

# Create a new directory for the Kali Linux download
mkdir custom-kali

# Change directory to the newly created directory
cd custom-kali

# Download the latest version of Kali Linux from their website
wget https://www.kali.org/downloads/kali-linux-*.tar.gz

# Extract the downloaded file using the tar command
tar -xzf kali-linux-*.tar.gz

# The tar command is used to extract files from a tar archive. The -x flag specifies that we want to extract files, the -z flag indicates that the archive is compressed with gzip, and the -f flag specifies the name of the archive file to be extracted.

# The * wildcard is used to match any characters in the file name, allowing us to extract the latest version of Kali Linux without knowing the exact file name.

# After the extraction is complete, we will have a directory named "kali-linux" containing all the necessary files for Kali Linux.

3. Copy your preseed file into the `preseed` folder inside the extracted Kali Linux ISO image (e.g., `custom-kali/pool/system/debian/preseed`) and rename it to `preseed.cfg`. For example, if you want to customize the hostname during installation:

#!/bin/bash

# This script is used to customize the preseed file for Kali Linux installation.

# Set the locale to en_US.UTF-8
d-i debian-installer/locale string en_US.UTF-8

# Set the country to US
d-i debian-installer/country select US

# Set the timezone to America/Los_Angeles
d-i debian-installer/timezone select America/Los_Angeles

# Set the clock skew to -100
d-i debian-installer/clockskew integer -100

# Set the network configuration method to manual
d-i debian-installer/network/method string manual

# Set the hostname to mycustomhost
d-i netcfg/get_hostname string mycustomhost

4. To enable PXE booting, you need to configure your DHCP server and TFTP server. For example:
1. Configure the DHCP server (e.g., `dhcpd.conf`) with the following options:

# This script is used to configure the DHCP server (e.g., `dhcpd.conf`) for PXE booting.

# Set the subnet and netmask for the DHCP server.
subnet 192.168.0.0 netmask 255.255.255.0 {
    # Set the range of IP addresses that can be assigned to clients.
    range 192.168.0.100 192.168.0.200;
    # Set the subnet mask for the clients.
    option subnet-mask 255.255.255.0;
    # Set the broadcast address for the clients.
    option broadcast-address 192.168.0.255;
    # Set the default gateway for the clients.
    option routers 192.168.0.1;
    # Set the filename for the PXE boot image.
    filename "pxelinux.cfg/kali"; # change this to match your custom ISO image name
}

2. Configure the TFTP server (e.g., `tftpd.conf`) with the following options:

# tftpd.conf
# This is the configuration file for the TFTP server.

# Enable the TFTP server.
enable

# Set the user and group for the TFTP server to run as.
user nobody
group nogroup

# Set the file permissions for files transferred through TFTP.
# The default is 0664, which allows read and write access for the owner and group, and read-only access for others.
mode 0664

# Set the root directory for the TFTP server.
# This is the directory where files will be transferred to and from.
chroot-directory /var/lib/tftpboot

# Deny access to all users except for root.
denyuser *
allowuser root

# Deny access to all groups except for root.
denygroup *
allowgroup root

3. Copy your custom ISO image to the `kali` folder inside the TFTP server directory (e.g., `/var/lib/tftpboot`) and rename it to match the filename option in DHCP configuration:

# This script copies a custom ISO image to the TFTP server directory for use in DHCP configuration.

# Copy the custom ISO image to the TFTP server directory and rename it to match the filename option in DHCP configuration.
# The custom ISO image is renamed to "kali-linux-*.iso" to match the filename option in DHCP configuration.
scp custom-kali.iso [email protected]:/var/lib/tftpboot/kali/kali-linux-*.iso

5. Reboot your PXE server and test the configuration by booting a client machine with PXE enabled (e.g., F12 on Dell laptops). If everything is working correctly, you should see the Kali Linux installation menu:
! [Kali Linux Installation Menu](https://i.imgur.com/zJcQZ7k.png)
6. Follow the prompts to complete the installation and customize your new system according to your preferences.

Note that this is just a basic guide, and there are many more options available for customizing Kali Linux Live ISO images with preseed files and PXE booting. For more information, refer to the official documentation: https://www.kali.org/docs/installation/pxe-netbooting/.

SICORPS