
live-build environment and how to create your own Kali ISO images. Also in this chapter we talked about the preparation of bootable flash media with support for permanent storage of information that can be either encrypted or unencrypted. Now we will systematize the main provisions of this chapter and offer you a set of exercises.make install ), then such installation will contaminate the file system with files unknown to dpkg , which will soon lead to problems that cannot be detected based on packet dependency analysis. In addition, with this approach to modifying packages, what happened is more difficult to share with other users.apt source source-package-name . To succeed, you need to add the line deb-src to the /etc/apt/sources.list file and update the index files with the apt update command.dge t command (from the devscripts package) to directly download the .dsc file and related materials. In the case of packages prepared specifically for Kali, the source code of which is stored in the Git repository at git.kali.org , you can download the source code using a command like git clone git://git.kali.org/packages/source-package (if after executing such a command nothing is loaded, try switching to the kali/master branch with the git checkout kali/master command git checkout kali/master ).apt build-dep ./ command. It must be run from the package directory where the source code is located.dch --local version-identifier or by modifying other information about the package using the dch utility.patch -p1 < patch-file command or modifying a quilt patch series.debian/rules file or in other files from the debian/ directory.dpkg-buildpackage -us -uc -b , which is called from the source directory. This command will create an unsigned binary package. The resulting package can then be installed using this command: dpkg -i package-name_version_arch.deb .apt install build-essential libncurses5-dev fakeroot .apt-cache search ^linux-source command should list the latest kernel versions created by the Kali support team. A command like apt install linux-source-version-number installs a compressed archive with kernel source code in /usr/src .tar -xaf in a directory other than /usr/src (for example, in ~kernel )./boot/config-version-string to ~/kernel/linux-source-version-number/.config . Alternatively, you can use the command make architecture_defconfig command to build the appropriate configuration for your architecture.make menuconfig , reads the .config file and allows you to configure the kernel using the extensive menu system. When you select an item, the documentation on it and a list of possible values are displayed, and you can immediately enter a new value for it.make clean from the directory with the source code of the kernel, this will delete the previously compiled files. The make deb-pkg command will create up to five Debian packages. A file whose name looks like linux-image-version.deb contains a kernel image and related modules.dpkg -i file.deb . You can’t do without the linux-image package. The “linux-headers” package needs to be installed only if there are external kernel modules for building, which happens if you have installed * -dkms-packages (you can check if this is the case with the dpkg -l "*-dkms" | grep ^ii command dpkg -l "*-dkms" | grep ^ii ). Other packages, in most cases, are not used.live-build scripts, which allows you to fully automate the work and customize all aspects of creating ISO images.live-build you need the system to be updated to the latest version.apt install curl git live-build , followed by the git clone git://git.kali.org/live-build-config.git ../build.sh --verbose command. The assembly will take a lot of time, since during the execution of this operation all the necessary packages will be loaded. After the build is complete, a new ISO image will be found in the images directory. If you use the option --variant variant when executing this command, the specified version of the image will be assembled. Different variants are defined by their configuration directories, whose names look like config/variant-* . The main image is created using the gnome variant.live-build configuration directory:package-lists/*.list.chroot .packages.chroot directory. Their installation can be automated using preseed/*.cfg files.includes.chroot folder.chroot you can run scripts by installing them as hooks/live/*.chroot files. In addition, scripts can be invoked at boot time using the created Live image. They need to be installed to an address that looks like /usr/lib/live/config/XXXX-name , for example, based on the includes.chroot configuration directory.live-build , you can use the excellent Debian Live System Manual tutorial.kali-meta package. apt-get install devscripts # dch nano /etc/apt/sources.list # : deb-src http://http.kali.org/kali kali-rolling main non-free contrib apt-get update apt source kali-meta # kali-linux-*. cd kali-meta-2017.2.0/ ls -l nano debian/control Package: kali-linux-muts Architecture: any Depends: ${misc:Depends}, kali-linux, aircrack-ng, nmap, sqlmap, Description: Kali Linux Custom tools for muts This is Kali Linux, the most advanced penetration testing and security auditing distribution. . This metapackage depends on few of muts' favorites. root@kali:~/kali-meta-2017.2.0# head -1 debian/changelog root@kali:~/kali-meta-2017.2.0# dch --local muts -m "Added a new metapackage" root@kali:~/kali-meta-2017.2.0# head -1 debian/changelog # , root@kali:~/kali-meta-2017.2.0# dpkg-buildpackage -us -uc -b # Disable signatures (-us -uc), binary-only build (-b) root@kali:~/kali-meta-2017.2.0# ls -l ../*muts* -rw-r--r-- 1 root root 6804 Aug 28 13:42 gqrx_2017.2.0muts1_all.deb -rw-r--r-- 1 root root 6948 Aug 28 13:42 kali-desktop-common_2017.2.0muts1_all.deb -rw-r--r-- 1 root root 6972 Aug 28 13:42 kali-desktop-gnome_2017.2.0muts1_all.deb -rw-r--r-- 1 root root 6796 Aug 28 13:42 kali-desktop-kde_2017.2.0muts1_all.deb -rw-r--r-- 1 root root 6920 Aug 28 13:42 kali-desktop-live_2017.2.0muts1_all.deb -rw-r--r-- 1 root root 6812 Aug 28 13:42 kali-desktop-lxde_2017.2.0muts1_all.deb -rw-r--r-- 1 root root 6868 Aug 28 13:42 kali-desktop-xfce_2017.2.0muts1_all.deb -rw-r--r-- 1 root root 7068 Aug 28 13:42 kali-linux_2017.2.0muts1_amd64.deb -rw-r--r-- 1 root root 7062 Aug 28 13:42 kali-linux-all_2017.2.0muts1_amd64.deb -rw-r--r-- 1 root root 7290 Aug 28 13:42 kali-linux-forensic_2017.2.0muts1_amd64.deb -rw-r--r-- 1 root root 8732 Aug 28 13:42 kali-linux-full_2017.2.0muts1_amd64.deb -rw-r--r-- 1 root root 6850 Aug 28 13:42 kali-linux-gpu_2017.2.0muts1_amd64.deb -rw-r--r-- 1 root root 6844 Aug 28 13:42 kali-linux-muts_2017.2.0muts1_amd64.deb -rw-r--r-- 1 root root 7298 Aug 28 13:42 kali-linux-nethunter_2017.2.0muts1_amd64.deb -rw-r--r-- 1 root root 7088 Aug 28 13:42 kali-linux-pwtools_2017.2.0muts1_amd64.deb -rw-r--r-- 1 root root 6864 Aug 28 13:42 kali-linux-rfid_2017.2.0muts1_amd64.deb -rw-r--r-- 1 root root 6908 Aug 28 13:42 kali-linux-sdr_2017.2.0muts1_amd64.deb -rw-r--r-- 1 root root 6924 Aug 28 13:42 kali-linux-top10_2017.2.0muts1_amd64.deb -rw-r--r-- 1 root root 6942 Aug 28 13:42 kali-linux-voip_2017.2.0muts1_amd64.deb -rw-r--r-- 1 root root 7360 Aug 28 13:42 kali-linux-web_2017.2.0muts1_amd64.deb -rw-r--r-- 1 root root 7058 Aug 28 13:42 kali-linux-wireless_2017.2.0muts1_amd64.deb -rw-r--r-- 1 root root 10312 Aug 28 13:42 kali-meta_2017.2.0muts1_amd64.buildinfo -rw-r--r-- 1 root root 8343 Aug 28 13:42 kali-meta_2017.2.0muts1_amd64.changes root@kali:~/kali-meta-2017.2.0# ls -l ../kali-linux-muts_2017.2.0muts1_amd64.deb -rw-r--r-- 1 root root 6852 Aug 28 14:05 ../kali-linux-muts_2017.2.0muts1_amd64.deb aircrack-ng package be updated using the same approach? apt source set wget https://github.com/trustedsec/social-engineer-toolkit/archive/master.tar.gz -O set_7.7.1.orig.tar.gz tar xvf set_7.7.1.orig.tar.gz mv social-engineer-toolkit-master social-engineer-toolkit-7.7.1 cp -a set-7.7/debian social-engineer-toolkit-7.7.1/debian rm -rf social-engineer-toolkit-7.7.1/.git cd social-engineer-toolkit-7.7.1 head -1 debian/changelog dch -v 7.7.1-0muts1 "New upstream release" head -1 debian/changelog dpkg-buildpackage -us -uc -b ls -l ../*muts* # dpkg -i ../set_7.7.1-0muts1_all.deb # aircrack-ng everything is done in a similar way: nano /etc/apt/sources.list apt-get update apt source aircrack-ng wget https://github.com/aircrack-ng/aircrack-ng/archive/master.tar.gz tar zxpf master.tar.gz mv aircrack-ng-master aircrack-ng-1.3 cp -rf aircrack-ng-1.2-0~rc4/debian/ aircrack-ng-1.3/ cd aircrack-ng-1.3/ head -1 debian/changelog dch -v 1:1.3 -m "Upstream update" nano debian/changelog dpkg-checkbuilddeps apt-get install libgcrypt-dev libgcrypt11-dev libnl-genl-3-dev libpcap0.8-dev libpcre3-dev libsqlite3-dev pkg-config zlib1g-dev dpkg-buildpackage -us -uc -b likwid and run a quick test likwid-bench .likwid , run the test: apt-get install likwid likwid-topology -g | head # likwid-bench -t copy -w S0:100kB:1 # socket 0 apt install build-essential libncurses5-dev fakeroot apt-cache search ^linux-source # linux-source package apt install linux-source-4.9 # ls /usr/src # which gets extracted to /usr/src mkdir ~/kernel; cd ~/kernel tar -xaf /usr/src/linux-source-4.9.tar.xz cp /boot/config-4.9.0-kali3-amd64 ~/kernel/linux-source-4.9/.config # Copy existing config menuconfig on unpatched kernel configuration: cd linux-source-4.9 make menuconfig Processor type and features ---> Processor family (Generic-x86-64) ---> cd ~/kernel wget https://raw.githubusercontent.com/graysky2/kernel_gcc_patch/master/enable_additional_cpu_optimizations_for_gcc_v4.9%2B_kernel_v3.15%2B.patch cd linux-source-4.9/ patch -p1 < ../enable_additional_cpu_optimizations_for_gcc_v4.9+_kernel_v3.15+.patch make menuconfig Processor type and features ---> Processor family (Generic-x86-64) ---> 
export CONCURRENCY_LEVEL=5 # CPU +1 make deb-pkg LOCALVERSION=-custom KDEB_PKGVERSION=$(make kernelversion)-1 likwid-topology -g | head # likwid-bench -t copy -w S0:100kB:1 # socket 0 
# ! apt-get update apt-get dist-upgrade # apt install -y git live-build cdebootstrap curl # Kali live build git clone git://git.kali.org/live-build-config.git # , cd live-build-config/ cat kali-config/variant-default/package-lists/kali.list.chroot echo cryptsetup > kali-config/variant-default/package-lists/kali.list.chroot echo openssh-server >> kali-config/variant-default/package-lists/kali.list.chroot echo nmap >> kali-config/variant-default/package-lists/kali.list.chroot # live- ( , ) mkdir -p kali-config/common/includes.chroot/lib/systemd/system/ # "Angela" /usr/bin/startssh cat << EOF > kali-config/common/includes.chroot/lib/systemd/system/angela.service [Unit] Description=Start Custom Script After=multi-user.target [Service] Type=idle ExecStart=/bin/bash /usr/bin/startssh [Install] WantedBy=multi-user.target EOF # /usr/bin ( ) Live- mkdir -p kali-config/common/includes.chroot/usr/bin/ # "startssh", cat << EOF > kali-config/common/includes.chroot/usr/bin/startssh #!/bin/sh echo hola > /root/test.txt EOF # , cat << EOF > kali-config/common/hooks/live/angela.chroot #!/bin/sh systemctl enable angela.service || true EOF # chmod 755 kali-config/common/hooks/live/angela.chroot # , , -, , cat << EOF > kali-config/common/includes.binary/isolinux/isolinux.cfg include menu.cfg default vesamenu.c32 prompt 0 timeout 20 ONTIMEOUT live-amd64 EOF # ISO! ./build.sh --verbose openssh-server and salt-minion .live-build uses the entire directory structure as input to its configuration. We store this configuration and some supporting scripts in the live-build-config Git repository. We will use this repository as a base for building specially customized images. Install the necessary packages and load the Git repository with the Kali live-build configuration: apt install curl git live-build git clone git://git.kali.org/live-build-config.git cd live-build-config salt-minion : echo salt-minion > kali-config/variant-default/package-lists/kali.list.chroot echo openssh-server >> kali-config/variant-default/package-lists/kali.list.chroot preseed.cfg : mkdir -p kali-config/common/includes.installer wget https://www.kali.org/dojo/preseed.cfg -O ./kali-config/common/includes.installer/preseed.cfg includes.binary . , install.cfg ( ): cat << EOF > kali-config/common/includes.binary/isolinux/install.cfg label install menu label ^Install linux /install/vmlinuz initrd /install/initrd.gz append vga=788 --quiet file=/preseed.cfg locale=en_US keymap=us hostname=kali domain=local.lan EOF isolinux.cfg : cat << EOF > kali-config/common/includes.binary/isolinux/isolinux.cfg include menu.cfg ui vesamenu.c32 default install prompt 0 timeout 5 EOF echo 'systemctl enable ssh' > kali-config/common/hooks/live/01-start-ssh.chroot ssh-keygen -f /root/.ssh/id_rsa -t rsa -N '' # , mkdir -p kali-config/common/includes.chroot/root/.ssh/ cat /root/.ssh/id_rsa.pub > kali-config/common/includes.chroot/root/.ssh/authorized_keys ./build.sh --verbose /dev/sdb , , ISO- ( /dev/sdb1 /dev/sdb2 ). , , , , .dmesg fdisk . , , /dev/sdb . - , . : umount /dev/sdb1 umount /dev/sdb2 parted /dev/sdb (parted) print Model: SanDisk Ultra USB 3.0 (scsi) Disk /dev/sdb: 124GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 32.8kB 2794MB 2794MB primary boot, hidden 2 2794MB 2794MB 721kB primary (parted) mkpart primary 2794 5000 (parted) mkpart primary 5000 100% (parted) quit Information: You may need to update /etc/fstab. mkpart primary 2794 5000 ( , ), 2794 , 5000 . , Kali 2794 . , , ISO- -.sdb3 . , persistence . , . , ! mkfs.ext3 /dev/sdb3 e2label /dev/sdb3 persistence persistence.conf , , . : mkdir -p /mnt/usb mount /dev/sdb3 /mnt/usb echo "/ union" > /mnt/usb/persistence.conf umount /mnt/usb cryptsetup , , , , persistence.conf , : cryptsetup --verbose --verify-passphrase luksFormat /dev/sdb4 cryptsetup luksOpen /dev/sdb4 my_usb mkfs.ext3 /dev/mapper/my_usb e2label /dev/mapper/my_usb persistence ls -l /dev/disk/by-label mkdir -p /mnt/my_usb mount /dev/mapper/my_usb /mnt/my_usb echo "/ union" > /mnt/my_usb/persistence.conf umount /dev/mapper/my_usb cryptsetup luksClose /dev/mapper/my_usb cryptsetup luksAddNuke /dev/sdb4 Source: https://habr.com/ru/post/342406/
All Articles