Setting up Kali Linux for TFTP Netboot

Create a configuration file for dnsmasq in /etc/dnsmasq.conf with the following lines:

# Create a configuration file for dnsmasq in /etc/dnsmasq.conf with the following lines:

# Set the network interface for dnsmasq to use
interface=eth0

# Set the DHCP range and lease duration for virtual machines
dhcp-range=192.168.1.100,192.168.1.200,12h

# Set the boot file for PXE boot
dhcp-boot=pxelinux.0

# Enable TFTP support
enable-tftp

# Set the directory where Netboot images will be stored
tftp-root=/tftpboot/

# Set the default gateway for virtual machines to be the router's IP address
dhcp-option=3,$(ip -4 route show dev eth0 | grep -oP '(?<=default\svia\s)(\d+(\.\d+){3})')

# Add Google DNS servers as a backup in case primary DNS server is unavailable
dhcp-option=6,8.8.8.8,8.8.4.4

Save and close the file (press Ctrl+X followed by Y then Enter). 3. Restart dnsmasq with `sudo systemctl restart dnsmasq`. 4. Create a new virtual machine in VirtualBox and configure it to use PXE boot by setting Network Adapters > Attached to: > Bridged Adapter, checking “Promiscuous Mode” under Advanced > Ports & USB, and starting the VM. 5. Your custom Netboot image should now be accessible via TFTP! If everything went smoothly, you can access the Kali Linux command line interface by pressing Enter at the PXE boot menu. g. eth0) and .100,.200 with your desired IP range in /etc/dnsmasq.conf.

To add additional persistence stores to the USB drive, both encrypted or not:
1. Create a new partition for the additional store using `parted` command. For example, let’s create an additional 5GB non-encrypted store labeled “work”:

#!/bin/bash

# This script is used to create an additional persistence store on a USB drive, either encrypted or not.

# First, we need to identify the USB drive and its partitions using the `parted` command.
# We will use the `print` option to display the current partition table of the USB drive.
# Replace "sdX" with the appropriate drive letter.
sudo parted /dev/sdX print

# The output will show the model, size, and partition table of the USB drive.
# We need to create a new partition for the additional store, using the `mkpart` option.
# We will specify the type as "primary" and the start and end points for the partition.
# In this example, we will create a 5GB non-encrypted store labeled "work" starting at 10000MB and ending at 15000MB.
sudo parted /dev/sdX mkpart primary 10000 15000

# After creating the partition, we can verify it by using the `print` option again.
# The new partition should now be listed with the appropriate size and type.
sudo parted /dev/sdX print

# Now we can use this new partition as an additional persistence store on the USB drive.

2. Format the new partition using `mkfs.ext4` command:


# This script is used to format a new partition using the mkfs.ext4 command.
# It takes in the device name as an argument.

# Check if the user has root privileges.
if [[ $EUID -ne 0 ]]; then
  echo "This script must be run as root." 
  exit 1
fi

# Check if the device name is provided as an argument.
if [ $# -eq 0 ]; then
  echo "Please provide the device name as an argument."
  exit 1
fi

# Format the new partition using the mkfs.ext4 command.
sudo mkfs.ext4 "$1"

# The "$1" represents the first argument passed to the script, which is the device name.
# The sudo command is used to run the mkfs.ext4 command with root privileges.
# This ensures that the command is executed successfully without any permission issues.

3. Label the new partition with “work” using `e2label` command:

# This script is used to label a new partition with "work" using the e2label command.
# It requires sudo privileges to run.

# First, we need to specify the device name of the partition we want to label.
# In this case, it is /dev/sdX4, but it may vary depending on the system.
# We will store this value in a variable called "device".
device="/dev/sdX4"

# Next, we use the e2label command to label the partition with "work".
# We also need to use sudo to run this command with root privileges.

# In this case, we will use the variable "device" to specify the device name.
# The label "work" will be added as the second argument.
sudo e2label "$device" work

# Finally, we can check if the partition has been successfully labeled by using the "lsblk" command.
# This command lists all block devices and their labels.
# We can use the "-f" flag to display the filesystem type and label.
# The output should show the device name, filesystem type, and label "work" for the partition we just labeled.
lsblk -f

4. Mount the new partition and create a persistence.conf file in it:

# Create a directory named "usb" in the /mnt directory with root privileges
sudo mkdir -p /mnt/usb
# Mount the fourth partition of the device "sdX" to the "usb" directory
sudo mount /dev/sdX4 /mnt/usb
# Create a file named "persistence.conf" in the "usb" directory with the content "/ union"
echo "/ union" > /mnt/usb/persistence.conf
# Unmount the "usb" directory
sudo umount /mnt/usb

5. To configure a nuke password for added security, install the `cryptsetup-nuke-password` package using `sudo apt install -y cryptsetup-nuke-password`. Then run `sudo dpkg-reconfigure cryptsetup-nuke-password` to set up the nuke password.

SICORPS