live-buid
uses, when forming its configuration, the directory structure. This configuration and some related helper scripts can be found in the live-build-config
Git repository. We will use this repository as a basis for building images that are configured in accordance with special requirements.live-build
configuration: # apt install curl git live-build [...] # git clone git://git.kali.org/live-build-config.git [...] # cd live-build-config # ls auto build_all.sh build.sh kali-config README
./build.sh --verbose
. The assembly will take a lot of time, because in its course all the packages that need to be included in the image will be loaded. After completing this process, you can find a new ISO image in the images
directory.build.sh
script from the live-build
kit is responsible for preparing the config
directory. Her presence is expected to live-build
. The script helps to set different configurations, depending on its option --variant
.config
directory by combining files from kali-config/common
and kali-config/variant-X
, where X —
the name of the variant specified using the --variant
parameter. When this option is not specified explicitly, the default
name is used as a variant name.kali-config
folder contains directories for the most popular desktop environments:e17
for Enlightenment;gnome
for GNOME;i3wm
for frame window manager i3;kde
for KDE;lxde
for LXDE;mate
for Mate Desktop Environment;xfce
for XFCE.light
option is a special case. It is based on XFCE and is used to create an official lightweight ISO image that contains a reduced set of applications. # ./build.sh --variant kde --verbose
kali-config
. Below we look at a few examples.Live-build
, after launch, installs all the packages listed in the package-lists/*.list.chroot
. The standard configuration includes the package-lists/kali.list.chroot
, which contains an entry for the kali-linux-full
package (this is the basic meta package, which results in the inclusion of all Kali packages in the image). The line with the mention of this package can be commented out and use another meta package or make your own list of other packages. In addition, you can combine both approaches, starting with a meta package and adding additional necessary packages.package-lists
, only those packages that are already available in the official Kali repository can be included in the image. However, if you have your own packages, you can include them in the Live image by placing the corresponding .deb files in the packages.chroot
directory (for example, in kali-config/config-gnome/packages.chroot
, if you, when building, use the GNOME graphical environment option).kali-meta
source package is responsible for building all the meta packages provided by Kali Linux:kali-linux
: the base system (it is used in all other meta packages).kali-linux-full
: standard installation of Kali Linux.kali-linux-all
: a meta package that combines all other meta packages, as well as other packages (here, almost everything that is in Kali, so it's just a huge package!).kali-linux-sdr
: Software Defined Radio (SDR) tools.kali-linux-gpu
: tools that use a graphics card (GPU) to perform heavy calculations.kali-linux-wireless
: tools for research and analysis of wireless networks.kali-linux-web
: tools for researching web applications.kali-linux-forensic
: digital kali-linux-forensic
tools (they are used to search for evidence in investigating various incidents).kali-linux-voip
: VoIP (Voice Over IP) tools.kali-linux-pwtools
: password cracking tools.kali-linux-top10
: the ten most popular tools.kali-linux-rfid
: tools for working with RFID.live-build
. A complete list of the available meta packages and the software they include can be found here .â–ŤAutomation of customization of installed packages
To automate the configuration of installed packages, you can use Debconf answer files (for more information, see section 4.3.2., “ Creating an Answer File ”), placing them inpreseed/*.cfg
. They will be used to customize the packages used to create the live image.
live-build
, you can use hooks that are performed at various stages of the build process. chroot —
hooks/live/*.chroot
are executable scripts that are installed as hooks/live/*.chroot
in the configuration tree and are executed using chroot
. While chroot —
a command that allows you to temporarily change the root directory of an operating system to a selected directory, it is also used by live-build
to designate a directory containing the full (alternative) tree of the file system. In the case of live-build
, the chroot directory is the directory where the file system is prepared for the live image. Since applications running using chroot
do not have access beyond the selected directory, the same is true for chroot hooks: you can only use and modify what is available in the chroot
environment. We rely on these hooks to perform many Kali-specific settings (take a look at kali-config/common/hooks/live/kali-hacks.chroot
).hooks/live/*.binary
Binary) are executed in the context of the build process, at the end of this process. They are not called during assembly using chroot
. With their help, you can modify the contents of the assembly ISO image, but not the Live-file system, since at this point it has already been created. We use this feature in Kali to make some changes to the standard isolinux
configuration created by live-build
. For example, take a look at config/common/hooks/live/persistence.binary
, where we add boot menu items to enable the persistent data store.includes.chroot
configuration directory. For example, there is a standard file kali-config/common/includes.chroot/usr/lib/live/config/0031-root-password
, which ultimately turns out to be located in the Live-file system at /usr/lib/live/config/0031-root-password
.â–ŤHooks live-boot
The scripts installed in/lib/live/config/XXXX-name
are executed by theinit
script of thelive-boot
package. They reconfigure many aspects of the system so that they are suitable for working in live mode. Here you can add your own scripts to customize your Live-system during operation. In particular, they are used, for example, to implement their own boot parameters.
includes.binary
configuration directory where they should be. For example, there is a standard kali-config/common/includes.binary/isolinux/splash.png
that overrides the background image used by the isolinux
bootloader (it is stored in the /isolinux/splash.png
file in the ISO image file system).live-boot
feature, called persistence. This feature is activated if the boot options include the persistence
keyword.Live USB Persistence
and Live USB Encrypted Persistence
.live-boot
scan all partitions for file systems marked as persistence
(this can be changed using the persistence-label=value
boot parameter), and the installer will create a repository for the directories that are listed in the persistence.conf
file found in this section (each directory is listed on a separate line). The special option / union
allows you to enable full preservation of all directories using cascade-unified mount (union mount). With this approach, an additional file system level is created, in which only changes made to the data of the underlying file system are saved. Directory data that is not lost after a reboot is stored in the file system, which contains the corresponding persistence.conf
file./dev/sdb
, and that it contains only two partitions that are part of the standard ISO image ( /dev/sdb1
and /dev/sdb2
). Doing what is discussed below, be very careful. The fact is that if you accidentally re-partition the wrong disk, this can result in the loss of important data.parted
command to create the partition. The following commands analyze the kali-linux-2016.1-amd64.iso
ISO image, which is expected to be present on a USB flash drive: # parted /dev/sdb print Model: SanDisk Cruzer Edge (scsi) Disk /dev/sdb: 32,0GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 32,8kB 2852MB 2852MB primary boot, hidden 2 2852MB 2945MB 93,4MB primary # start=$(du --block-size=1MB kali-linux-2016.1-amd64.iso | awk '{print $1}') # echo "Size of image is $start MB" Size of image is 2946 MB # parted -a optimal /dev/sdb mkpart primary "${start}MB" 100% Information: You may need to update /etc/fstab. # parted /dev/sdb print Model: SanDisk Cruzer Edge (scsi) Disk /dev/sdb: 32,0GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 32,8kB 2852MB 2852MB primary boot, hidden 2 2852MB 2945MB 93,4MB primary 3 2946MB 32,0GB 29,1GB primary
/dev/sdb3
created, format it in the ext4
file system and assign the persistence
label to it using the mkfs.ext4
(and its -L
options to assign a label). Then the partition is mounted in the /mnt
directory and the persistence.conf
file is added there. Be careful when formatting any disk. If you format the wrong partition or the wrong drive, you may lose something important. # mkfs.ext4 -L persistence /dev/sdb3 mke2fs 1.43-WIP (15-Mar-2016) Creating filesystem with 7096832 4k blocks and 1777664 inodes Filesystem UUID: dede20c4-5239-479a-b115-96561ac857b6 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done # mount /dev/sdb3 /mnt # echo "/ union" >/mnt/persistence.conf # ls -l /mnt total 20 drwx------ 2 root root 16384 May 10 13:31 lost+found -rw-r--r-- 1 root root 8 May 10 13:34 persistence.conf # umount /mnt
Live USB Persistence
menu item.live-boot
. This approach allows you to protect data by creating an encrypted LUKS partition, on which they are stored.ext4
file system, use cryptsetup
to initialize the partition as a LUKS container. Then open this container and configure the ext4
file system as you did when creating unencrypted storage, but instead of using the /dev/sdb3
partition, use the virtual partition created by cryptsetup
. This virtual partition is the decrypted content of the encrypted partition, which is available in /dev/mapper
under the name you assigned to it. In the example below, we will use the name kali_persistence
. Recall that when performing such operations, it is worth being vigilant and not accidentally formatting the wrong disk or partition. # cryptsetup --verbose --verify-passphrase luksFormat /dev/sdb3 WARNING! ======== This will overwrite data on /dev/sdb3 irrevocably. Are you sure? (Type uppercase yes): YES Enter passphrase: Verify passphrase: Command successful. # cryptsetup luksOpen /dev/sdb3 kali_persistence Enter passphrase for /dev/sdb3: # mkfs.ext4 -L persistence /dev/mapper/kali_persistence mke2fs 1.43-WIP (15-Mar-2016) Creating filesystem with 7096320 4k blocks and 1774192 inodes Filesystem UUID: 287892c1-00bb-43cb-b513-81cc9e6fa72b Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done # mount /dev/mapper/kali_persistence /mnt # echo "/ union" >/mnt/persistence.conf # umount /mnt # cryptsetup luksClose /dev/mapper/kali_persistence
persistence-label=label
.kali-config/common/hooks/live/persistence-menu.binary
, bringing it to something like this (pay attention to the persistence-label
parameters): #!/bin/sh if [ ! -d isolinux ]; then cd binary fi cat >>isolinux/live.cfg <<END label live-demo menu label ^Live USB with Demo Data linux /live/vmlinuz initrd /live/initrd.img append boot=live username=root hostname=kali persistence-label=demo persistence label live-work menu label ^Live USB with Work Data linux /live/vmlinuz initrd /live/initrd.img append boot=live username=root hostname=kali persistence-label=work persistence-encryption=luks persistence END
demo
, was created without encryption, the second, labeled work
, is encrypted. Here, based on the assumption that the USB disk is visible in the system as /dev/sdb
, and the size of our ISO image is 3000 MB, you need to perform the following sequence of actions: # parted /dev/sdb mkpart primary 3000 MB 55% # parted /dev/sdb mkpart primary 55% 100% # mkfs.ext4 -L demo /dev/sdb3 [...] # mount /dev/sdb3 /mnt # echo "/ union" >/mnt/persistence.conf # umount /mnt # cryptsetup --verbose --verify-passphrase luksFormat /dev/sdb4 [...] # cryptsetup luksOpen /dev/sdb4 kali_persistence [...] # mkfs.ext4 -L work /dev/mapper/kali_persistence [...] # mount /dev/mapper/kali_persistence /mnt # echo "/ union" >/mnt/persistence.conf # umount /mnt # cryptsetup luksClose /dev/mapper/kali_persistence
â–ŤSetting self-destruct password to enhance system security
Kali has a modifiedcryptsetup
to implement a new feature. , (nuke password), , , , .
, . , ( ) .
, .
, , , :
$ cryptsetup luksAddNuke /dev/sdb4 Enter any existing passphrase: Enter new passphrase for key slot: Verify passphrase:
.
Source: https://habr.com/ru/post/341882/
All Articles