From 2a549aa31a5b8a71bcc8c610777e11d11cec4daf Mon Sep 17 00:00:00 2001 From: g0t mi1k <have.you.g0tmi1k@gmail.com> Date: Sun, 19 Jan 2025 15:39:19 +0000 Subject: [PATCH 01/15] Split simple-cdd/debian-cd & live-build ## Live `--live` = kali-live (previouly live-build-config) <https://gitlab.com/kalilinux/build-scripts/kali-live> Uses live-build ## Installer `--installer` = kali-installer <https://gitlab.com/kalilinux/build-scripts/kali-installer> Uses simple-cdd (which is a wrapper for debian-cd) --- .getopt.sh | 4 +- .gitignore | 6 - README.md | 82 +++++++- build.sh | 185 ++---------------- build_all.sh | 1 - .../common/bootloaders/grub-pc/grub-theme.in | 95 --------- .../includes.installer/kali-finish-install | 2 +- kali-config/installer-default/packages | 23 --- kali-config/installer-everything/packages | 17 -- kali-config/installer-netinst/packages | 9 - kali-config/installer-purple/packages | 21 -- simple-cdd/disc-end-hook | 68 ------- simple-cdd/local_packages/.empty | 0 simple-cdd/profiles/default.downloads | 1 - simple-cdd/profiles/default.excludes | 1 - simple-cdd/profiles/default.packages | 1 - simple-cdd/profiles/default.preseed | 3 - simple-cdd/profiles/default.udebs | 1 - simple-cdd/profiles/kali-purple.postinst | 45 ----- simple-cdd/profiles/kali.postinst | 1 - simple-cdd/profiles/kali.preseed | 1 - simple-cdd/profiles/offline.downloads | 18 -- simple-cdd/profiles/offline.preseed | 3 - simple-cdd/simple-cdd.conf | 118 ----------- 24 files changed, 102 insertions(+), 604 deletions(-) delete mode 120000 build_all.sh delete mode 100644 kali-config/common/bootloaders/grub-pc/grub-theme.in delete mode 100644 kali-config/installer-default/packages delete mode 100644 kali-config/installer-everything/packages delete mode 100644 kali-config/installer-netinst/packages delete mode 100644 kali-config/installer-purple/packages delete mode 100755 simple-cdd/disc-end-hook delete mode 100644 simple-cdd/local_packages/.empty delete mode 120000 simple-cdd/profiles/default.downloads delete mode 120000 simple-cdd/profiles/default.excludes delete mode 100644 simple-cdd/profiles/default.packages delete mode 100644 simple-cdd/profiles/default.preseed delete mode 100644 simple-cdd/profiles/default.udebs delete mode 100755 simple-cdd/profiles/kali-purple.postinst delete mode 120000 simple-cdd/profiles/kali.postinst delete mode 120000 simple-cdd/profiles/kali.preseed delete mode 100644 simple-cdd/profiles/offline.downloads delete mode 100644 simple-cdd/profiles/offline.preseed delete mode 100644 simple-cdd/simple-cdd.conf diff --git a/.getopt.sh b/.getopt.sh index 96eedc6..6ef11f7 100644 --- a/.getopt.sh +++ b/.getopt.sh @@ -6,8 +6,6 @@ # -D | --debug # -s | --salt # -h | --help -# --installer -# --live # --variant <variant> # --version <version> # --subdir <directory-name> @@ -16,4 +14,4 @@ # --clean BUILD_OPTS_SHORT="d:pa:vDsh" -BUILD_OPTS_LONG="distribution:,proposed-updates,arch:,verbose,debug,salt,installer,live,variant:,version:,subdir:,get-image-path,no-clean,clean,help" +BUILD_OPTS_LONG="distribution:,proposed-updates,arch:,verbose,debug,salt,variant:,version:,subdir:,get-image-path,no-clean,clean,help" diff --git a/.gitignore b/.gitignore index 94591ef..d93d35c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,8 +7,6 @@ chroot/* config/* images local/* -simple-cdd/images/* -simple-cdd/tmp/* # Files .mirror @@ -27,10 +25,6 @@ live-image-*.hybrid.iso.zsync live-image-*.packages wget-log* -# Overwritten due to build.sh -simple-cdd/debian-cd/* -simple-cdd/profiles/kali.downloads - # Miscellaneous .lock .stage diff --git a/README.md b/README.md index 9cf42dc..45e2e51 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,83 @@ -# live-build configuration for Kali ISO images +# Kali-Live Build-Scripts + +_`live-build` configuration for Kali ISO images._ + +These are the same [build-scripts](https://gitlab.com/kalilinux/build-scripts) that the [Kali team](https://www.kali.org/) uses to generate the official Kali Linux base images, found here: [kali.org/get-kali/](https://www.kali.org/get-kali/). + +_Build your Kali Linux image today!_ + +- - - + +These images can be used to live boot into Kali, from such a USB/CD/DVD/sdCard, as well offers a basic installation. For more customization during setup, see [kali-installer](https://gitlab.com/kalilinux/build-scripts/kali-installer). + +- [kali-installer](https://gitlab.com/kalilinux/build-scripts/kali-installer) uses [Simple-CDD](https://wiki.debian.org/Simple-CDD) _(which is a wrapper for [debian-cd](https://wiki.debian.org/debian-cd))_ +- [kali-live](https://gitlab.com/kalilinux/build-scripts/kali-live) uses [live-build](https://live-team.pages.debian.net/live-manual/html/live-manual/index.en.html) + +- - - Have a look at [Live Build a Custom Kali ISO](https://www.kali.org/docs/development/live-build-a-custom-kali-iso/) for explanations on how to use this repository. + +There are also other [code examples of live-build](https://gitlab.com/kalilinux/recipes/live-build-config-examples), as well as [code examples for pre-seed to automate/unattended installation](https://gitlab.com/kalilinux/recipes/kali-preseed-examples). + +- - - + +## Help + +```console +$ ./build.sh --help +Usage: ./build.sh [<option>...] + + --distribution <arg> + --proposed-updates + --arch <arg> + --verbose + --debug + --salt + --variant <arg> + --version <arg> + --subdir <arg> + --get-image-path + --no-clean + --clean + --help + +More information: https://www.kali.org/docs/development/live-build-a-custom-kali-iso/ +$ +``` + +## Usage Examples + +Both images types, using the latest packages: + +```console +$ ./build.sh +[...] +``` + +- - - + +Manually define which Kali mirror to pull from, as well as be more detailed in output: + +```console +$ echo "http://kali.download/kali" > .mirror +$ +$ ./build.sh --verbose +[...] +``` + +- - - + +Build a different Live image version (GNOME and KDE Plasma): + +```console +$ ./build.sh \ + --debug \ + --variant gnome +[...] +$ +$ ./build.sh \ + --debug \ + --variant kde +[...] +$ +``` diff --git a/build.sh b/build.sh index 4474b13..d7485ba 100755 --- a/build.sh +++ b/build.sh @@ -9,7 +9,6 @@ set -o pipefail # Bashism KALI_DIST="kali-rolling" KALI_VERSION="" KALI_VARIANT="default" -IMAGE_TYPE="live" TARGET_DIR="$(dirname $0)/images" TARGET_SUBDIR="" SUDO="sudo" @@ -18,17 +17,6 @@ DEBUG="" HOST_ARCH=$(dpkg --print-architecture) image_name() { - case "$IMAGE_TYPE" in - live) - live_image_name - ;; - installer) - installer_image_name - ;; - esac -} - -live_image_name() { case "$KALI_ARCH" in i386|amd64|arm64) echo "live-image-$KALI_ARCH.hybrid.iso" @@ -39,14 +27,6 @@ live_image_name() { esac } -installer_image_name() { - if [ "$KALI_VARIANT" = "netinst" ]; then - echo "simple-cdd/images/kali-$KALI_VERSION-$KALI_ARCH-NETINST-1.iso" - else - echo "simple-cdd/images/kali-$KALI_VERSION-$KALI_ARCH-BD-1.iso" - fi -} - target_image_name() { local arch=$1 @@ -55,18 +35,10 @@ target_image_name() { if [ "$IMAGE_EXT" = "$IMAGE_NAME" ]; then IMAGE_EXT="img" fi - if [ "$IMAGE_TYPE" = "live" ]; then - if [ "$KALI_VARIANT" = "default" ]; then - echo "${TARGET_SUBDIR:+$TARGET_SUBDIR/}kali-linux-$KALI_VERSION-live-$KALI_ARCH.$IMAGE_EXT" - else - echo "${TARGET_SUBDIR:+$TARGET_SUBDIR/}kali-linux-$KALI_VERSION-live-$KALI_VARIANT-$KALI_ARCH.$IMAGE_EXT" - fi + if [ "$KALI_VARIANT" = "default" ]; then + echo "${TARGET_SUBDIR:+$TARGET_SUBDIR/}kali-linux-$KALI_VERSION-live-$KALI_ARCH.$IMAGE_EXT" else - if [ "$KALI_VARIANT" = "default" ]; then - echo "${TARGET_SUBDIR:+$TARGET_SUBDIR/}kali-linux-$KALI_VERSION-installer-$KALI_ARCH.$IMAGE_EXT" - else - echo "${TARGET_SUBDIR:+$TARGET_SUBDIR/}kali-linux-$KALI_VERSION-installer-$KALI_VARIANT-$KALI_ARCH.$IMAGE_EXT" - fi + echo "${TARGET_SUBDIR:+$TARGET_SUBDIR/}kali-linux-$KALI_VERSION-live-$KALI_VARIANT-$KALI_ARCH.$IMAGE_EXT" fi } @@ -87,7 +59,7 @@ default_version() { } failure() { - echo "Build of $KALI_DIST/$KALI_VARIANT/$KALI_ARCH $IMAGE_TYPE image failed (see build.log for details)" >&2 + echo "Build of $KALI_DIST/$KALI_VARIANT/$KALI_ARCH live image failed (see build.log for details)" >&2 echo "Log: $BUILD_LOG" >&2 exit 2 } @@ -115,17 +87,12 @@ debug() { clean() { debug "Cleaning" - # Live run_and_log $SUDO lb clean --purge #run_and_log $SUDO umount -l $(pwd)/chroot/proc #run_and_log $SUDO umount -l $(pwd)/chroot/dev/pts #run_and_log $SUDO umount -l $(pwd)/chroot/sys #run_and_log $SUDO rm -rf $(pwd)/chroot #run_and_log $SUDO rm -rf $(pwd)/binary - - # Installer - run_and_log $SUDO rm -rf "$(pwd)/simple-cdd/tmp" - run_and_log $SUDO rm -rf "$(pwd)/simple-cdd/debian-cd" } print_help() { @@ -177,8 +144,6 @@ while true; do -D|--debug) DEBUG="1"; shift 1; ;; -s|--salt) shift; ;; -h|--help) print_help; ;; - --installer) IMAGE_TYPE="installer"; shift 1 ;; - --live) IMAGE_TYPE="live"; shift 1 ;; --variant) KALI_VARIANT="$2"; shift 2; ;; --version) KALI_VERSION="$2"; shift 2; ;; --subdir) TARGET_SUBDIR="$2"; shift 2; ;; @@ -206,7 +171,7 @@ debug "KALI_VERSION: $KALI_VERSION" # Check parameters debug "HOST_ARCH: $HOST_ARCH" -if [ "$HOST_ARCH" != "$KALI_ARCH" ] && [ "$IMAGE_TYPE" != "installer" ]; then +if [ "$HOST_ARCH" != "$KALI_ARCH" ]; then case "$HOST_ARCH/$KALI_ARCH" in amd64/i386|i386/amd64) ;; @@ -219,13 +184,11 @@ fi # Build parameters for lb config KALI_CONFIG_OPTS="--distribution $KALI_DIST -- --variant $KALI_VARIANT" -CODENAME=$KALI_DIST # for simple-cdd/debian-cd if [ -n "$OPT_pu" ]; then KALI_CONFIG_OPTS="$KALI_CONFIG_OPTS --proposed-updates" KALI_DIST="$KALI_DIST+pu" fi debug "KALI_CONFIG_OPTS: $KALI_CONFIG_OPTS" -debug "CODENAME: $CODENAME" debug "KALI_DIST: $KALI_DIST" # Set sane PATH (cron seems to lack /sbin/ dirs) @@ -240,27 +203,11 @@ else echo "ERROR: Non Debian-based OS" >&2 fi -debug "IMAGE_TYPE: $IMAGE_TYPE" -case "$IMAGE_TYPE" in - live) - if [ ! -d "$(dirname $0)/kali-config/variant-$KALI_VARIANT" ]; then - echo "ERROR: Unknown variant of Kali live configuration: $KALI_VARIANT" >&2 - fi - require_package live-build "1:20230502+kali4" - require_package debootstrap "1.0.97" - ;; - installer) - if [ ! -d "$(dirname $0)/kali-config/installer-$KALI_VARIANT" ]; then - echo "ERROR: Unknown variant of Kali installer configuration: $KALI_VARIANT" >&2 - fi - require_package debian-cd "3.2.1+kali1" - require_package simple-cdd "0.6.9" - ;; - *) - echo "ERROR: Unsupported IMAGE_TYPE selected ($IMAGE_TYPE)" >&2 - exit 1 - ;; -esac +if [ ! -d "$(dirname $0)/kali-config/variant-$KALI_VARIANT" ]; then + echo "ERROR: Unknown variant of Kali live configuration: $KALI_VARIANT" >&2 +fi +require_package live-build "1:20230502+kali4" +require_package debootstrap "1.0.97" # We need root rights at some point if [ "$(whoami)" != "root" ]; then @@ -295,109 +242,15 @@ mkdir -p $TARGET_DIR/$TARGET_SUBDIR # Don't quit on any errors now set +e -case "$IMAGE_TYPE" in - live) - debug "Stage 1/2 - Config" - run_and_log lb config -a $KALI_ARCH $KALI_CONFIG_OPTS "$@" - [ $? -eq 0 ] || failure - - debug "Stage 2/2 - Build" - run_and_log $SUDO lb build - if [ $? -ne 0 ] || [ ! -e $IMAGE_NAME ]; then - failure - fi - ;; - installer) - # Override some debian-cd environment variables - export BASEDIR="$(pwd)/simple-cdd/debian-cd" - export ARCHES=$KALI_ARCH - export ARCH=$KALI_ARCH - export DEBVERSION=$KALI_VERSION - debug "BASEDIR: $BASEDIR" - debug "ARCHES: $ARCHES" - debug "ARCH: $ARCH" - debug "DEBVERSION: $DEBVERSION" - - if [ "$KALI_VARIANT" = "netinst" ]; then - export DISKTYPE="NETINST" - profiles="kali" - auto_profiles="kali" - elif [ "$KALI_VARIANT" = "purple" ]; then - export DISKTYPE="BD" - profiles="kali kali-purple offline" - auto_profiles="kali kali-purple offline" - export KERNEL_PARAMS="debian-installer/theme=Clearlooks-Purple" - else # plain installer - export DISKTYPE="BD" - profiles="kali offline" - auto_profiles="kali offline" - fi - debug "DISKTYPE: $DISKTYPE" - debug "profiles: $profiles" - debug "auto_profiles: $auto_profiles" - [ -v KERNEL_PARAMS ] && debug "KERNEL_PARAMS: $KERNEL_PARAMS" - - if [ -e .mirror ]; then - kali_mirror=$(cat .mirror) - else - kali_mirror=http://kali.download/kali/ - fi - if ! echo "$kali_mirror" | grep -q '/$'; then - kali_mirror="$kali_mirror/" - fi - debug "kali_mirror: $kali_mirror" - - debug "Stage 1/2 - File(s)" - # Setup custom debian-cd to make our changes - cp -aT /usr/share/debian-cd simple-cdd/debian-cd - [ $? -eq 0 ] || failure - - # Use the same grub theme as in the live images - # Until debian-cd is smart enough: http://bugs.debian.org/1003927 - cp -f kali-config/common/bootloaders/grub-pc/grub-theme.in simple-cdd/debian-cd/data/$CODENAME/grub-theme.in - - # Keep 686-pae udebs as we changed the default from 686 - # to 686-pae in the debian-installer images - sed -i -e '/686-pae/d' \ - simple-cdd/debian-cd/data/$CODENAME/exclude-udebs-i386 - [ $? -eq 0 ] || failure - - # Configure the kali profile with the packages we want - grep -v '^#' kali-config/installer-$KALI_VARIANT/packages \ - > simple-cdd/profiles/kali.downloads - [ $? -eq 0 ] || failure - - # Tasksel is required in the mirror for debian-cd - echo tasksel >> simple-cdd/profiles/kali.downloads - [ $? -eq 0 ] || failure - - # Grub is the only supported bootloader on arm64 - # so ensure it's on the iso for arm64. - if [ "$KALI_ARCH" = "arm64" ]; then - debug "arm64 GRUB" - echo "grub-efi-arm64" >> simple-cdd/profiles/kali.downloads - [ $? -eq 0 ] || failure - fi - - # Run simple-cdd - debug "Stage 2/2 - Build" - cd simple-cdd/ - run_and_log build-simple-cdd \ - --verbose \ - --debug \ - --force-root \ - --conf simple-cdd.conf \ - --dist $CODENAME \ - --debian-mirror $kali_mirror \ - --profiles "$profiles" \ - --auto-profiles "$auto_profiles" - res=$? - cd ../ - if [ $res -ne 0 ] || [ ! -e $IMAGE_NAME ]; then - failure - fi - ;; -esac +debug "Stage 1/2 - Config" +run_and_log lb config -a $KALI_ARCH $KALI_CONFIG_OPTS "$@" +[ $? -eq 0 ] || failure + +debug "Stage 2/2 - Build" +run_and_log $SUDO lb build +if [ $? -ne 0 ] || [ ! -e $IMAGE_NAME ]; then + failure +fi # If a command fails, make the whole script exit set -e diff --git a/build_all.sh b/build_all.sh deleted file mode 120000 index c07a74d..0000000 --- a/build_all.sh +++ /dev/null @@ -1 +0,0 @@ -build.sh \ No newline at end of file diff --git a/kali-config/common/bootloaders/grub-pc/grub-theme.in b/kali-config/common/bootloaders/grub-pc/grub-theme.in deleted file mode 100644 index fb7fb78..0000000 --- a/kali-config/common/bootloaders/grub-pc/grub-theme.in +++ /dev/null @@ -1,95 +0,0 @@ -#/* Installer Image (UEFI boot) */ -title-text: "" -desktop-image: "../splash.png" -desktop-color: "#041838" -terminal-left: "0" -terminal-top: "0" -terminal-width: "100%" -terminal-height: "100%" -terminal-border: "0" - -+ vbox { - top = 80 - left = 65% - width = 30% - height = 100 -#ifdef MENU1 - + hbox { - left = 0 - + label {text = " >" font = "Sans 10" color = "white" align = "left"} - + label {text = MENU1 font = "Sans 10" color = "#c0c0c0" align = "left"} - } -#endif -#ifdef MENU2 - + hbox { - left = 0 - + label {text = " >" font = "Sans 10" color = "white" align = "left"} - + label {text = MENU2 font = "Sans 10" color = "#c0c0c0" align = "left"} - } -#endif -#ifdef MENU3 - + hbox { - left = 0 - + label {text = " >" font = "Sans 10" color = "white" align = "left"} - + label {text = MENU3 font = "Sans 10" color = "#c0c0c0" align = "left"} - } -#endif -#ifdef MENU4 - + hbox { - left = 0 - + label {text = " >" font = "Sans 10" color = "white" align = "left"} - + label {text = MENU4 font = "Sans 10" color = "#c0c0c0" align = "left"} - } -#endif -} - -+ label { - top = 31% - left = 0 - width = 100% - height = 35 - align = "center" - color = "#ffffff" - font = "Sans 16" - text = "Kali Linux installer menu (UEFI mode)" -} - -+ boot_menu { - left = 14% - width = 73% - top = 39% - height = 42% - item_color = "#f3f3f3" - selected_item_color = "#ffffff" - item_height = 36 - item_padding = 0 - item_spacing = 4 - icon_width = 0 - icon_height = 0 - selected_item_pixmap_style = "select_*.png" -} - -+ vbox { - top = 100%-60 - left = 14% - + hbox { - top = 0 - left = 20% - + label {text = "Enter: " font = "Sans 10" color = "white" align = "left"} - + label {text = "Select " font = "Sans 10" color = "#c0c0c0" align = "left"} -#ifdef MENU1 - + label {text = " " font = "Sans 10" color = "white" align = "left"} - + label {text = "Esc: " font = "Sans 10" color = "white" align = "left"} - + label {text = "Back up one level " font = "Sans 10" color = "#c0c0c0" align = "left"} -#endif - } - + hbox { - top = 0 - left = 20% - + label {text = "E: " font = "Sans 10" color = "white" align = "left"} - + label {text = "Edit Selection " font = "Sans 10" color = "#c0c0c0" align = "left"} - + label {text = " " font = "Sans 10" color = "white" align = "left"} - + label {text = "C: " font = "Sans 10" color = "white" align = "left"} - + label {text = "GRUB Command line" font = "Sans 10" color = "#c0c0c0" align = "left"} - } -} diff --git a/kali-config/common/includes.installer/kali-finish-install b/kali-config/common/includes.installer/kali-finish-install index 23be7a1..cbc188a 100755 --- a/kali-config/common/includes.installer/kali-finish-install +++ b/kali-config/common/includes.installer/kali-finish-install @@ -1,7 +1,7 @@ #!/bin/sh # The reference version of this script is maintained in -# ./live-build-config/kali-config/common/includes.installer/kali-finish-install +# ./kali-live/kali-config/common/includes.installer/kali-finish-install # # It is used in multiple places to finish configuring the target system # and build.sh copies it where required (in the simple-cdd configuration diff --git a/kali-config/installer-default/packages b/kali-config/installer-default/packages deleted file mode 100644 index 6d32598..0000000 --- a/kali-config/installer-default/packages +++ /dev/null @@ -1,23 +0,0 @@ -# Full installer image -# It should contain everything offered in tasksel -# during initial installation so all kali-linux-* except: -# - kali-linux-everything - -# Metapackages -# You can customize the set of Kali metapackages (groups of tools) available -# in the installer ISO. -# For the complete list see: https://tools.kali.org/kali-metapackages -kali-linux-firmware -kali-linux-core -kali-tools-top10 -kali-linux-default - -# NOTE: We would like to provide kali-linux-large in our installer images -# but we end up with ISO images that are too big for our CDN. So disable -# it for now. -# kali-linux-large - -# Graphical desktops -kali-desktop-xfce -kali-desktop-gnome -kali-desktop-kde diff --git a/kali-config/installer-everything/packages b/kali-config/installer-everything/packages deleted file mode 100644 index 6614383..0000000 --- a/kali-config/installer-everything/packages +++ /dev/null @@ -1,17 +0,0 @@ -# Installer image with kali-linux-everything - -# Metapackages -# You can customize the set of Kali metapackages (groups of tools) available -# in the installer ISO. -# For the complete list see: https://tools.kali.org/kali-metapackages -kali-linux-firmware -kali-linux-core -kali-tools-top10 -kali-linux-default -kali-linux-large -kali-linux-everything - -# Graphical desktops -kali-desktop-xfce -kali-desktop-gnome -kali-desktop-kde diff --git a/kali-config/installer-netinst/packages b/kali-config/installer-netinst/packages deleted file mode 100644 index a5e61d1..0000000 --- a/kali-config/installer-netinst/packages +++ /dev/null @@ -1,9 +0,0 @@ -# Network installer image -# Mostly empty list because netinst has no embedded packages in theory -# -# This variant is not meant to be used with live-build but only with -# simple-cdd and thus ./build.sh --installer --variant netinst - -# We still put kali-linux-firmware because we want firmware to be -# in the ISO for use by the installer -kali-linux-firmware diff --git a/kali-config/installer-purple/packages b/kali-config/installer-purple/packages deleted file mode 100644 index 73239fe..0000000 --- a/kali-config/installer-purple/packages +++ /dev/null @@ -1,21 +0,0 @@ -# Installer for Kali Purple - -# Metapackages -# You can customize the set of Kali metapackages (groups of tools) available -# in the installer ISO. -# For the complete list see: https://tools.kali.org/kali-metapackages -kali-linux-firmware -kali-system-gui -kali-themes-purple # temporary, until we do it a better way - -# Tools -kali-tools-detect -kali-tools-identify -kali-tools-protect -kali-tools-recover -kali-tools-respond - -# Graphical desktops -kali-desktop-xfce -kali-desktop-gnome -kali-desktop-kde diff --git a/simple-cdd/disc-end-hook b/simple-cdd/disc-end-hook deleted file mode 100755 index b42299e..0000000 --- a/simple-cdd/disc-end-hook +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh - -set -e - -TDIR=$1 -MIRROR=$2 -DISKNUM=$3 -CDDIR=$4 -ARCHES=$5 - -# Copy grub theme assets -# Until debian-cd picks them from d-i automatically: -# http://bugs.debian.org/1003927 -cp -r $BASEDIR/../../kali-config/common/bootloaders/grub-pc/theme \ - $BASEDIR/../../kali-config/common/bootloaders/grub-pc/splash.png \ - $CDDIR/boot/grub/ - -cd $CDDIR - -fix_branding() { - sed -i -e 's|Debian GNU/Linux|Kali Linux|g' \ - -e 's|Kali GNU/Linux|Kali Linux|g' \ - -e 's|Debian kali-rolling|Kali Rolling|g' \ - -e 's|Debian|Kali|g' \ - -e 's|DEBIAN|KALI|g' \ - "$@" -} - -# Rebrand Debian into Kali -if [ -e ../boot$DISKNUM/isolinux/menu.cfg ]; then - fix_branding ../boot$DISKNUM/isolinux/menu.cfg \ - ../boot$DISKNUM/isolinux/*.txt -fi -if [ -d boot/grub/theme ] && [ -s boot/grub/theme ]; then - fix_branding boot/grub/theme/* -fi - -# Remove Debian's windows loader -rm -f autorun.inf win32-loader.ini setup.exe - -# Replace Debian specific documentation -rm -rf css -cat >README.txt <<EOF -This disc contains an installer for Kali Linux. - -Read more at: https://www.kali.org -EOF -cat >README.html <<EOF -<html> -<head><title>Kali Linux Installer Disc</title></head> -<body> -This disc contains an installer for Kali Linux. - -Read more at: <a href="https://www.kali.org">www.kali.org</a> -</body> -</html> -EOF - -# Replace kali-last-snapshot with kali-rolling -if [ -e dists/kali-last-snapshot ]; then - mv dists/kali-last-snapshot dists/kali-rolling - rm -f dists/stable && ln -sf kali-rolling dists/stable - sed -i -e 's|kali-last-snapshot|kali-rolling|g' \ - dists/kali-rolling/Release -fi - -# Redo the md5sum.txt due to our changes -find . -type f | grep -v ./md5sum.txt | xargs md5sum | sort -uk2 > md5sum.txt diff --git a/simple-cdd/local_packages/.empty b/simple-cdd/local_packages/.empty deleted file mode 100644 index e69de29..0000000 diff --git a/simple-cdd/profiles/default.downloads b/simple-cdd/profiles/default.downloads deleted file mode 120000 index 024fb11..0000000 --- a/simple-cdd/profiles/default.downloads +++ /dev/null @@ -1 +0,0 @@ -/usr/share/simple-cdd/profiles/default.downloads \ No newline at end of file diff --git a/simple-cdd/profiles/default.excludes b/simple-cdd/profiles/default.excludes deleted file mode 120000 index 0b5629f..0000000 --- a/simple-cdd/profiles/default.excludes +++ /dev/null @@ -1 +0,0 @@ -/usr/share/simple-cdd/profiles/default.excludes \ No newline at end of file diff --git a/simple-cdd/profiles/default.packages b/simple-cdd/profiles/default.packages deleted file mode 100644 index 8bc8527..0000000 --- a/simple-cdd/profiles/default.packages +++ /dev/null @@ -1 +0,0 @@ -# Disable default packages from simple-cdd diff --git a/simple-cdd/profiles/default.preseed b/simple-cdd/profiles/default.preseed deleted file mode 100644 index 75bff77..0000000 --- a/simple-cdd/profiles/default.preseed +++ /dev/null @@ -1,3 +0,0 @@ -# loads the simple-cdd-profiles udeb to which asks for which profiles to use, -# load the debconf preseeding and queue packages for installation. -d-i preseed/early_command string anna-install simple-cdd-profiles diff --git a/simple-cdd/profiles/default.udebs b/simple-cdd/profiles/default.udebs deleted file mode 100644 index ee104d8..0000000 --- a/simple-cdd/profiles/default.udebs +++ /dev/null @@ -1 +0,0 @@ -simple-cdd-profiles diff --git a/simple-cdd/profiles/kali-purple.postinst b/simple-cdd/profiles/kali-purple.postinst deleted file mode 100755 index 0302f50..0000000 --- a/simple-cdd/profiles/kali-purple.postinst +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh - -set -eu - -cat << 'EOF' > /etc/apt/sources.list.d/elastic.sources -Enabled: yes -Types: deb -URIs: https://artifacts.elastic.co/packages/8.x/apt -Suites: stable -Components: main -Signed-by: - -----BEGIN PGP PUBLIC KEY BLOCK----- - Version: GnuPG v2.0.14 (GNU/Linux) - . - mQENBFI3HsoBCADXDtbNJnxbPqB1vDNtCsqhe49vFYsZN9IOZsZXgp7aHjh6CJBD - A+bGFOwyhbd7at35jQjWAw1O3cfYsKAmFy+Ar3LHCMkV3oZspJACTIgCrwnkic/9 - CUliQe324qvObU2QRtP4Fl0zWcfb/S8UYzWXWIFuJqMvE9MaRY1bwUBvzoqavLGZ - j3SF1SPO+TB5QrHkrQHBsmX+Jda6d4Ylt8/t6CvMwgQNlrlzIO9WT+YN6zS+sqHd - 1YK/aY5qhoLNhp9G/HxhcSVCkLq8SStj1ZZ1S9juBPoXV1ZWNbxFNGwOh/NYGldD - 2kmBf3YgCqeLzHahsAEpvAm8TBa7Q9W21C8vABEBAAG0RUVsYXN0aWNzZWFyY2gg - KEVsYXN0aWNzZWFyY2ggU2lnbmluZyBLZXkpIDxkZXZfb3BzQGVsYXN0aWNzZWFy - Y2gub3JnPokBOAQTAQIAIgUCUjceygIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgEC - F4AACgkQ0n1mbNiOQrRzjAgAlTUQ1mgo3nK6BGXbj4XAJvuZDG0HILiUt+pPnz75 - nsf0NWhqR4yGFlmpuctgCmTD+HzYtV9fp9qW/bwVuJCNtKXk3sdzYABY+Yl0Cez/ - 7C2GuGCOlbn0luCNT9BxJnh4mC9h/cKI3y5jvZ7wavwe41teqG14V+EoFSn3NPKm - TxcDTFrV7SmVPxCBcQze00cJhprKxkuZMPPVqpBS+JfDQtzUQD/LSFfhHj9eD+Xe - 8d7sw+XvxB2aN4gnTlRzjL1nTRp0h2/IOGkqYfIG9rWmSLNlxhB2t+c0RsjdGM4/ - eRlPWylFbVMc5pmDpItrkWSnzBfkmXL3vO2X3WvwmSFiQbkBDQRSNx7KAQgA5JUl - zcMW5/cuyZR8alSacKqhSbvoSqqbzHKcUQZmlzNMKGTABFG1yRx9r+wa/fvqP6OT - RzRDvVS/cycws8YX7Ddum7x8uI95b9ye1/Xy5noPEm8cD+hplnpU+PBQZJ5XJ2I+ - 1l9Nixx47wPGXeClLqcdn0ayd+v+Rwf3/XUJrvccG2YZUiQ4jWZkoxsA07xx7Bj+ - Lt8/FKG7sHRFvePFU0ZS6JFx9GJqjSBbHRRkam+4emW3uWgVfZxuwcUCn1ayNgRt - KiFv9jQrg2TIWEvzYx9tywTCxc+FFMWAlbCzi+m4WD+QUWWfDQ009U/WM0ks0Kww - EwSk/UDuToxGnKU2dQARAQABiQEfBBgBAgAJBQJSNx7KAhsMAAoJENJ9ZmzYjkK0 - c3MIAIE9hAR20mqJWLcsxLtrRs6uNF1VrpB+4n/55QU7oxA1iVBO6IFu4qgsF12J - TavnJ5MLaETlggXY+zDef9syTPXoQctpzcaNVDmedwo1SiL03uMoblOvWpMR/Y0j - 6rm7IgrMWUDXDPvoPGjMl2q1iTeyHkMZEyUJ8SKsaHh4jV9wp9KmC8C+9CwMukL7 - vM5w8cgvJoAwsp3Fn59AxWthN3XJYcnMfStkIuWgR7U2r+a210W6vnUxU4oN0PmM - cursYPyeV0NX/KQeUeNMwGTFB6QHS/anRaGQewijkrYYoTNtfllxIu9XYmiBERQ/ - qPDlGRlOgVTd9xUfHFkzB52c70E= - =92oX - -----END PGP PUBLIC KEY BLOCK----- -EOF - -apt-get update diff --git a/simple-cdd/profiles/kali.postinst b/simple-cdd/profiles/kali.postinst deleted file mode 120000 index a0e67f7..0000000 --- a/simple-cdd/profiles/kali.postinst +++ /dev/null @@ -1 +0,0 @@ -../../kali-config/common/includes.installer/kali-finish-install \ No newline at end of file diff --git a/simple-cdd/profiles/kali.preseed b/simple-cdd/profiles/kali.preseed deleted file mode 120000 index 26deeec..0000000 --- a/simple-cdd/profiles/kali.preseed +++ /dev/null @@ -1 +0,0 @@ -../../kali-config/common/includes.installer/preseed.cfg \ No newline at end of file diff --git a/simple-cdd/profiles/offline.downloads b/simple-cdd/profiles/offline.downloads deleted file mode 100644 index 3d7d8e0..0000000 --- a/simple-cdd/profiles/offline.downloads +++ /dev/null @@ -1,18 +0,0 @@ -# Ensure eatmydata is available for eatmydata.udeb -eatmydata -# Add packages required for virtualization support (installed by -# /usr/lib/finish-install.d/08hw-detect) including their recommends -hyperv-daemons -open-vm-tools -open-vm-tools-desktop -qemu-guest-agent -virtualbox-guest-utils -virtualbox-guest-x11 -xauth -xserver-xorg-video-vmware -# Add packages required for speech synthesis (installed by -# /usr/lib/finish-install.d/06espeakup) including their recommends -espeakup -# Ensure unrar is available, otherwise the "unrar | unar" dependency -# in kali-linux-headless ends up satisfied by the unar alternative -unrar diff --git a/simple-cdd/profiles/offline.preseed b/simple-cdd/profiles/offline.preseed deleted file mode 100644 index 69623a4..0000000 --- a/simple-cdd/profiles/offline.preseed +++ /dev/null @@ -1,3 +0,0 @@ -# Do not use a network mirror, full offline install -d-i apt-setup/use_mirror boolean false -d-i pkgsel/upgrade select none diff --git a/simple-cdd/simple-cdd.conf b/simple-cdd/simple-cdd.conf deleted file mode 100644 index dc4b29b..0000000 --- a/simple-cdd/simple-cdd.conf +++ /dev/null @@ -1,118 +0,0 @@ -# simple-cdd.conf detailed configuration file -# -# Note: this is an example list of configuration options: it is *strongly* -# advised to merely create a new file using only the options you actually need. -# -# Note: Variables in lowercase are only used by simple-cdd. -# -# Profile Selection -# -# The following four files get included on the CD if present: -# $profile.preseed -# Debconf selections. -# $profile.packages -# Packages to be installed with the profile. Dependencies also will -# be installed. -# $profile.downloads -# Additional packages to be included on the CD with this profile, but -# not installed by default. -# $profile.postinst -# Post-install script that is run after installing packages. -# -# During the install after base system setup, it will give you the -# options to determine which profiles you want to install. - -# Profiles to include on the CD -profiles=${profiles:-kali} - -# To automatically select profiles (must also be listed in profiles): -auto_profiles=${auto_profiles:-kali} - -# To include profiles which only effect the CD build -#build_profiles="kali" - -# Mirror tools -mirror_tools="reprepro download" -mirror_files="" # Don't try to download README doc/ tools/ -require_optional_packages="true" -ignore_missing_checksums="true" - -# Mirror variables -server="http.kali.org" -debian_mirror=${debian_mirror:-http://kali.download/kali/} -keyring="/usr/share/keyrings/kali-archive-keyring.gpg" - -# Which components to get from the mirror -mirror_components="main contrib non-free non-free-firmware" - -# Disable *-security and *-updates repositories -security_mirror="" -updates_mirror="" - -# Add kernel parameter to disable -export KERNEL_PARAMS="${KERNEL_PARAMS} net.ifnames=0 " - -# Kernel and architecture related -if [ "$ARCH" = "i386" ]; then - kernel_packages="linux-image-686-pae" -fi -if [ "$ARCH" = "arm64" ]; then - kernel_packages="linux-image-arm64" - # ARM devices don't typically have a default console set, so we export one here - export KERNEL_PARAMS="${KERNEL_PARAMS} console=tty0 " - # Some packages are not available on arm64 - require_optional_packages="false" -fi - -# Random other variables -export default_desktop="xfce" -export DISKINFO_DISTRO="Kali" -export DEBVERSION=${DEBVERSION:-rolling} -export OFFICIAL="Official" -export VOLID_BASE="Kali Linux" -export CDNAME="kali" - -export OMIT_MANUAL=1 -export OMIT_RELEASE_NOTES=1 -export OMIT_DOC_TOOLS=1 -export DOJIGDO=0 -export NORECOMMENDS=0 -export NONFREE=1 -export NONFREE_COMPONENTS="non-free non-free-firmware" -export CONTRIB=1 -export FORCE_FIRMWARE=1 -export ARCHIVE_KEYRING_PACKAGE=kali-archive-keyring -export DESKTOP=xfce -export DISKTYPE=${DISKTYPE:-DVD} - -# Kali repo doesn't have dep11 metadata -export DEP11=0 - -# Configure a hook to apply our customization via debian-cd -export DISC_END_HOOK=$(pwd)/disc-end-hook - -# Extra files to include onto the CD -# These will get copied to /simple-cdd dir on the CD -# Paths starting with '/' are interpreted as absolute, otherwise relative -# to the current directory. -#all_extras="" - -# Generate a simple package repository on the CD with the debs cited -# Please insert full paths. -local_packages="$(pwd)/local_packages" - -# Call mirror tools at each build- defaults to true. -#do_mirror="false" - -# Set your proxy (if any). -#export http_proxy=http://localhost:3128 - -# Location of debian-cd files -debian_cd_dir=${BASEDIR:-/usr/share/debian-cd} - -# Set target architecture for build -#export ARCH=amd64 -#export ARCHES="amd64 i386" - -# Define the CD label -export DISKINFO="Kali Installer: Kali Linux $DEBVERSION $(date +%Y-%m-%d)" -- GitLab From 2d05f2b85be8084d6ab6b9d107566d4fd5fe939f Mon Sep 17 00:00:00 2001 From: g0t mi1k <have.you.g0tmi1k@gmail.com> Date: Tue, 21 Jan 2025 15:26:36 +0000 Subject: [PATCH 02/15] Drop --salt --- .getopt.sh | 5 ++--- README.md | 1 - build.sh | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.getopt.sh b/.getopt.sh index 6ef11f7..00bbac3 100644 --- a/.getopt.sh +++ b/.getopt.sh @@ -4,7 +4,6 @@ # -a | --arch <architecture> # -v | --verbose # -D | --debug -# -s | --salt # -h | --help # --variant <variant> # --version <version> @@ -13,5 +12,5 @@ # --no-clean # --clean -BUILD_OPTS_SHORT="d:pa:vDsh" -BUILD_OPTS_LONG="distribution:,proposed-updates,arch:,verbose,debug,salt,variant:,version:,subdir:,get-image-path,no-clean,clean,help" +BUILD_OPTS_SHORT="d:pa:vDh" +BUILD_OPTS_LONG="distribution:,proposed-updates,arch:,verbose,debug,variant:,version:,subdir:,get-image-path,no-clean,clean,help" diff --git a/README.md b/README.md index 45e2e51..e7fa8b6 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,6 @@ Usage: ./build.sh [<option>...] --arch <arg> --verbose --debug - --salt --variant <arg> --version <arg> --subdir <arg> diff --git a/build.sh b/build.sh index d7485ba..ed74220 100755 --- a/build.sh +++ b/build.sh @@ -142,7 +142,6 @@ while true; do -a|--arch) KALI_ARCH="$2"; shift 2; ;; -v|--verbose) VERBOSE="1"; shift 1; ;; -D|--debug) DEBUG="1"; shift 1; ;; - -s|--salt) shift; ;; -h|--help) print_help; ;; --variant) KALI_VARIANT="$2"; shift 2; ;; --version) KALI_VERSION="$2"; shift 2; ;; -- GitLab From cf029a87c984445e15b83b76f8c3406653b0692b Mon Sep 17 00:00:00 2001 From: g0t mi1k <have.you.g0tmi1k@gmail.com> Date: Mon, 20 Jan 2025 10:26:47 +0000 Subject: [PATCH 03/15] Clean up ignored --- .gitignore | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index d93d35c..1467c8a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,31 +1,15 @@ -# Directories -.build/* -binary/* -binary.*/* -cache/* -chroot/* -config/* +## Directories +.build/ +cache/ +chroot/ +## `lb` will generate this folder, `config` +## Which is why our config directory is called `kali-config` +config/ +## Incase symlink, no slash images -local/* -# Files +## Files +.lock .mirror -binary.modified_timestamps build.log -chroot.files -chroot.packages.install -chroot.packages.live -config/binary -config/bootstrap -config/common -config/source -live-image-*.contents -live-image-*.files -live-image-*.hybrid.iso.zsync -live-image-*.packages wget-log* - -# Miscellaneous -.lock -.stage -prepare.log -- GitLab From 530b22106b484a39ba9ff8f965df296eff61a49e Mon Sep 17 00:00:00 2001 From: g0t mi1k <have.you.g0tmi1k@gmail.com> Date: Sun, 19 Jan 2025 15:47:37 +0000 Subject: [PATCH 04/15] Prefix desktop to variant Tool metapackages --- .../package-lists/kali.list.chroot | 0 .../package-lists/kali.list.chroot | 0 .../package-lists/kali.list.chroot | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename kali-config/{variant-everything => variant-xfce-everything}/package-lists/kali.list.chroot (100%) rename kali-config/{variant-large => variant-xfce-large}/package-lists/kali.list.chroot (100%) rename kali-config/{variant-light => variant-xfce-light}/package-lists/kali.list.chroot (100%) diff --git a/kali-config/variant-everything/package-lists/kali.list.chroot b/kali-config/variant-xfce-everything/package-lists/kali.list.chroot similarity index 100% rename from kali-config/variant-everything/package-lists/kali.list.chroot rename to kali-config/variant-xfce-everything/package-lists/kali.list.chroot diff --git a/kali-config/variant-large/package-lists/kali.list.chroot b/kali-config/variant-xfce-large/package-lists/kali.list.chroot similarity index 100% rename from kali-config/variant-large/package-lists/kali.list.chroot rename to kali-config/variant-xfce-large/package-lists/kali.list.chroot diff --git a/kali-config/variant-light/package-lists/kali.list.chroot b/kali-config/variant-xfce-light/package-lists/kali.list.chroot similarity index 100% rename from kali-config/variant-light/package-lists/kali.list.chroot rename to kali-config/variant-xfce-light/package-lists/kali.list.chroot -- GitLab From 26efadcc712e659d20baca3c9952627a7c9f9271 Mon Sep 17 00:00:00 2001 From: g0t mi1k <have.you.g0tmi1k@gmail.com> Date: Mon, 20 Jan 2025 06:57:48 +0000 Subject: [PATCH 05/15] Refresh live profile --- .../live/tweak-enlightenment-config.chroot | 10 +++--- .../package-lists/kali.list.chroot | 28 ++++++++-------- .../package-lists/kali.list.chroot | 28 ++++++++-------- .../variant-i3/package-lists/kali.list.chroot | 28 ++++++++-------- .../package-lists/kali.list.chroot | 28 ++++++++-------- .../package-lists/kali.list.chroot | 28 ++++++++-------- .../package-lists/kali.list.chroot | 33 +++++++++---------- .../package-lists/kali.list.chroot | 28 ++++++++-------- .../package-lists/kali.list.chroot | 28 ++++++++-------- .../package-lists/kali.list.chroot | 28 ++++++++-------- .../package-lists/kali.list.chroot | 28 ++++++++-------- 11 files changed, 155 insertions(+), 140 deletions(-) diff --git a/kali-config/variant-e17/hooks/live/tweak-enlightenment-config.chroot b/kali-config/variant-e17/hooks/live/tweak-enlightenment-config.chroot index 8b6ca88..ff89944 100755 --- a/kali-config/variant-e17/hooks/live/tweak-enlightenment-config.chroot +++ b/kali-config/variant-e17/hooks/live/tweak-enlightenment-config.chroot @@ -2,9 +2,9 @@ # Inject default background in e17 configuration (for all known profiles) for profile in mobile standard; do - dpkg-divert --local --add /usr/share/enlightenment/data/config/$profile/e.cfg - eet -d /usr/share/enlightenment/data/config/$profile/e.cfg config /tmp/e.src - awk '/value "desktop_default_name"/ {print " value \"desktop_default_background\" string: \"/usr/share/enlightenment/data/backgrounds/kali-wallpaper_1920x1200.edj\";"}; {print}' /tmp/e.src >/tmp/e2.src - eet -e /usr/share/enlightenment/data/config/$profile/e.cfg config /tmp/e2.src 1 - rm -f /tmp/e.src /tmp/e2.src + dpkg-divert --local --add /usr/share/enlightenment/data/config/$profile/e.cfg + eet -d /usr/share/enlightenment/data/config/$profile/e.cfg config /tmp/e.src + awk '/value "desktop_default_name"/ {print " value \"desktop_default_background\" string: \"/usr/share/enlightenment/data/backgrounds/kali-wallpaper_1920x1200.edj\";"}; {print}' /tmp/e.src >/tmp/e2.src + eet -e /usr/share/enlightenment/data/config/$profile/e.cfg config /tmp/e2.src 1 + rm -f /tmp/e.src /tmp/e2.src done diff --git a/kali-config/variant-e17/package-lists/kali.list.chroot b/kali-config/variant-e17/package-lists/kali.list.chroot index 3dd480d..a7e874b 100644 --- a/kali-config/variant-e17/package-lists/kali.list.chroot +++ b/kali-config/variant-e17/package-lists/kali.list.chroot @@ -1,19 +1,21 @@ -# Live image -# You always want these: +## Live image with Enlightenment 17 and default tools +## +## $ ./build.sh --variant e17 + +## Live images always want these kali-linux-core kali-desktop-live -# Metapackages -# You can customize the set of Kali metapackages (groups of tools) to install -# For the complete list see: https://tools.kali.org/kali-metapackages -#kali-linux-core -#kali-tools-top10 -kali-linux-default -#kali-linux-large -#kali-linux-everything - -# Graphical desktop +## Graphical desktop +## For the complete list see: https://www.kali.org/docs/general-use/metapackages/ kali-desktop-e17 -# Kali applications +## Metapackages +## You can customize the set of Kali metapackages (groups of tools) to install +## For the complete list see: https://www.kali.org/tools/kali-meta/ +kali-linux-default + +## Extra Kali packages/tools/applications +## For the complete list see: https://www.kali.org/tools/ +## https://pkg.kali.org/ #<package> diff --git a/kali-config/variant-gnome/package-lists/kali.list.chroot b/kali-config/variant-gnome/package-lists/kali.list.chroot index 672be48..b545251 100644 --- a/kali-config/variant-gnome/package-lists/kali.list.chroot +++ b/kali-config/variant-gnome/package-lists/kali.list.chroot @@ -1,19 +1,21 @@ -# Live image -# You always want these: +## Live image with GNOME and default tools +## +## $ ./build.sh --variant gnome + +## Live images always want these kali-linux-core kali-desktop-live -# Metapackages -# You can customize the set of Kali metapackages (groups of tools) to install -# For the complete list see: https://tools.kali.org/kali-metapackages -#kali-linux-core -#kali-tools-top10 -kali-linux-default -#kali-linux-large -#kali-linux-everything - -# Graphical desktop +## Graphical desktop +## For the complete list see: https://www.kali.org/docs/general-use/metapackages/ kali-desktop-gnome -# Kali applications +## Metapackages +## You can customize the set of Kali metapackages (groups of tools) to install +## For the complete list see: https://www.kali.org/tools/kali-meta/ +kali-linux-default + +## Extra Kali packages/tools/applications +## For the complete list see: https://www.kali.org/tools/ +## https://pkg.kali.org/ #<package> diff --git a/kali-config/variant-i3/package-lists/kali.list.chroot b/kali-config/variant-i3/package-lists/kali.list.chroot index 9d8c491..9b0a584 100644 --- a/kali-config/variant-i3/package-lists/kali.list.chroot +++ b/kali-config/variant-i3/package-lists/kali.list.chroot @@ -1,19 +1,21 @@ -# Live image -# You always want these: +## Live image with i3 and default tools +## +## $ ./build.sh --variant i3 + +## Live images always want these kali-linux-core kali-desktop-live -# Metapackages -# You can customize the set of Kali metapackages (groups of tools) to install -# For the complete list see: https://tools.kali.org/kali-metapackages -#kali-linux-core -#kali-tools-top10 -kali-linux-default -#kali-linux-large -#kali-linux-everything - -# Graphical desktop +## Graphical desktop +## For the complete list see: https://www.kali.org/docs/general-use/metapackages/ kali-desktop-i3 -# Kali applications +## Metapackages +## You can customize the set of Kali metapackages (groups of tools) to install +## For the complete list see: https://www.kali.org/tools/kali-meta/ +kali-linux-default + +## Extra Kali packages/tools/applications +## For the complete list see: https://www.kali.org/tools/ +## https://pkg.kali.org/ #<package> diff --git a/kali-config/variant-kde/package-lists/kali.list.chroot b/kali-config/variant-kde/package-lists/kali.list.chroot index a611035..305db65 100644 --- a/kali-config/variant-kde/package-lists/kali.list.chroot +++ b/kali-config/variant-kde/package-lists/kali.list.chroot @@ -1,19 +1,21 @@ -# Live image -# You always want these: +## Live image with KDE Plasma and default tools +## +## $ ./build.sh --variant kde + +## Live images always want these kali-linux-core kali-desktop-live -# Metapackages -# You can customize the set of Kali metapackages (groups of tools) to install -# For the complete list see: https://tools.kali.org/kali-metapackages -#kali-linux-core -#kali-tools-top10 -kali-linux-default -#kali-linux-large -#kali-linux-everything - -# Graphical desktop +## Graphical desktop +## For the complete list see: https://www.kali.org/docs/general-use/metapackages/ kali-desktop-kde -# Kali applications +## Metapackages +## You can customize the set of Kali metapackages (groups of tools) to install +## For the complete list see: https://www.kali.org/tools/kali-meta/ +kali-linux-default + +## Extra Kali packages/tools/applications +## For the complete list see: https://www.kali.org/tools/ +## https://pkg.kali.org/ #<package> diff --git a/kali-config/variant-lxde/package-lists/kali.list.chroot b/kali-config/variant-lxde/package-lists/kali.list.chroot index 599e91b..216793e 100644 --- a/kali-config/variant-lxde/package-lists/kali.list.chroot +++ b/kali-config/variant-lxde/package-lists/kali.list.chroot @@ -1,19 +1,21 @@ -# Live image -# You always want these: +## Live image with LXDE and default tools +## +## $ ./build.sh --variant lxde + +## Live images always want these kali-linux-core kali-desktop-live -# Metapackages -# You can customize the set of Kali metapackages (groups of tools) to install -# For the complete list see: https://tools.kali.org/kali-metapackages -#kali-linux-core -#kali-tools-top10 -kali-linux-default -#kali-linux-large -#kali-linux-everything - -# Graphical desktop +## Graphical desktop +## For the complete list see: https://www.kali.org/docs/general-use/metapackages/ kali-desktop-lxde -# Kali applications +## Metapackages +## You can customize the set of Kali metapackages (groups of tools) to install +## For the complete list see: https://www.kali.org/tools/kali-meta/ +kali-linux-default + +## Extra Kali packages/tools/applications +## For the complete list see: https://www.kali.org/tools/ +## https://pkg.kali.org/ #<package> diff --git a/kali-config/variant-mate/package-lists/kali.list.chroot b/kali-config/variant-mate/package-lists/kali.list.chroot index b8b9192..b2b2f88 100644 --- a/kali-config/variant-mate/package-lists/kali.list.chroot +++ b/kali-config/variant-mate/package-lists/kali.list.chroot @@ -1,24 +1,21 @@ -# Live image -# You always want these: +## Live image with MATE and default tools +## +## $ ./build.sh --variant mate + +## Live images always want these kali-linux-core kali-desktop-live -# Metapackages -# You can customize the set of Kali metapackages (groups of tools) to install -# For the complete list see: https://tools.kali.org/kali-metapackages -#kali-linux-core -#kali-tools-top10 -kali-linux-default -#kali-linux-large -#kali-linux-everything - -# Graphical desktop +## Graphical desktop +## For the complete list see: https://www.kali.org/docs/general-use/metapackages/ kali-desktop-mate -# | NOTE: With Kali 1.x, the mate desktop requires other changes to the live config. -# | See ~ https://web.archive.org/web/20150721230745/http://docs.kali.org/live-build/customize-the-kali-desktop-environment -#if DISTRIBUTION moto -mate-archive-keyring -#endif -# Kali applications +## Metapackages +## You can customize the set of Kali metapackages (groups of tools) to install +## For the complete list see: https://www.kali.org/tools/kali-meta/ +kali-linux-default + +## Extra Kali packages/tools/applications +## For the complete list see: https://www.kali.org/tools/ +## https://pkg.kali.org/ #<package> diff --git a/kali-config/variant-xfce-everything/package-lists/kali.list.chroot b/kali-config/variant-xfce-everything/package-lists/kali.list.chroot index 5c727b6..a043780 100644 --- a/kali-config/variant-xfce-everything/package-lists/kali.list.chroot +++ b/kali-config/variant-xfce-everything/package-lists/kali.list.chroot @@ -1,19 +1,21 @@ -# Live image -# You always want these: +## Live image with Xfce with "all" tools +## +## $ ./build.sh --variant xfce-everything + +## Live images always want these kali-linux-core kali-desktop-live -# Metapackages -# You can customize the set of Kali metapackages (groups of tools) to install -# For the complete list see: https://tools.kali.org/kali-metapackages -#kali-linux-core -#kali-tools-top10 -#kali-linux-default -#kali-linux-large -kali-linux-everything - -# Graphical desktop +## Graphical desktop +## For the complete list see: https://www.kali.org/docs/general-use/metapackages/ kali-desktop-xfce -# Kali applications +## Metapackages +## You can customize the set of Kali metapackages (groups of tools) to install +## For the complete list see: https://www.kali.org/tools/kali-meta/ +kali-linux-everything + +## Extra Kali packages/tools/applications +## For the complete list see: https://www.kali.org/tools/ +## https://pkg.kali.org/ #<package> diff --git a/kali-config/variant-xfce-large/package-lists/kali.list.chroot b/kali-config/variant-xfce-large/package-lists/kali.list.chroot index 386852a..4c43f5a 100644 --- a/kali-config/variant-xfce-large/package-lists/kali.list.chroot +++ b/kali-config/variant-xfce-large/package-lists/kali.list.chroot @@ -1,19 +1,21 @@ -# Live image -# You always want these: +## Live image with Xfce and large tool selection +## +## $ ./build.sh --variant xfce-large + +## Live images always want these kali-linux-core kali-desktop-live -# Metapackages -# You can customize the set of Kali metapackages (groups of tools) to install -# For the complete list see: https://tools.kali.org/kali-metapackages -#kali-linux-core -#kali-tools-top10 -#kali-linux-default -kali-linux-large -#kali-linux-everything - -# Graphical desktop +## Graphical desktop +## For the complete list see: https://www.kali.org/docs/general-use/metapackages/ kali-desktop-xfce -# Kali applications +## Metapackages +## You can customize the set of Kali metapackages (groups of tools) to install +## For the complete list see: https://www.kali.org/tools/kali-meta/ +kali-linux-large + +## Extra Kali packages/tools/applications +## For the complete list see: https://www.kali.org/tools/ +## https://pkg.kali.org/ #<package> diff --git a/kali-config/variant-xfce-light/package-lists/kali.list.chroot b/kali-config/variant-xfce-light/package-lists/kali.list.chroot index da621b2..a8b793a 100644 --- a/kali-config/variant-xfce-light/package-lists/kali.list.chroot +++ b/kali-config/variant-xfce-light/package-lists/kali.list.chroot @@ -1,19 +1,21 @@ -# Live image -# You always want these: +## Live image with Xfce and nothing else +## +## $ ./build.sh --variant xfce-light + +## Live images always want these kali-linux-core kali-desktop-live -# Metapackages -# You can customize the set of Kali metapackages (groups of tools) to install -# For the complete list see: https://tools.kali.org/kali-metapackages -#kali-linux-core -#kali-tools-top10 -#kali-linux-default -#kali-linux-large -#kali-linux-everything - -# Graphical desktop +## Graphical desktop +## For the complete list see: https://www.kali.org/docs/general-use/metapackages/ kali-desktop-xfce -# Kali applications +## Metapackages +## You can customize the set of Kali metapackages (groups of tools) to install +## For the complete list see: https://www.kali.org/tools/kali-meta/ +#kali-linux-<selection> + +## Extra Kali packages/tools/applications +## For the complete list see: https://www.kali.org/tools/ +## https://pkg.kali.org/ #<package> diff --git a/kali-config/variant-xfce/package-lists/kali.list.chroot b/kali-config/variant-xfce/package-lists/kali.list.chroot index d08d2d8..9e30a89 100644 --- a/kali-config/variant-xfce/package-lists/kali.list.chroot +++ b/kali-config/variant-xfce/package-lists/kali.list.chroot @@ -1,19 +1,21 @@ -# Live image -# You always want these: +## Live image with Xfce and default tool selection +## +## $ ./build.sh --variant xfce-light + +## Live images always want these kali-linux-core kali-desktop-live -# Metapackages -# You can customize the set of Kali metapackages (groups of tools) to install -# For the complete list see: https://tools.kali.org/kali-metapackages -#kali-linux-core -#kali-tools-top10 -kali-linux-default -#kali-linux-large -#kali-linux-everything - -# Graphical desktop +## Graphical desktop +## For the complete list see: https://www.kali.org/docs/general-use/metapackages/ kali-desktop-xfce -# Kali applications +## Metapackages +## You can customize the set of Kali metapackages (groups of tools) to install +## For the complete list see: https://www.kali.org/tools/kali-meta/ +kali-linux-default + +## Extra Kali packages/tools/applications +## For the complete list see: https://www.kali.org/tools/ +## https://pkg.kali.org/ #<package> -- GitLab From fb95194293d61dbf095a31d0ec14785928df0d8e Mon Sep 17 00:00:00 2001 From: g0t mi1k <have.you.g0tmi1k@gmail.com> Date: Sun, 19 Jan 2025 15:41:20 +0000 Subject: [PATCH 06/15] Consistency: tabs to spaces --- auto/clean | 14 +- auto/config | 190 +++++++------- build.sh | 242 +++++++++--------- .../common/bootloaders/grub-pc/grub.cfg | 16 +- .../bootloaders/syslinux_common/live.cfg.in | 2 +- .../common/hooks/live/kali-hacks.chroot | 4 +- .../includes.binary/isolinux/stdmenu.cfg | 2 +- .../usr/lib/live/config/0031-kali-user-setup | 14 +- .../includes.installer/kali-finish-install | 44 ++-- 9 files changed, 264 insertions(+), 264 deletions(-) diff --git a/auto/clean b/auto/clean index 77cb682..3f78b8e 100755 --- a/auto/clean +++ b/auto/clean @@ -3,13 +3,13 @@ lb clean noauto "$@" rm -fv config/binary \ - config/bootstrap \ - config/chroot \ - config/common \ - config/source \ - config/package-lists/live.list.chroot + config/bootstrap \ + config/chroot \ + config/common \ + config/source \ + config/package-lists/live.list.chroot if [ -e config/hooks/ ]; then - find config/hooks/ -type l \ - | xargs --no-run-if-empty rm -f + find config/hooks/ -type l \ + | xargs --no-run-if-empty rm -f fi diff --git a/auto/config b/auto/config index ce9c71b..0d62a06 100755 --- a/auto/config +++ b/auto/config @@ -6,9 +6,9 @@ set -o pipefail # Bashism # You can put a local mirror here if you want (or you can set # it in .mirror) if [ -e .mirror ]; then - kali_mirror=$(cat .mirror) + kali_mirror=$(cat .mirror) else - kali_mirror=http://kali.download/kali + kali_mirror=http://kali.download/kali fi ### DO NOT EDIT THE REST OF THIS FILE ### @@ -21,93 +21,93 @@ arch=$(dpkg --print-architecture) dist="kali-rolling" lb_opts="" while [ $# -gt 0 ]; do - arg="$1" - case "$arg" in - -a|--arch|--architecture|--architectures) - arch="$2" - temp="$temp "'"'"$arg"'"' - temp="$temp "'"'"$2"'"' - shift - ;; - --distribution) - dist="$2" - shift - ;; - --variant) - variant="$2" - shift - ;; - -p|--proposed-updates) - enable_pu="1" - ;; - --) - # Skip the separator, it was added so that "lb config" - # doesn't barf on our own options, but now we are - # filtering them away assuming that the remaining ones - # are intended for lb config ! - ;; - *) - temp="$temp "'"'"$arg"'"' - ;; - esac - shift + arg="$1" + case "$arg" in + -a|--arch|--architecture|--architectures) + arch="$2" + temp="$temp "'"'"$arg"'"' + temp="$temp "'"'"$2"'"' + shift + ;; + --distribution) + dist="$2" + shift + ;; + --variant) + variant="$2" + shift + ;; + -p|--proposed-updates) + enable_pu="1" + ;; + --) + # Skip the separator, it was added so that "lb config" + # doesn't barf on our own options, but now we are + # filtering them away assuming that the remaining ones + # are intended for lb config ! + ;; + *) + temp="$temp "'"'"$arg"'"' + ;; + esac + shift done eval set -- "$temp" # Resolve release name dist=$(wget -q -O- $kali_mirror/dists/$dist/Release | awk '/^Codename:/ {print $2}') if [ -z "$dist" ]; then - echo "ERROR: Build release could not be resolved" - exit 1 + echo "ERROR: Build release could not be resolved" + exit 1 fi # live-build doesn't work if --parent-debian-distribution is unknown of # debian-cd => we have to put a symlink so that it deals with kali like sid if [ ! -e ${LIVE_BUILD:-/usr/share/live/build}/data/debian-cd/$dist ]; then - if [ -w ${LIVE_BUILD:-/usr/share/live/build}/data/debian-cd ]; then - ln -sf sid ${LIVE_BUILD:-/usr/share/live/build}/data/debian-cd/$dist - else - echo "ERROR: Run this first:" - echo "ln -sf sid ${LIVE_BUILD:-/usr/share/live/build}/data/debian-cd/$dist" - exit 1 - fi + if [ -w ${LIVE_BUILD:-/usr/share/live/build}/data/debian-cd ]; then + ln -sf sid ${LIVE_BUILD:-/usr/share/live/build}/data/debian-cd/$dist + else + echo "ERROR: Run this first:" + echo "ln -sf sid ${LIVE_BUILD:-/usr/share/live/build}/data/debian-cd/$dist" + exit 1 + fi fi # Define options that vary across architectures case "$arch" in - amd64) - lb_opts="$lb_opts --debian-installer live" - ;; - i386) - lb_opts="$lb_opts --debian-installer live --linux-flavours 686-pae" - ;; - arm64) - lb_opts="$lb_opts --bootloaders grub-efi --uefi-secure-boot disable" - ;; - armel|armhf) - lb_opts="$lb_opts --binary-images hdd --binary-filesystem ext4 --chroot-filesystem none" - ;; - *) - echo "WARNING: configuration not tested on arch $arch" >&2 - ;; + amd64) + lb_opts="$lb_opts --debian-installer live" + ;; + i386) + lb_opts="$lb_opts --debian-installer live --linux-flavours 686-pae" + ;; + arm64) + lb_opts="$lb_opts --bootloaders grub-efi --uefi-secure-boot disable" + ;; + armel|armhf) + lb_opts="$lb_opts --binary-images hdd --binary-filesystem ext4 --chroot-filesystem none" + ;; + *) + echo "WARNING: configuration not tested on arch $arch" >&2 + ;; esac # Define options that vary across distributions case "$dist" in - kali-last-snapshot) - # We don't want kali-last-snapshot to end up in the image, it - # should be replaced with kali-rolling - lb_opts="$lb_opts --distribution-binary kali-rolling" - lb_opts="$lb_opts --debootstrap-script /usr/share/debootstrap/scripts/kali-rolling" - ;; + kali-last-snapshot) + # We don't want kali-last-snapshot to end up in the image, it + # should be replaced with kali-rolling + lb_opts="$lb_opts --distribution-binary kali-rolling" + lb_opts="$lb_opts --debootstrap-script /usr/share/debootstrap/scripts/kali-rolling" + ;; esac # Setup configuration files from variant and options # Drop all files that a former run might have put into place for file in $(cd kali-config && find ./common ./variant-* -type f); do - file=${file#./*/} - rm -fv config/$file + file=${file#./*/} + rm -fv config/$file done rm -fv config/archives/kali-proposed-updates.list.* @@ -116,37 +116,37 @@ cp -rT kali-config/common config [ ! -d kali-config/variant-$variant ] || cp -rTL kali-config/variant-$variant config if [ -n "$enable_pu" ]; then - mkdir -p config/archives - echo "deb $kali_mirror $dist-proposed-updates main contrib non-free non-free-firmware" \ - > config/archives/kali-proposed-updates.list.chroot - echo "deb $public_kali_mirror $dist-proposed-updates main contrib non-free non-free-firmware" \ - > config/archives/kali-proposed-updates.list.binary + mkdir -p config/archives + echo "deb $kali_mirror $dist-proposed-updates main contrib non-free non-free-firmware" \ + > config/archives/kali-proposed-updates.list.chroot + echo "deb $public_kali_mirror $dist-proposed-updates main contrib non-free non-free-firmware" \ + > config/archives/kali-proposed-updates.list.binary fi lb config noauto \ - --apt-indices=false \ - --distribution "$dist" \ - --debian-installer-distribution "$dist" \ - --archive-areas "main contrib non-free non-free-firmware" \ - --debootstrap-options "--keyring=/usr/share/keyrings/kali-archive-keyring.gpg" \ - --keyring-packages kali-archive-keyring \ - --updates false \ - --backports false \ - --source false \ - --firmware-binary true \ - --firmware-chroot true \ - --mirror-bootstrap "$kali_mirror" \ - --mirror-debian-installer "$kali_mirror" \ - --mirror-binary "$public_kali_mirror" \ - --iso-application "Kali Linux" \ - --iso-publisher "Kali" \ - --iso-volume "Kali Live" \ - --linux-packages linux-image \ - --memtest memtest86+ \ - --bootappend-live "boot=live components quiet splash noeject" \ - --bootappend-live-failsafe "boot=live components noeject memtest noapic noapm nodma nomce nolapic nomodeset nosmp nosplash vga=normal" \ - --bootappend-install "net.ifnames=0" \ - --security false \ - --win32-loader false \ - $lb_opts \ - "$@" + --apt-indices=false \ + --distribution "$dist" \ + --debian-installer-distribution "$dist" \ + --archive-areas "main contrib non-free non-free-firmware" \ + --debootstrap-options "--keyring=/usr/share/keyrings/kali-archive-keyring.gpg" \ + --keyring-packages kali-archive-keyring \ + --updates false \ + --backports false \ + --source false \ + --firmware-binary true \ + --firmware-chroot true \ + --mirror-bootstrap "$kali_mirror" \ + --mirror-debian-installer "$kali_mirror" \ + --mirror-binary "$public_kali_mirror" \ + --iso-application "Kali Linux" \ + --iso-publisher "Kali" \ + --iso-volume "Kali Live" \ + --linux-packages linux-image \ + --memtest memtest86+ \ + --bootappend-live "boot=live components quiet splash noeject" \ + --bootappend-live-failsafe "boot=live components noeject memtest noapic noapm nodma nomce nolapic nomodeset nosmp nosplash vga=normal" \ + --bootappend-install "net.ifnames=0" \ + --security false \ + --win32-loader false \ + $lb_opts \ + "$@" diff --git a/build.sh b/build.sh index ed74220..d9ec793 100755 --- a/build.sh +++ b/build.sh @@ -17,111 +17,111 @@ DEBUG="" HOST_ARCH=$(dpkg --print-architecture) image_name() { - case "$KALI_ARCH" in - i386|amd64|arm64) - echo "live-image-$KALI_ARCH.hybrid.iso" - ;; - armel|armhf) - echo "live-image-$KALI_ARCH.img" - ;; - esac + case "$KALI_ARCH" in + i386|amd64|arm64) + echo "live-image-$KALI_ARCH.hybrid.iso" + ;; + armel|armhf) + echo "live-image-$KALI_ARCH.img" + ;; + esac } target_image_name() { - local arch=$1 - - IMAGE_NAME="$(image_name $arch)" - IMAGE_EXT="${IMAGE_NAME##*.}" - if [ "$IMAGE_EXT" = "$IMAGE_NAME" ]; then - IMAGE_EXT="img" - fi - if [ "$KALI_VARIANT" = "default" ]; then - echo "${TARGET_SUBDIR:+$TARGET_SUBDIR/}kali-linux-$KALI_VERSION-live-$KALI_ARCH.$IMAGE_EXT" - else - echo "${TARGET_SUBDIR:+$TARGET_SUBDIR/}kali-linux-$KALI_VERSION-live-$KALI_VARIANT-$KALI_ARCH.$IMAGE_EXT" - fi + local arch=$1 + + IMAGE_NAME="$(image_name $arch)" + IMAGE_EXT="${IMAGE_NAME##*.}" + if [ "$IMAGE_EXT" = "$IMAGE_NAME" ]; then + IMAGE_EXT="img" + fi + if [ "$KALI_VARIANT" = "default" ]; then + echo "${TARGET_SUBDIR:+$TARGET_SUBDIR/}kali-linux-$KALI_VERSION-live-$KALI_ARCH.$IMAGE_EXT" + else + echo "${TARGET_SUBDIR:+$TARGET_SUBDIR/}kali-linux-$KALI_VERSION-live-$KALI_VARIANT-$KALI_ARCH.$IMAGE_EXT" + fi } target_build_log() { - TARGET_IMAGE_NAME=$(target_image_name $1) - echo ${TARGET_IMAGE_NAME%.*}.log + TARGET_IMAGE_NAME=$(target_image_name $1) + echo ${TARGET_IMAGE_NAME%.*}.log } default_version() { - case "$1" in - kali-*) - echo "${1#kali-}" - ;; - *) - echo "$1" - ;; - esac + case "$1" in + kali-*) + echo "${1#kali-}" + ;; + *) + echo "$1" + ;; + esac } failure() { - echo "Build of $KALI_DIST/$KALI_VARIANT/$KALI_ARCH live image failed (see build.log for details)" >&2 - echo "Log: $BUILD_LOG" >&2 - exit 2 + echo "Build of $KALI_DIST/$KALI_VARIANT/$KALI_ARCH live image failed (see build.log for details)" >&2 + echo "Log: $BUILD_LOG" >&2 + exit 2 } run_and_log() { - if [ -n "$VERBOSE" ] || [ -n "$DEBUG" ]; then - printf "RUNNING:" >&2 - for _ in "$@"; do - [[ $_ =~ [[:space:]] ]] && printf " '%s'" "$_" || printf " %s" "$_" - done >&2 - printf "\n" >&2 - "$@" 2>&1 | tee -a "$BUILD_LOG" - else - "$@" >>"$BUILD_LOG" 2>&1 - fi - return $? + if [ -n "$VERBOSE" ] || [ -n "$DEBUG" ]; then + printf "RUNNING:" >&2 + for _ in "$@"; do + [[ $_ =~ [[:space:]] ]] && printf " '%s'" "$_" || printf " %s" "$_" + done >&2 + printf "\n" >&2 + "$@" 2>&1 | tee -a "$BUILD_LOG" + else + "$@" >>"$BUILD_LOG" 2>&1 + fi + return $? } debug() { - if [ -n "$DEBUG" ]; then - echo "DEBUG: $*" >&2 - fi + if [ -n "$DEBUG" ]; then + echo "DEBUG: $*" >&2 + fi } clean() { - debug "Cleaning" - - run_and_log $SUDO lb clean --purge - #run_and_log $SUDO umount -l $(pwd)/chroot/proc - #run_and_log $SUDO umount -l $(pwd)/chroot/dev/pts - #run_and_log $SUDO umount -l $(pwd)/chroot/sys - #run_and_log $SUDO rm -rf $(pwd)/chroot - #run_and_log $SUDO rm -rf $(pwd)/binary + debug "Cleaning" + + run_and_log $SUDO lb clean --purge + #run_and_log $SUDO umount -l $(pwd)/chroot/proc + #run_and_log $SUDO umount -l $(pwd)/chroot/dev/pts + #run_and_log $SUDO umount -l $(pwd)/chroot/sys + #run_and_log $SUDO rm -rf $(pwd)/chroot + #run_and_log $SUDO rm -rf $(pwd)/binary } print_help() { - echo "Usage: $0 [<option>...]" - echo - for x in $(echo "${BUILD_OPTS_LONG}" | sed 's_,_ _g'); do - x=$(echo $x | sed 's/:$/ <arg>/') - echo " --${x}" - done - echo - echo "More information: https://www.kali.org/docs/development/live-build-a-custom-kali-iso/" - exit 0 + echo "Usage: $0 [<option>...]" + echo + for x in $(echo "${BUILD_OPTS_LONG}" | sed 's_,_ _g'); do + x=$(echo $x | sed 's/:$/ <arg>/') + echo " --${x}" + done + echo + echo "More information: https://www.kali.org/docs/development/live-build-a-custom-kali-iso/" + exit 0 } require_package() { - local pkg=$1 - local required_version=$2 - local pkg_version= - - pkg_version=$(dpkg-query -f '${Version}' -W $pkg || true) - if [ -z "$pkg_version" ]; then - echo "ERROR: You need $pkg, but it is not installed" >&2 - exit 1 - fi - if dpkg --compare-versions "$pkg_version" lt "$required_version"; then - echo "ERROR: You need $pkg (>= $required_version), you have $pkg_version" >&2 - exit 1 - fi - debug "$pkg version: $pkg_version" + local pkg=$1 + local required_version=$2 + local pkg_version= + + pkg_version=$(dpkg-query -f '${Version}' -W $pkg || true) + if [ -z "$pkg_version" ]; then + echo "ERROR: You need $pkg, but it is not installed" >&2 + exit 1 + fi + if dpkg --compare-versions "$pkg_version" lt "$required_version"; then + echo "ERROR: You need $pkg (>= $required_version), you have $pkg_version" >&2 + exit 1 + fi + debug "$pkg version: $pkg_version" } # Allowed command line options @@ -136,56 +136,56 @@ debug "BUILD_LOG: $BUILD_LOG" temp=$(getopt -o "$BUILD_OPTS_SHORT" -l "$BUILD_OPTS_LONG,get-image-path" -- "$@") eval set -- "$temp" while true; do - case "$1" in - -d|--distribution) KALI_DIST="$2"; shift 2; ;; - -p|--proposed-updates) OPT_pu="1"; shift 1; ;; - -a|--arch) KALI_ARCH="$2"; shift 2; ;; - -v|--verbose) VERBOSE="1"; shift 1; ;; - -D|--debug) DEBUG="1"; shift 1; ;; - -h|--help) print_help; ;; - --variant) KALI_VARIANT="$2"; shift 2; ;; - --version) KALI_VERSION="$2"; shift 2; ;; - --subdir) TARGET_SUBDIR="$2"; shift 2; ;; - --get-image-path) ACTION="get-image-path"; shift 1; ;; - --clean) ACTION="clean"; shift 1; ;; - --no-clean) NO_CLEAN="1"; shift 1 ;; - --) shift; break; ;; - *) echo "ERROR: Invalid command-line option: $1" >&2; exit 1; ;; - esac + case "$1" in + -d|--distribution) KALI_DIST="$2"; shift 2; ;; + -p|--proposed-updates) OPT_pu="1"; shift 1; ;; + -a|--arch) KALI_ARCH="$2"; shift 2; ;; + -v|--verbose) VERBOSE="1"; shift 1; ;; + -D|--debug) DEBUG="1"; shift 1; ;; + -h|--help) print_help; ;; + --variant) KALI_VARIANT="$2"; shift 2; ;; + --version) KALI_VERSION="$2"; shift 2; ;; + --subdir) TARGET_SUBDIR="$2"; shift 2; ;; + --get-image-path) ACTION="get-image-path"; shift 1; ;; + --clean) ACTION="clean"; shift 1; ;; + --no-clean) NO_CLEAN="1"; shift 1 ;; + --) shift; break; ;; + *) echo "ERROR: Invalid command-line option: $1" >&2; exit 1; ;; + esac done # Set default values KALI_ARCH=${KALI_ARCH:-$HOST_ARCH} if [ "$KALI_ARCH" = "x64" ]; then - KALI_ARCH="amd64" + KALI_ARCH="amd64" elif [ "$KALI_ARCH" = "x86" ]; then - KALI_ARCH="i386" + KALI_ARCH="i386" fi debug "KALI_ARCH: $KALI_ARCH" if [ -z "$KALI_VERSION" ]; then - KALI_VERSION="$(default_version $KALI_DIST)" + KALI_VERSION="$(default_version $KALI_DIST)" fi debug "KALI_VERSION: $KALI_VERSION" # Check parameters debug "HOST_ARCH: $HOST_ARCH" if [ "$HOST_ARCH" != "$KALI_ARCH" ]; then - case "$HOST_ARCH/$KALI_ARCH" in - amd64/i386|i386/amd64) - ;; - *) - echo "Can't build $KALI_ARCH image on $HOST_ARCH system." >&2 - exit 1 - ;; - esac + case "$HOST_ARCH/$KALI_ARCH" in + amd64/i386|i386/amd64) + ;; + *) + echo "Can't build $KALI_ARCH image on $HOST_ARCH system." >&2 + exit 1 + ;; + esac fi # Build parameters for lb config KALI_CONFIG_OPTS="--distribution $KALI_DIST -- --variant $KALI_VARIANT" if [ -n "$OPT_pu" ]; then - KALI_CONFIG_OPTS="$KALI_CONFIG_OPTS --proposed-updates" - KALI_DIST="$KALI_DIST+pu" + KALI_CONFIG_OPTS="$KALI_CONFIG_OPTS --proposed-updates" + KALI_DIST="$KALI_DIST+pu" fi debug "KALI_CONFIG_OPTS: $KALI_CONFIG_OPTS" debug "KALI_DIST: $KALI_DIST" @@ -195,27 +195,27 @@ export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" debug "PATH: $PATH" if grep -q -e "^ID=debian" -e "^ID_LIKE=debian" /usr/lib/os-release; then - debug "OS: $( . /usr/lib/os-release && echo $NAME $VERSION )" + debug "OS: $( . /usr/lib/os-release && echo $NAME $VERSION )" elif [ -e /etc/debian_version ]; then - debug "OS: $( cat /etc/debian_version )" + debug "OS: $( cat /etc/debian_version )" else - echo "ERROR: Non Debian-based OS" >&2 + echo "ERROR: Non Debian-based OS" >&2 fi if [ ! -d "$(dirname $0)/kali-config/variant-$KALI_VARIANT" ]; then - echo "ERROR: Unknown variant of Kali live configuration: $KALI_VARIANT" >&2 + echo "ERROR: Unknown variant of Kali live configuration: $KALI_VARIANT" >&2 fi require_package live-build "1:20230502+kali4" require_package debootstrap "1.0.97" # We need root rights at some point if [ "$(whoami)" != "root" ]; then - if ! which $SUDO >/dev/null; then - echo "ERROR: $0 is not run as root and $SUDO is not available" >&2 - exit 1 - fi + if ! which $SUDO >/dev/null; then + echo "ERROR: $0 is not run as root and $SUDO is not available" >&2 + exit 1 + fi else - SUDO="" # We're already root + SUDO="" # We're already root fi debug "SUDO: $SUDO" @@ -224,15 +224,15 @@ debug "IMAGE_NAME: $IMAGE_NAME" debug "ACTION: $ACTION" if [ "$ACTION" = "get-image-path" ]; then - echo $(target_image_name $KALI_ARCH) - exit 0 + echo $(target_image_name $KALI_ARCH) + exit 0 fi if [ "$NO_CLEAN" = "" ]; then - clean + clean fi if [ "$ACTION" = "clean" ]; then - exit 0 + exit 0 fi cd $(dirname $0) @@ -248,7 +248,7 @@ run_and_log lb config -a $KALI_ARCH $KALI_CONFIG_OPTS "$@" debug "Stage 2/2 - Build" run_and_log $SUDO lb build if [ $? -ne 0 ] || [ ! -e $IMAGE_NAME ]; then - failure + failure fi # If a command fails, make the whole script exit diff --git a/kali-config/common/bootloaders/grub-pc/grub.cfg b/kali-config/common/bootloaders/grub-pc/grub.cfg index 1467e01..751d3c2 100644 --- a/kali-config/common/bootloaders/grub-pc/grub.cfg +++ b/kali-config/common/bootloaders/grub-pc/grub.cfg @@ -5,16 +5,16 @@ source /boot/grub/config.cfg LINUX_LIVE menuentry "Live system (@FLAVOUR_LIVE@ forensic mode)" { - linux @KERNEL_LIVE@ @APPEND_LIVE@ noswap noautomount - initrd @INITRD_LIVE@ + linux @KERNEL_LIVE@ @APPEND_LIVE@ noswap noautomount + initrd @INITRD_LIVE@ } menuentry "Live system with USB persistence (check kali.org/prst)" { - linux @KERNEL_LIVE@ @APPEND_LIVE@ persistence - initrd @INITRD_LIVE@ + linux @KERNEL_LIVE@ @APPEND_LIVE@ persistence + initrd @INITRD_LIVE@ } menuentry "Live system with USB Encrypted persistence" { - linux @KERNEL_LIVE@ @APPEND_LIVE@ persistent=cryptsetup persistence-encryption=luks persistence - initrd @INITRD_LIVE@ + linux @KERNEL_LIVE@ @APPEND_LIVE@ persistent=cryptsetup persistence-encryption=luks persistence + initrd @INITRD_LIVE@ } # Installer (if any) @@ -22,8 +22,8 @@ LINUX_INSTALL if [ ! -e /boot/grub/install.cfg ]; then menuentry "Start installer with speech synthesis" { - linux @KERNEL_GI@ speakup.synth=soft @APPEND_GI@ - initrd @INITRD_GI@ + linux @KERNEL_GI@ speakup.synth=soft @APPEND_GI@ + initrd @INITRD_GI@ } fi diff --git a/kali-config/common/bootloaders/syslinux_common/live.cfg.in b/kali-config/common/bootloaders/syslinux_common/live.cfg.in index ebe20e5..8b8a263 100644 --- a/kali-config/common/bootloaders/syslinux_common/live.cfg.in +++ b/kali-config/common/bootloaders/syslinux_common/live.cfg.in @@ -24,7 +24,7 @@ label live-persistence append boot=live username=kali hostname=kali persistence label live-encrypted-persistence - menu label Live system with USB ^Encrypted persistence + menu label Live system with USB ^Encrypted persistence linux @LINUX@ initrd @INITRD@ append boot=live persistent=cryptsetup persistence-encryption=luks username=kali hostname=kali persistence diff --git a/kali-config/common/hooks/live/kali-hacks.chroot b/kali-config/common/hooks/live/kali-hacks.chroot index bde4ac4..95d53ff 100755 --- a/kali-config/common/hooks/live/kali-hacks.chroot +++ b/kali-config/common/hooks/live/kali-hacks.chroot @@ -10,9 +10,9 @@ fi # This is until https://bugs.debian.org/908220 has a proper fix. if [ -e /etc/cryptsetup-initramfs/conf-hook ]; then if grep -q '^#CRYPTSETUP=' /etc/cryptsetup-initramfs/conf-hook; then - sed -i -e 's/^#CRYPTSETUP=.*/CRYPTSETUP=y/' /etc/cryptsetup-initramfs/conf-hook + sed -i -e 's/^#CRYPTSETUP=.*/CRYPTSETUP=y/' /etc/cryptsetup-initramfs/conf-hook else - echo "CRYPTSETUP=y" >>/etc/cryptsetup-initramfs/conf-hook + echo "CRYPTSETUP=y" >>/etc/cryptsetup-initramfs/conf-hook fi fi diff --git a/kali-config/common/includes.binary/isolinux/stdmenu.cfg b/kali-config/common/includes.binary/isolinux/stdmenu.cfg index ffdb150..74bc6f1 100644 --- a/kali-config/common/includes.binary/isolinux/stdmenu.cfg +++ b/kali-config/common/includes.binary/isolinux/stdmenu.cfg @@ -1,4 +1,4 @@ -menu background splash.png +menu background splash.png menu color title * #FFFFFFFF * menu color border * #00000000 #00000000 none menu color sel * #ffffffff #26ffffff none diff --git a/kali-config/common/includes.chroot/usr/lib/live/config/0031-kali-user-setup b/kali-config/common/includes.chroot/usr/lib/live/config/0031-kali-user-setup index f7d2093..7c95556 100755 --- a/kali-config/common/includes.chroot/usr/lib/live/config/0031-kali-user-setup +++ b/kali-config/common/includes.chroot/usr/lib/live/config/0031-kali-user-setup @@ -3,11 +3,11 @@ configure_zsh() { # Stop if zsh is not present if [ ! -x /usr/bin/zsh ]; then - return + return fi # Stop if user has opted out of zsh if echo "${LIVE_CONFIG_CMDLINE}" | grep -qs 'nozsh'; then - return + return fi chsh --shell /usr/bin/zsh kali chsh --shell /usr/bin/zsh root @@ -26,8 +26,8 @@ configure_usergroups() { kali_groups="adm dialout kaboxer vboxsf wireshark" for grp in $kali_groups; do - getent group $grp >/dev/null || continue - usermod -a -G $grp kali + getent group $grp >/dev/null || continue + usermod -a -G $grp kali done } @@ -37,9 +37,9 @@ pkg_installed() { configure_terminal() { while read -r desktop terminal; do - pkg_installed kali-desktop-$desktop || continue - update-alternatives --verbose --set x-terminal-emulator /usr/bin/$terminal || true - break + pkg_installed kali-desktop-$desktop || continue + update-alternatives --verbose --set x-terminal-emulator /usr/bin/$terminal || true + break done <<END e17 terminology gnome gnome-terminal.wrapper diff --git a/kali-config/common/includes.installer/kali-finish-install b/kali-config/common/includes.installer/kali-finish-install index cbc188a..21ea79d 100755 --- a/kali-config/common/includes.installer/kali-finish-install +++ b/kali-config/common/includes.installer/kali-finish-install @@ -9,8 +9,8 @@ configure_sources_list() { if grep -q '^deb ' /etc/apt/sources.list; then - echo "INFO: sources.list is configured, everything is fine" - return + echo "INFO: sources.list is configured, everything is fine" + return fi echo "INFO: sources.list is empty, setting up a default one for Kali" @@ -27,27 +27,27 @@ END get_user_list() { for user in $(cd /home && ls); do - if ! getent passwd "$user" >/dev/null; then - echo "WARNING: user '$user' is invalid but /home/$user exists" >&2 - continue - fi - echo "$user" + if ! getent passwd "$user" >/dev/null; then + echo "WARNING: user '$user' is invalid but /home/$user exists" >&2 + continue + fi + echo "$user" done echo "root" } configure_zsh() { if grep -q 'nozsh' /proc/cmdline; then - echo "INFO: user opted out of zsh by default" - return + echo "INFO: user opted out of zsh by default" + return fi if [ ! -x /usr/bin/zsh ]; then - echo "INFO: /usr/bin/zsh is not available" - return + echo "INFO: /usr/bin/zsh is not available" + return fi for user in $(get_user_list); do - echo "INFO: changing default shell of user '$user' to zsh" - chsh --shell /usr/bin/zsh $user + echo "INFO: changing default shell of user '$user' to zsh" + chsh --shell /usr/bin/zsh $user done } @@ -64,11 +64,11 @@ configure_usergroups() { kali_groups="adm dialout kaboxer vboxsf wireshark" for user in $(get_user_list | grep -xv root); do - echo "INFO: adding user '$user' to groups '$kali_groups'" - for grp in $kali_groups; do - getent group $grp >/dev/null || continue - usermod -a -G $grp $user - done + echo "INFO: adding user '$user' to groups '$kali_groups'" + for grp in $kali_groups; do + getent group $grp >/dev/null || continue + usermod -a -G $grp $user + done done } @@ -78,10 +78,10 @@ pkg_installed() { configure_terminal() { while read -r desktop terminal; do - pkg_installed kali-desktop-$desktop || continue - echo "INFO: setting x-terminal-emulator alternative to '$terminal'" - update-alternatives --verbose --set x-terminal-emulator /usr/bin/$terminal || true - break + pkg_installed kali-desktop-$desktop || continue + echo "INFO: setting x-terminal-emulator alternative to '$terminal'" + update-alternatives --verbose --set x-terminal-emulator /usr/bin/$terminal || true + break done <<END e17 terminology gnome gnome-terminal.wrapper -- GitLab From 4e4382e8c1dd5a93a5aab0f3e4e2d01c88f50400 Mon Sep 17 00:00:00 2001 From: g0t mi1k <have.you.g0tmi1k@gmail.com> Date: Mon, 20 Jan 2025 06:57:58 +0000 Subject: [PATCH 07/15] Sync preseed files --- .../includes.installer/kali-finish-install | 7 ++-- .../common/includes.installer/preseed.cfg | 39 +++++++++++++++---- kali-config/common/preseed/kali.cfg.chroot | 9 +---- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/kali-config/common/includes.installer/kali-finish-install b/kali-config/common/includes.installer/kali-finish-install index 21ea79d..50a0151 100755 --- a/kali-config/common/includes.installer/kali-finish-install +++ b/kali-config/common/includes.installer/kali-finish-install @@ -1,7 +1,8 @@ #!/bin/sh - -# The reference version of this script is maintained in -# ./kali-live/kali-config/common/includes.installer/kali-finish-install +# +# The reference version of this script is maintained in: +# ./kali-installer/simple-cdd/profiles/kali.postinst +# ./kali-live/kali-config/common/includes.installer/kali-finish-install # # It is used in multiple places to finish configuring the target system # and build.sh copies it where required (in the simple-cdd configuration diff --git a/kali-config/common/includes.installer/preseed.cfg b/kali-config/common/includes.installer/preseed.cfg index 759c937..8a171aa 100644 --- a/kali-config/common/includes.installer/preseed.cfg +++ b/kali-config/common/includes.installer/preseed.cfg @@ -1,9 +1,19 @@ +# +# The reference version of this script is maintained in: +# ./kali-installer/simple-cdd/profiles/kali.preseed +# ./kali-live/kali-config/common/includes.installer/preseed.cfg +# +# Upstream: https://gitlab.com/kalilinux/packages/debian-installer/-/blob/kali/master/build/preseed.cfg +# + # This file replaces preseed.cfg embedded in the initrd by # debian-installer. It should be kept in sync except with the # mirror/{codename,suite} dropped so that the image installs # what's available on the CD instead of hardcoding a specific # release. +## Questions from debian-installer + # Default repository information (don't include codename data, d-i figures it # out from what's available in the ISO) d-i mirror/country string enter information manually @@ -44,7 +54,7 @@ d-i pkgsel/update-policy select none # Disable question about extra media d-i apt-setup/cdrom/set-first boolean false -## Questions from regular packages +## Questions from Debian's regular packages # Disable popularity-contest popularity-contest popularity-contest/participate boolean false @@ -53,15 +63,11 @@ popularity-contest popularity-contest/participate boolean false encfs encfs/security-information boolean true encfs encfs/security-information seen true -# Random other questions +## Random other questions console-setup console-setup/charmap47 select UTF-8 samba-common samba-common/dhcp boolean false -macchanger macchanger/automatically_run boolean false -kismet-capture-common kismet-capture-common/install-users string -kismet-capture-common kismet-capture-common/install-setuid boolean true -wireshark-common wireshark-common/install-setuid boolean true -sslh sslh/inetd_or_standalone select standalone -atftpd atftpd/use_inetd boolean false + +## Questions from Kali's packages # Defensive packages tripwire tripwire/installed boolean true @@ -70,3 +76,20 @@ tripwire tripwire/rebuild-config boolean false tripwire tripwire/rebuild-policy boolean false tripwire tripwire/use-localkey boolean false tripwire tripwire/use-sitekey boolean false + +# Do not register it in inetd so that its status can be controlled +# individually +atftpd atftpd/use_inetd boolean false + +# Install wireshark setuid +wireshark-common wireshark-common/install-setuid boolean true + +# Disable autorun with macchanger +macchanger macchanger/automatically_run boolean false + +# Install kismet setuid +kismet-capture-common kismet-capture-common/install-users string +kismet-capture-common kismet-capture-common/install-setuid boolean true + +# Use own process for sslh +sslh sslh/inetd_or_standalone select standalone diff --git a/kali-config/common/preseed/kali.cfg.chroot b/kali-config/common/preseed/kali.cfg.chroot index 7c1d27e..2fb75b3 100644 --- a/kali-config/common/preseed/kali.cfg.chroot +++ b/kali-config/common/preseed/kali.cfg.chroot @@ -1,7 +1,2 @@ -# Various preseeding for auto-installed packages - -# Do not register it in inetd so that its status can be controlled -# individually -atftpd atftpd/use_inetd boolean false -# Install wireshark setuid -wireshark-common wireshark-common/install-setuid boolean true +# May want to review: +# ./kali-config/common/includes.installer/preseed.cfg -- GitLab From 5dbdcad8ed73b6d5dc6eb1f304b782d260b4f851 Mon Sep 17 00:00:00 2001 From: g0t mi1k <have.you.g0tmi1k@gmail.com> Date: Mon, 20 Jan 2025 10:34:05 +0000 Subject: [PATCH 08/15] Add comments --- auto/config | 4 ++-- build.sh | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/auto/config b/auto/config index 0d62a06..557b0e3 100755 --- a/auto/config +++ b/auto/config @@ -3,8 +3,8 @@ set -e set -o pipefail # Bashism -# You can put a local mirror here if you want (or you can set -# it in .mirror) +# You can put a local mirror here if you want +# (or you can set it in .mirror) if [ -e .mirror ]; then kali_mirror=$(cat .mirror) else diff --git a/build.sh b/build.sh index d9ec793..464de13 100755 --- a/build.sh +++ b/build.sh @@ -16,6 +16,8 @@ VERBOSE="" DEBUG="" HOST_ARCH=$(dpkg --print-architecture) +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + image_name() { case "$KALI_ARCH" in i386|amd64|arm64) @@ -87,7 +89,7 @@ debug() { clean() { debug "Cleaning" - run_and_log $SUDO lb clean --purge + run_and_log $SUDO lb clean --purge # ./auto/clean #run_and_log $SUDO umount -l $(pwd)/chroot/proc #run_and_log $SUDO umount -l $(pwd)/chroot/dev/pts #run_and_log $SUDO umount -l $(pwd)/chroot/sys @@ -124,9 +126,12 @@ require_package() { debug "$pkg version: $pkg_version" } +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # Allowed command line options . $(dirname $0)/.getopt.sh +# Define log file BUILD_LOG="$(pwd)/build.log" debug "BUILD_LOG: $BUILD_LOG" # Create empty file @@ -236,17 +241,18 @@ if [ "$ACTION" = "clean" ]; then fi cd $(dirname $0) +# Create image output location mkdir -p $TARGET_DIR/$TARGET_SUBDIR # Don't quit on any errors now set +e -debug "Stage 1/2 - Config" +debug "Stage 1/2 - Config" # ./auto/config run_and_log lb config -a $KALI_ARCH $KALI_CONFIG_OPTS "$@" [ $? -eq 0 ] || failure debug "Stage 2/2 - Build" -run_and_log $SUDO lb build +run_and_log $SUDO lb build # ./auto/build... but missing for us if [ $? -ne 0 ] || [ ! -e $IMAGE_NAME ]; then failure fi -- GitLab From bd5b40620f348b938fb20a3a18545311222b4ebe Mon Sep 17 00:00:00 2001 From: g0t mi1k <have.you.g0tmi1k@gmail.com> Date: Mon, 20 Jan 2025 10:36:58 +0000 Subject: [PATCH 09/15] Show full path of output file --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 464de13..d1a2596 100755 --- a/build.sh +++ b/build.sh @@ -264,4 +264,4 @@ debug "Moving files" run_and_log mv -f $IMAGE_NAME $TARGET_DIR/$(target_image_name $KALI_ARCH) run_and_log mv -f "$BUILD_LOG" $TARGET_DIR/$(target_build_log $KALI_ARCH) -run_and_log echo -e "\n***\nGENERATED KALI IMAGE: $TARGET_DIR/$(target_image_name $KALI_ARCH)\n***" +run_and_log echo -e "\n***\nGENERATED KALI IMAGE: $(readlink -f $TARGET_DIR/$(target_image_name $KALI_ARCH))\n***" -- GitLab From 789854a9219a143e1856596309826b72ed4852d9 Mon Sep 17 00:00:00 2001 From: g0t mi1k <have.you.g0tmi1k@gmail.com> Date: Mon, 20 Jan 2025 10:37:43 +0000 Subject: [PATCH 10/15] Add error handling when trying to create folder --- build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index d1a2596..16f5e97 100755 --- a/build.sh +++ b/build.sh @@ -242,7 +242,8 @@ fi cd $(dirname $0) # Create image output location -mkdir -p $TARGET_DIR/$TARGET_SUBDIR +mkdir -pv $TARGET_DIR/$TARGET_SUBDIR +[ $? -eq 0 ] || failure # Don't quit on any errors now set +e -- GitLab From 61f2913e709b3fcbcadf6287b9534cb74e804736 Mon Sep 17 00:00:00 2001 From: g0t mi1k <have.you.g0tmi1k@gmail.com> Date: Mon, 20 Jan 2025 10:38:31 +0000 Subject: [PATCH 11/15] Change directory as soon as possible --- build.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 16f5e97..2ffff8c 100755 --- a/build.sh +++ b/build.sh @@ -128,14 +128,16 @@ require_package() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Allowed command line options -. $(dirname $0)/.getopt.sh +# Change directory into where the script is +cd $(dirname $0)/ # Define log file BUILD_LOG="$(pwd)/build.log" debug "BUILD_LOG: $BUILD_LOG" # Create empty file : > "$BUILD_LOG" +# Allowed command line options +source .getopt.sh # Parsing command line options (see .getopt.sh) temp=$(getopt -o "$BUILD_OPTS_SHORT" -l "$BUILD_OPTS_LONG,get-image-path" -- "$@") @@ -240,7 +242,6 @@ if [ "$ACTION" = "clean" ]; then exit 0 fi -cd $(dirname $0) # Create image output location mkdir -pv $TARGET_DIR/$TARGET_SUBDIR [ $? -eq 0 ] || failure -- GitLab From 3d6141b8775a576c552af15b8a88ab12ae64b77b Mon Sep 17 00:00:00 2001 From: g0t mi1k <have.you.g0tmi1k@gmail.com> Date: Mon, 20 Jan 2025 10:39:14 +0000 Subject: [PATCH 12/15] Move log, so --help doesn't trigger --- build.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index 2ffff8c..1e56994 100755 --- a/build.sh +++ b/build.sh @@ -131,11 +131,6 @@ require_package() { # Change directory into where the script is cd $(dirname $0)/ -# Define log file -BUILD_LOG="$(pwd)/build.log" -debug "BUILD_LOG: $BUILD_LOG" -# Create empty file -: > "$BUILD_LOG" # Allowed command line options source .getopt.sh @@ -161,6 +156,12 @@ while true; do esac done +# Define log file +BUILD_LOG="$(pwd)/build.log" +debug "BUILD_LOG: $BUILD_LOG" +# Create empty file +: > "$BUILD_LOG" + # Set default values KALI_ARCH=${KALI_ARCH:-$HOST_ARCH} if [ "$KALI_ARCH" = "x64" ]; then @@ -266,4 +267,4 @@ debug "Moving files" run_and_log mv -f $IMAGE_NAME $TARGET_DIR/$(target_image_name $KALI_ARCH) run_and_log mv -f "$BUILD_LOG" $TARGET_DIR/$(target_build_log $KALI_ARCH) -run_and_log echo -e "\n***\nGENERATED KALI IMAGE: $(readlink -f $TARGET_DIR/$(target_image_name $KALI_ARCH))\n***" +echo -e "\n***\nGENERATED KALI IMAGE: $(readlink -f $TARGET_DIR/$(target_image_name $KALI_ARCH))\n***" -- GitLab From 82780ef866a916947dce17f0d06d8e2ff4c8e8fe Mon Sep 17 00:00:00 2001 From: g0t mi1k <have.you.g0tmi1k@gmail.com> Date: Mon, 20 Jan 2025 10:39:28 +0000 Subject: [PATCH 13/15] Hide output if package doesn't exists --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 1e56994..74d5af7 100755 --- a/build.sh +++ b/build.sh @@ -114,7 +114,7 @@ require_package() { local required_version=$2 local pkg_version= - pkg_version=$(dpkg-query -f '${Version}' -W $pkg || true) + pkg_version=$(dpkg-query -f '${Version}' -W $pkg 2>/dev/null || true) if [ -z "$pkg_version" ]; then echo "ERROR: You need $pkg, but it is not installed" >&2 exit 1 -- GitLab From 7f241a3c73d592a9dac011209a37c892422502ed Mon Sep 17 00:00:00 2001 From: g0t mi1k <have.you.g0tmi1k@gmail.com> Date: Mon, 20 Jan 2025 10:40:14 +0000 Subject: [PATCH 14/15] Keep output consistency by dropping full stop --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 74d5af7..bce558c 100755 --- a/build.sh +++ b/build.sh @@ -183,7 +183,7 @@ if [ "$HOST_ARCH" != "$KALI_ARCH" ]; then amd64/i386|i386/amd64) ;; *) - echo "Can't build $KALI_ARCH image on $HOST_ARCH system." >&2 + echo "Can't build $KALI_ARCH image on $HOST_ARCH system" >&2 exit 1 ;; esac -- GitLab From a9d7f357abd17911af27e7883d7f3db1aa05a9b1 Mon Sep 17 00:00:00 2001 From: g0t mi1k <have.you.g0tmi1k@gmail.com> Date: Mon, 20 Jan 2025 10:40:48 +0000 Subject: [PATCH 15/15] Keep consistency with lines --- auto/clean | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/auto/clean b/auto/clean index 3f78b8e..e53a096 100755 --- a/auto/clean +++ b/auto/clean @@ -2,7 +2,8 @@ lb clean noauto "$@" -rm -fv config/binary \ +rm -fv \ + config/binary \ config/bootstrap \ config/chroot \ config/common \ -- GitLab