From e470475f021f1a7e91e46c61ab68a01c4bd631eb Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 11 May 2021 15:18:12 +0100 Subject: [PATCH 01/46] Update default generated files --- .../includes.installer/kali-finish-install | 25 ++++++++++++------- simple-cdd/profiles/kali.postinst | 25 ++++++++++++------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/kali-config/common/includes.installer/kali-finish-install b/kali-config/common/includes.installer/kali-finish-install index 462ba03..1aaac7a 100755 --- a/kali-config/common/includes.installer/kali-finish-install +++ b/kali-config/common/includes.installer/kali-finish-install @@ -51,17 +51,24 @@ configure_zsh() { done } -configure_kaboxer() { - # Create the group if needed - addgroup --system kaboxer || true +# This is generically named in case we want to add other groups in the future. +configure_usergroups() { + # Create the kaboxer group if needed + addgroup --system kaboxer || true + # Create the wireshark group if needed + addgroup --system wireshark || true - # Add the users to the group - for user in $(get_user_list); do - echo "INFO: adding user '$user' to group 'kaboxer'" - adduser $user kaboxer || true - done + # kaboxer - for kaboxer + # dialout - for serial access + # wireshark - capture sessions in wireshark + kali_groups="kaboxer,dialout,wireshark" + + for user in $(get_user_list); do + echo "INFO: adding user '$user' to groups '$kali_groups'" + usermod -a -G "$kali_groups" $user || true + done } configure_sources_list configure_zsh -configure_kaboxer +configure_usergroups diff --git a/simple-cdd/profiles/kali.postinst b/simple-cdd/profiles/kali.postinst index 462ba03..1aaac7a 100755 --- a/simple-cdd/profiles/kali.postinst +++ b/simple-cdd/profiles/kali.postinst @@ -51,17 +51,24 @@ configure_zsh() { done } -configure_kaboxer() { - # Create the group if needed - addgroup --system kaboxer || true +# This is generically named in case we want to add other groups in the future. +configure_usergroups() { + # Create the kaboxer group if needed + addgroup --system kaboxer || true + # Create the wireshark group if needed + addgroup --system wireshark || true - # Add the users to the group - for user in $(get_user_list); do - echo "INFO: adding user '$user' to group 'kaboxer'" - adduser $user kaboxer || true - done + # kaboxer - for kaboxer + # dialout - for serial access + # wireshark - capture sessions in wireshark + kali_groups="kaboxer,dialout,wireshark" + + for user in $(get_user_list); do + echo "INFO: adding user '$user' to groups '$kali_groups'" + usermod -a -G "$kali_groups" $user || true + done } configure_sources_list configure_zsh -configure_kaboxer +configure_usergroups From 2854f83f2f80f08b613f149abaef8534853cc6e6 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 11 May 2021 15:19:39 +0100 Subject: [PATCH 02/46] Make consistent for desktop environment live images --- .../variant-e17/package-lists/kali.list.chroot | 16 ++++++++++------ .../variant-gnome/package-lists/kali.list.chroot | 16 ++++++++++------ .../variant-i3wm/package-lists/kali.list.chroot | 16 ++++++++++------ .../variant-kde/package-lists/kali.list.chroot | 16 ++++++++++------ .../variant-large/package-lists/kali.list.chroot | 16 ++++++++++------ .../variant-light/package-lists/kali.list.chroot | 13 +++++++++++-- .../variant-lxde/package-lists/kali.list.chroot | 16 ++++++++++------ .../variant-mate/package-lists/kali.list.chroot | 16 ++++++++++------ .../variant-xfce/package-lists/kali.list.chroot | 16 ++++++++++------ 9 files changed, 91 insertions(+), 50 deletions(-) diff --git a/kali-config/variant-e17/package-lists/kali.list.chroot b/kali-config/variant-e17/package-lists/kali.list.chroot index fb18b57..3dd480d 100644 --- a/kali-config/variant-e17/package-lists/kali.list.chroot +++ b/kali-config/variant-e17/package-lists/kali.list.chroot @@ -1,15 +1,19 @@ -# You always want those +# Live image +# You always want these: kali-linux-core kali-desktop-live -# Kali applications -# +# 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 -# kali-tools-top10 +#kali-linux-large +#kali-linux-everything # Graphical desktop kali-desktop-e17 + +# Kali applications +# diff --git a/kali-config/variant-gnome/package-lists/kali.list.chroot b/kali-config/variant-gnome/package-lists/kali.list.chroot index 03c692d..672be48 100644 --- a/kali-config/variant-gnome/package-lists/kali.list.chroot +++ b/kali-config/variant-gnome/package-lists/kali.list.chroot @@ -1,15 +1,19 @@ -# You always want those +# Live image +# You always want these: kali-linux-core kali-desktop-live -# Kali applications -# +# 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 -# kali-tools-top10 +#kali-linux-large +#kali-linux-everything # Graphical desktop kali-desktop-gnome + +# Kali applications +# diff --git a/kali-config/variant-i3wm/package-lists/kali.list.chroot b/kali-config/variant-i3wm/package-lists/kali.list.chroot index 0cb1002..9d8c491 100644 --- a/kali-config/variant-i3wm/package-lists/kali.list.chroot +++ b/kali-config/variant-i3wm/package-lists/kali.list.chroot @@ -1,15 +1,19 @@ -# You always want those +# Live image +# You always want these: kali-linux-core kali-desktop-live -# Kali applications -# +# 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 -# kali-tools-top10 +#kali-linux-large +#kali-linux-everything # Graphical desktop kali-desktop-i3 + +# Kali applications +# diff --git a/kali-config/variant-kde/package-lists/kali.list.chroot b/kali-config/variant-kde/package-lists/kali.list.chroot index 2393ed5..a611035 100644 --- a/kali-config/variant-kde/package-lists/kali.list.chroot +++ b/kali-config/variant-kde/package-lists/kali.list.chroot @@ -1,15 +1,19 @@ -# You always want those +# Live image +# You always want these: kali-linux-core kali-desktop-live -# Kali applications -# +# 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 -# kali-tools-top10 +#kali-linux-large +#kali-linux-everything # Graphical desktop kali-desktop-kde + +# Kali applications +# diff --git a/kali-config/variant-large/package-lists/kali.list.chroot b/kali-config/variant-large/package-lists/kali.list.chroot index 8ba636c..386852a 100644 --- a/kali-config/variant-large/package-lists/kali.list.chroot +++ b/kali-config/variant-large/package-lists/kali.list.chroot @@ -1,15 +1,19 @@ -# You always want those +# Live image +# You always want these: kali-linux-core kali-desktop-live -# Kali applications -# +# 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-default +#kali-linux-core +#kali-tools-top10 +#kali-linux-default kali-linux-large -# kali-linux-everything -# kali-tools-top10 +#kali-linux-everything # Graphical desktop kali-desktop-xfce + +# Kali applications +# diff --git a/kali-config/variant-light/package-lists/kali.list.chroot b/kali-config/variant-light/package-lists/kali.list.chroot index bdcb590..da621b2 100644 --- a/kali-config/variant-light/package-lists/kali.list.chroot +++ b/kali-config/variant-light/package-lists/kali.list.chroot @@ -1,10 +1,19 @@ -# You always want those +# Live image +# You always want these: kali-linux-core kali-desktop-live -# Kali applications +# 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 kali-desktop-xfce + +# Kali applications +# diff --git a/kali-config/variant-lxde/package-lists/kali.list.chroot b/kali-config/variant-lxde/package-lists/kali.list.chroot index 6efcb0d..599e91b 100644 --- a/kali-config/variant-lxde/package-lists/kali.list.chroot +++ b/kali-config/variant-lxde/package-lists/kali.list.chroot @@ -1,15 +1,19 @@ -# You always want those +# Live image +# You always want these: kali-linux-core kali-desktop-live -# Kali applications -# +# 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 -# kali-tools-top10 +#kali-linux-large +#kali-linux-everything # Graphical desktop kali-desktop-lxde + +# Kali applications +# diff --git a/kali-config/variant-mate/package-lists/kali.list.chroot b/kali-config/variant-mate/package-lists/kali.list.chroot index fa8613a..b8b9192 100644 --- a/kali-config/variant-mate/package-lists/kali.list.chroot +++ b/kali-config/variant-mate/package-lists/kali.list.chroot @@ -1,15 +1,16 @@ -# You always want those +# Live image +# You always want these: kali-linux-core kali-desktop-live -# Kali applications -# +# 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 -# kali-tools-top10 +#kali-linux-large +#kali-linux-everything # Graphical desktop kali-desktop-mate @@ -18,3 +19,6 @@ kali-desktop-mate #if DISTRIBUTION moto mate-archive-keyring #endif + +# Kali applications +# diff --git a/kali-config/variant-xfce/package-lists/kali.list.chroot b/kali-config/variant-xfce/package-lists/kali.list.chroot index c017a59..d08d2d8 100644 --- a/kali-config/variant-xfce/package-lists/kali.list.chroot +++ b/kali-config/variant-xfce/package-lists/kali.list.chroot @@ -1,15 +1,19 @@ -# You always want those +# Live image +# You always want these: kali-linux-core kali-desktop-live -# Kali applications -# +# 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 -# kali-tools-top10 +#kali-linux-large +#kali-linux-everything # Graphical desktop kali-desktop-xfce + +# Kali applications +# From 15076bb3d306048f408530af0e7a988a5516457e Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 11 May 2021 15:19:56 +0100 Subject: [PATCH 03/46] Make consistent for live and installer images --- kali-config/installer-default/packages | 11 ++++++----- kali-config/installer-netinst/packages | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/kali-config/installer-default/packages b/kali-config/installer-default/packages index 11c5f5c..5b4d692 100644 --- a/kali-config/installer-default/packages +++ b/kali-config/installer-default/packages @@ -1,8 +1,11 @@ -# Full installer image, it should contain everything offered in tasksel -# during initial installation so all kali-linux-* except -# kali-linux-everything and most desktops. +# 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) to install +# For the complete list see: https://tools.kali.org/kali-metapackages kali-linux-core kali-tools-top10 kali-linux-default @@ -12,5 +15,3 @@ kali-linux-large kali-desktop-xfce kali-desktop-gnome kali-desktop-kde -kali-desktop-lxde -kali-desktop-mate diff --git a/kali-config/installer-netinst/packages b/kali-config/installer-netinst/packages index 2894671..f36f70a 100644 --- a/kali-config/installer-netinst/packages +++ b/kali-config/installer-netinst/packages @@ -1,3 +1,4 @@ +# 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 From 01639825e0e99a4a6d8e51df0ef1e49930aa316d Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 11 May 2021 15:20:11 +0100 Subject: [PATCH 04/46] Remove un-used space --- kali-config/common/hooks/live/persistence-menu.binary | 1 - 1 file changed, 1 deletion(-) diff --git a/kali-config/common/hooks/live/persistence-menu.binary b/kali-config/common/hooks/live/persistence-menu.binary index 1013283..4151553 100755 --- a/kali-config/common/hooks/live/persistence-menu.binary +++ b/kali-config/common/hooks/live/persistence-menu.binary @@ -19,4 +19,3 @@ label live-encrypted-persistence append boot=live persistent=cryptsetup persistence-encryption=luks username=kali hostname=kali persistence END - From 0f0a9c5a0453dd5be285b313e86cd051282c21c5 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 11 May 2021 15:20:55 +0100 Subject: [PATCH 05/46] Make boot options more consistent for live & installer images --- kali-config/common/bootloaders/grub-pc/grub.cfg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kali-config/common/bootloaders/grub-pc/grub.cfg b/kali-config/common/bootloaders/grub-pc/grub.cfg index 1c2f834..92eea9b 100644 --- a/kali-config/common/bootloaders/grub-pc/grub.cfg +++ b/kali-config/common/bootloaders/grub-pc/grub.cfg @@ -3,15 +3,15 @@ source /boot/grub/config.cfg # Live boot LINUX_LIVE -menuentry "Live system (forensic mode)" { +menuentry "Live (forensic mode)" { linux KERNEL_LIVE APPEND_LIVE noswap noautomount initrd INITRD_LIVE } -menuentry "Live system (persistence, check kali.org/prst)" { +menuentry "Live USB Persistence (check kali.org/prst)" { linux KERNEL_LIVE APPEND_LIVE persistence initrd INITRD_LIVE } -menuentry "Live system (encrypted persistence, check kali.org/prst)" { +menuentry "Live USB Encrypted Persistence (check kali.org/prst)" { linux KERNEL_LIVE APPEND_LIVE persistent=cryptsetup persistence-encryption=luks persistence initrd INITRD_LIVE } @@ -26,7 +26,7 @@ menuentry "Start installer with speech synthesis" { } fi -submenu 'Advanced options...' { +submenu 'Advanced options' { source /boot/grub/theme.cfg From 305d006cb6a7b8bfe4e201d61dc8e9bcb7ac9a9e Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 11 May 2021 15:23:49 +0100 Subject: [PATCH 06/46] Add comments to build.sh --- build.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.sh b/build.sh index b2ea340..7ce08de 100755 --- a/build.sh +++ b/build.sh @@ -1,8 +1,11 @@ #!/bin/bash +# If a command fails, make the whole script exit set -e set -o pipefail # Bashism +# Use return code for any command errors in part of a pipe +# Kali's default values KALI_DIST="kali-rolling" KALI_VERSION="" KALI_VARIANT="default" @@ -97,6 +100,7 @@ run_and_log() { return $? } +# Allowed command line options . $(dirname $0)/.getopt.sh # Parsing command line options @@ -203,6 +207,7 @@ cd $(dirname $0) mkdir -p $TARGET_DIR/$TARGET_SUBDIR IMAGE_NAME="$(image_name $KALI_ARCH)" +# Don't quit on any errors now set +e BUILD_LOG=$(pwd)/build.log : > $BUILD_LOG @@ -285,6 +290,7 @@ case "$IMAGE_TYPE" in ;; esac +# If a command fails, make the whole script exit set -e mv $IMAGE_NAME $TARGET_DIR/$(target_image_name $KALI_ARCH) mv $BUILD_LOG $TARGET_DIR/$(target_build_log $KALI_ARCH) From de6a0ee0d1afe1059985ab6feeb9f1631a7b5668 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 11 May 2021 15:26:09 +0100 Subject: [PATCH 07/46] Space out commands a bit more --- build.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 7ce08de..63a6df9 100755 --- a/build.sh +++ b/build.sh @@ -2,8 +2,8 @@ # If a command fails, make the whole script exit set -e -set -o pipefail # Bashism # Use return code for any command errors in part of a pipe +set -o pipefail # Bashism # Kali's default values KALI_DIST="kali-rolling" @@ -27,7 +27,6 @@ image_name() { esac } - live_image_name() { case "$KALI_ARCH" in i386|amd64|arm64) @@ -126,6 +125,7 @@ done # Set default values KALI_ARCH=${KALI_ARCH:-$HOST_ARCH} + if [ -z "$KALI_VERSION" ]; then KALI_VERSION="$(default_version $KALI_DIST)" fi @@ -144,7 +144,7 @@ fi # Build parameters for lb config KALI_CONFIG_OPTS="--distribution $KALI_DIST -- --variant $KALI_VARIANT" -CODENAME=$KALI_DIST # for simple-cdd/debian-cd +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" @@ -164,6 +164,7 @@ case "$IMAGE_TYPE" in echo "ERROR: You need live-build (>= 1:20151215kali1), you have $ver_live_build" >&2 exit 1 fi + ver_debootstrap=$(dpkg-query -f '${Version}' -W debootstrap) if dpkg --compare-versions "$ver_debootstrap" lt "1.0.97"; then echo "ERROR: You need debootstrap (>= 1.0.97), you have $ver_debootstrap" >&2 @@ -180,6 +181,7 @@ case "$IMAGE_TYPE" in echo "ERROR: You need debian-cd (>= 3.1.28~kali1), you have $ver_debian_cd" >&2 exit 1 fi + ver_simple_cdd=$(dpkg-query -f '${Version}' -W simple-cdd) if dpkg --compare-versions "$ver_simple_cdd" lt 0.6.8~kali1; then echo "ERROR: You need simple-cdd (>= 0.6.8~kali1), you have $ver_simple_cdd" >&2 @@ -207,8 +209,10 @@ cd $(dirname $0) mkdir -p $TARGET_DIR/$TARGET_SUBDIR IMAGE_NAME="$(image_name $KALI_ARCH)" + # Don't quit on any errors now set +e + BUILD_LOG=$(pwd)/build.log : > $BUILD_LOG @@ -217,10 +221,13 @@ case "$IMAGE_TYPE" in if [ "$NO_CLEAN" = "" ]; then run_and_log $SUDO lb clean --purge fi + cp bin/kali-finish-install kali-config/common/includes.installer/ [ $? -eq 0 ] || failure + run_and_log lb config -a $KALI_ARCH $KALI_CONFIG_OPTS "$@" [ $? -eq 0 ] || failure + run_and_log $SUDO lb build if [ $? -ne 0 ] || [ ! -e $IMAGE_NAME ]; then failure @@ -261,9 +268,9 @@ case "$IMAGE_TYPE" in # Configure the kali profile with the packages we want grep -v '^#' kali-config/installer-$KALI_VARIANT/packages \ - >simple-cdd/profiles/kali.downloads + > simple-cdd/profiles/kali.downloads # Tasksel is required in the mirror for debian-cd - echo tasksel >>simple-cdd/profiles/kali.downloads + echo tasksel >> simple-cdd/profiles/kali.downloads # Grub is the only supported bootloader on arm64 # so ensure it's on the iso for arm64. if [ "$KALI_ARCH" = "arm64" ]; then @@ -292,6 +299,7 @@ esac # If a command fails, make the whole script exit set -e + mv $IMAGE_NAME $TARGET_DIR/$(target_image_name $KALI_ARCH) mv $BUILD_LOG $TARGET_DIR/$(target_build_log $KALI_ARCH) From 93c9188c349ec6916d4584da3c7defdf6fb78a73 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 11 May 2021 15:27:21 +0100 Subject: [PATCH 08/46] Swap spaces for tabs To make it more consistent --- build.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/build.sh b/build.sh index 63a6df9..d076423 100755 --- a/build.sh +++ b/build.sh @@ -76,11 +76,11 @@ target_build_log() { default_version() { case "$1" in - kali-*) - echo "${1#kali-}" + kali-*) + echo "${1#kali-}" ;; - *) - echo "$1" + *) + echo "$1" ;; esac } @@ -120,7 +120,7 @@ while true; do --no-clean) NO_CLEAN="1"; shift 1 ;; --) shift; break; ;; *) echo "ERROR: Invalid command-line option: $1" >&2; exit 1; ;; - esac + esac done # Set default values @@ -253,14 +253,14 @@ case "$IMAGE_TYPE" in export DEBVERSION=$KALI_VERSION if [ "$KALI_VARIANT" = "netinst" ]; then - export DISKTYPE="NETINST" + export DISKTYPE="NETINST" else - export DISKTYPE="DVD" + export DISKTYPE="DVD" fi if [ -e .mirror ]; then - kali_mirror=$(cat .mirror) + kali_mirror=$(cat .mirror) else - kali_mirror=http://archive.kali.org/kali/ + kali_mirror=http://archive.kali.org/kali/ fi if ! echo "$kali_mirror" | grep -q '/$'; then kali_mirror="$kali_mirror/" @@ -283,12 +283,12 @@ case "$IMAGE_TYPE" in # Run simple-cdd cd simple-cdd run_and_log build-simple-cdd \ - --verbose \ - --debug \ - --force-root \ - --conf simple-cdd.conf \ - --dist $CODENAME \ - --debian-mirror $kali_mirror + --verbose \ + --debug \ + --force-root \ + --conf simple-cdd.conf \ + --dist $CODENAME \ + --debian-mirror $kali_mirror res=$? cd .. if [ $res -ne 0 ] || [ ! -e $IMAGE_NAME ]; then From 39747af0935ccc05bbdae49b7784a55460717fd9 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 11 May 2021 15:59:30 +0100 Subject: [PATCH 09/46] Add --debug & --live arguments --- .getopt.sh | 20 ++++++++++++-------- build.sh | 44 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 10 deletions(-) diff --git a/.getopt.sh b/.getopt.sh index 3c2940f..fd25df3 100644 --- a/.getopt.sh +++ b/.getopt.sh @@ -1,13 +1,17 @@ -# Supported options are: +# Supported options are (from build.sh): # -d | --distribution # -p | --proposed-updates # -a | --arch -# --subdir -# --version -# --variant -# --installer -# --no-clean # -v | --verbose +# -D | --debug # -s | --salt -BUILD_OPTS_SHORT="d:pa:vs" -BUILD_OPTS_LONG="distribution:,proposed-updates,arch:,subdir:,version:,variant:,verbose,salt,installer,no-clean" +# --installer +# --live +# --variant +# --version +# --subdir +# --get-image-path +# --no-clean + +BUILD_OPTS_SHORT="d:pa:vDs" +BUILD_OPTS_LONG="distribution:,proposed-updates,arch:,verbose,debug,salt,installer,live,variant:,version:,subdir:,get-image-path,no-clean" diff --git a/build.sh b/build.sh index d076423..5623742 100755 --- a/build.sh +++ b/build.sh @@ -14,6 +14,7 @@ TARGET_DIR="$(dirname $0)/images" TARGET_SUBDIR="" SUDO="sudo" VERBOSE="" +DEBUG="" HOST_ARCH=$(dpkg --print-architecture) image_name() { @@ -87,11 +88,13 @@ default_version() { failure() { echo "Build of $KALI_DIST/$KALI_VARIANT/$KALI_ARCH $IMAGE_TYPE image failed (see build.log for details)" >&2 + echo "Log: $BUILD_LOG" >&2 exit 2 } run_and_log() { - if [ -n "$VERBOSE" ]; then + if [ -n "$VERBOSE" ] || [ -n "$DEBUG" ]; then + echo "RUNNING: $@" >&2 "$@" 2>&1 | tee -a $BUILD_LOG else "$@" >>$BUILD_LOG 2>&1 @@ -99,10 +102,16 @@ run_and_log() { return $? } +debug() { + if [ -n "$DEBUG" ]; then + echo "DEBUG: $*" >&2 + fi +} + # Allowed command line options . $(dirname $0)/.getopt.sh -# Parsing command line options +# Parsing command line options (see .getopt.sh) temp=$(getopt -o "$BUILD_OPTS_SHORT" -l "$BUILD_OPTS_LONG,get-image-path" -- "$@") eval set -- "$temp" while true; do @@ -111,8 +120,10 @@ while true; do -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; ;; -s|--salt) shift; ;; --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; ;; @@ -125,12 +136,15 @@ done # Set default values KALI_ARCH=${KALI_ARCH:-$HOST_ARCH} +debug "KALI_ARCH: $KALI_ARCH" if [ -z "$KALI_VERSION" ]; then KALI_VERSION="$(default_version $KALI_DIST)" fi +debug "KALI_VERSION: $KALI_VERSION" # Check parameters +debug "HOST_ARCH: $HOST_ARCH" if [ "$HOST_ARCH" != "$KALI_ARCH" ] && [ "$IMAGE_TYPE" != "installer" ]; then case "$HOST_ARCH/$KALI_ARCH" in amd64/i386|i386/amd64) @@ -149,10 +163,15 @@ 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) export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" +debug "PATH: $PATH" +debug "IMAGE_TYPE: $IMAGE_TYPE" case "$IMAGE_TYPE" in live) if [ ! -d "$(dirname $0)/kali-config/variant-$KALI_VARIANT" ]; then @@ -164,12 +183,14 @@ case "$IMAGE_TYPE" in echo "ERROR: You need live-build (>= 1:20151215kali1), you have $ver_live_build" >&2 exit 1 fi + debug "ver_live_build: $ver_live_build" ver_debootstrap=$(dpkg-query -f '${Version}' -W debootstrap) if dpkg --compare-versions "$ver_debootstrap" lt "1.0.97"; then echo "ERROR: You need debootstrap (>= 1.0.97), you have $ver_debootstrap" >&2 exit 1 fi + debug "ver_debootstrap: $ver_debootstrap" ;; installer) if [ ! -d "$(dirname $0)/kali-config/installer-$KALI_VARIANT" ]; then @@ -181,12 +202,14 @@ case "$IMAGE_TYPE" in echo "ERROR: You need debian-cd (>= 3.1.28~kali1), you have $ver_debian_cd" >&2 exit 1 fi + debug "ver_debian_cd: $ver_debian_cd" ver_simple_cdd=$(dpkg-query -f '${Version}' -W simple-cdd) if dpkg --compare-versions "$ver_simple_cdd" lt 0.6.8~kali1; then echo "ERROR: You need simple-cdd (>= 0.6.8~kali1), you have $ver_simple_cdd" >&2 exit 1 fi + debug "ver_simple_cdd: $ver_simple_cdd" ;; esac @@ -199,7 +222,9 @@ if [ "$(whoami)" != "root" ]; then else SUDO="" # We're already root fi +debug "SUDO: $ACTION" +debug "ACTION: $ACTION" if [ "$ACTION" = "get-image-path" ]; then echo $(target_image_name $KALI_ARCH) exit 0 @@ -209,25 +234,31 @@ cd $(dirname $0) mkdir -p $TARGET_DIR/$TARGET_SUBDIR IMAGE_NAME="$(image_name $KALI_ARCH)" +debug "IMAGE_NAME: $IMAGE_NAME" # Don't quit on any errors now set +e BUILD_LOG=$(pwd)/build.log +debug "BUILD_LOG: $BUILD_LOG" : > $BUILD_LOG case "$IMAGE_TYPE" in live) if [ "$NO_CLEAN" = "" ]; then + debug "Stage 0/3 - Clean" run_and_log $SUDO lb clean --purge fi + debug "Stage 1/3 - File(s)" cp bin/kali-finish-install kali-config/common/includes.installer/ [ $? -eq 0 ] || failure + debug "Stage 2/3 - Config" run_and_log lb config -a $KALI_ARCH $KALI_CONFIG_OPTS "$@" [ $? -eq 0 ] || failure + debug "Stage 2/3 - Build" run_and_log $SUDO lb build if [ $? -ne 0 ] || [ ! -e $IMAGE_NAME ]; then failure @@ -251,12 +282,18 @@ case "$IMAGE_TYPE" in 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" else export DISKTYPE="DVD" fi + debug "DISKTYPE: $DISKTYPE" + if [ -e .mirror ]; then kali_mirror=$(cat .mirror) else @@ -275,6 +312,7 @@ case "$IMAGE_TYPE" in # so ensure it's on the iso for arm64. if [ "$KALI_ARCH" = "arm64" ]; then echo "grub-efi-arm64" >>simple-cdd/profiles/kali.downloads + debug "arm64 GRUB" fi # Update the postinst script @@ -282,6 +320,7 @@ case "$IMAGE_TYPE" in # Run simple-cdd cd simple-cdd + debug "Stage 1/2 - Build" run_and_log build-simple-cdd \ --verbose \ --debug \ @@ -300,6 +339,7 @@ esac # If a command fails, make the whole script exit set -e +debug "Moving files" mv $IMAGE_NAME $TARGET_DIR/$(target_image_name $KALI_ARCH) mv $BUILD_LOG $TARGET_DIR/$(target_build_log $KALI_ARCH) From 375693311bd72596b812c2147e597d58d5e94685 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 11 May 2021 15:59:51 +0100 Subject: [PATCH 10/46] Add error check for IMAGE_TYPE --- build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.sh b/build.sh index 5623742..d34ced9 100755 --- a/build.sh +++ b/build.sh @@ -211,6 +211,10 @@ case "$IMAGE_TYPE" in fi debug "ver_simple_cdd: $ver_simple_cdd" ;; + *) + echo "ERROR: Unsupported IMAGE_TYPE selected ($IMAGE_TYPE)" >&2 + exit 1 + ;; esac # We need root rights at some point From 0304a6f02e296c48f9c6912e86178ac532c06f85 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 11 May 2021 16:01:08 +0100 Subject: [PATCH 11/46] Switch around ordering to match live image --- build.sh | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/build.sh b/build.sh index d34ced9..e59ed4e 100755 --- a/build.sh +++ b/build.sh @@ -269,18 +269,6 @@ case "$IMAGE_TYPE" in fi ;; installer) - if [ "$NO_CLEAN" = "" ]; then - run_and_log $SUDO rm -rf simple-cdd/tmp - run_and_log $SUDO rm -rf simple-cdd/debian-cd - fi - - # Setup custom debian-cd to make our changes - cp -aT /usr/share/debian-cd simple-cdd/debian-cd - # 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 - # Override some debian-cd environment variables export BASEDIR=$(pwd)/simple-cdd/debian-cd export ARCHES=$KALI_ARCH @@ -307,6 +295,23 @@ case "$IMAGE_TYPE" in kali_mirror="$kali_mirror/" fi + if [ "$NO_CLEAN" = "" ]; then + debug "Stage 0/2 - Clean" + run_and_log $SUDO rm -rf simple-cdd/tmp + run_and_log $SUDO rm -rf simple-cdd/debian-cd + fi + + debug "Stage 1/2 - File(s)" + # Setup custom debian-cd to make our changes + cp -aT /usr/share/debian-cd simple-cdd/debian-cd + # 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 + + # Update the post-install script + cp bin/kali-finish-install simple-cdd/profiles/kali.postinst + # Configure the kali profile with the packages we want grep -v '^#' kali-config/installer-$KALI_VARIANT/packages \ > simple-cdd/profiles/kali.downloads @@ -319,9 +324,6 @@ case "$IMAGE_TYPE" in debug "arm64 GRUB" fi - # Update the postinst script - cp bin/kali-finish-install simple-cdd/profiles/kali.postinst - # Run simple-cdd cd simple-cdd debug "Stage 1/2 - Build" From ca00ef55645a04bbdf3ce7ed9341bc50b1f5173b Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 11 May 2021 16:01:26 +0100 Subject: [PATCH 12/46] Spaces to tabs --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index e59ed4e..23a003a 100755 --- a/build.sh +++ b/build.sh @@ -292,7 +292,7 @@ case "$IMAGE_TYPE" in kali_mirror=http://archive.kali.org/kali/ fi if ! echo "$kali_mirror" | grep -q '/$'; then - kali_mirror="$kali_mirror/" + kali_mirror="$kali_mirror/" fi if [ "$NO_CLEAN" = "" ]; then @@ -320,8 +320,8 @@ case "$IMAGE_TYPE" in # Grub is the only supported bootloader on arm64 # so ensure it's on the iso for arm64. if [ "$KALI_ARCH" = "arm64" ]; then - echo "grub-efi-arm64" >>simple-cdd/profiles/kali.downloads debug "arm64 GRUB" + echo "grub-efi-arm64" >> simple-cdd/profiles/kali.downloads fi # Run simple-cdd From 5f61581bc2cdf0e3fa39dd81fbeff77a2d733d37 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 11 May 2021 16:01:34 +0100 Subject: [PATCH 13/46] Debug output --- build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sh b/build.sh index 23a003a..e0b0799 100755 --- a/build.sh +++ b/build.sh @@ -294,6 +294,7 @@ case "$IMAGE_TYPE" in if ! echo "$kali_mirror" | grep -q '/$'; then kali_mirror="$kali_mirror/" fi + debug "kali_mirror: $kali_mirror" if [ "$NO_CLEAN" = "" ]; then debug "Stage 0/2 - Clean" From 60ef618b2a19ac14d82ff213d96d335a1d595c51 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 11 May 2021 16:01:43 +0100 Subject: [PATCH 14/46] Bash formatting --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index e0b0799..87b88ad 100755 --- a/build.sh +++ b/build.sh @@ -326,8 +326,8 @@ case "$IMAGE_TYPE" in fi # Run simple-cdd - cd simple-cdd debug "Stage 1/2 - Build" + cd simple-cdd/ run_and_log build-simple-cdd \ --verbose \ --debug \ @@ -336,7 +336,7 @@ case "$IMAGE_TYPE" in --dist $CODENAME \ --debian-mirror $kali_mirror res=$? - cd .. + cd ../ if [ $res -ne 0 ] || [ ! -e $IMAGE_NAME ]; then failure fi From 881f5f2c6b2cbd79efccac2f54b56c4774553657 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 11 May 2021 16:02:29 +0100 Subject: [PATCH 15/46] Ignore generated files from live image buildilng --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 53e8da0..e0dea94 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,10 @@ config/source simple-cdd/debian-cd simple-cdd/profiles/kali.downloads simple-cdd/tmp +build.log +config/ +chroot.files +live-image-amd64.contents +live-image-amd64.files +live-image-amd64.hybrid.iso.zsync +live-image-amd64.packages From d74576cccba4623bc92003eb6930e04b7fe5d424 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Tue, 11 May 2021 16:07:57 +0100 Subject: [PATCH 16/46] Swap spaces for tabs --- build.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index 87b88ad..c227f45 100755 --- a/build.sh +++ b/build.sh @@ -274,10 +274,10 @@ case "$IMAGE_TYPE" in export ARCHES=$KALI_ARCH export ARCH=$KALI_ARCH export DEBVERSION=$KALI_VERSION - debug "BASEDIR: $BASEDIR" - debug "ARCHES: $ARCHES" - debug "ARCH: $ARCH" - debug "DEBVERSION: $DEBVERSION" + debug "BASEDIR: $BASEDIR" + debug "ARCHES: $ARCHES" + debug "ARCH: $ARCH" + debug "DEBVERSION: $DEBVERSION" if [ "$KALI_VARIANT" = "netinst" ]; then export DISKTYPE="NETINST" From 8f77672b19d2cca295de094a063f4a97d6e0d568 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Tue, 11 May 2021 17:31:47 +0100 Subject: [PATCH 17/46] Switch shortcuts for live image and USB --- kali-config/common/hooks/live/persistence-menu.binary | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kali-config/common/hooks/live/persistence-menu.binary b/kali-config/common/hooks/live/persistence-menu.binary index 4151553..7c8c5d7 100755 --- a/kali-config/common/hooks/live/persistence-menu.binary +++ b/kali-config/common/hooks/live/persistence-menu.binary @@ -7,13 +7,13 @@ fi cat >>isolinux/live.cfg < Date: Tue, 11 May 2021 17:32:08 +0100 Subject: [PATCH 18/46] Add UEFI text on live image --- kali-config/common/bootloaders/grub-pc/live-theme/theme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kali-config/common/bootloaders/grub-pc/live-theme/theme.txt b/kali-config/common/bootloaders/grub-pc/live-theme/theme.txt index 28fcc75..3e15ec8 100644 --- a/kali-config/common/bootloaders/grub-pc/live-theme/theme.txt +++ b/kali-config/common/bootloaders/grub-pc/live-theme/theme.txt @@ -25,7 +25,7 @@ terminal-font: "Unifont Regular 16" height = 35 align = "center" color = "#ffffff" - text = "Kali Linux Live Boot Menu" + text = "Kali Linux Live Menu (UEFI)" font = "DejaVu Sans Bold 16" } From 85cad5075b8dcf036ad6462bbb2ca97f33a06c9e Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Tue, 11 May 2021 17:32:23 +0100 Subject: [PATCH 19/46] Fix number typo --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index c227f45..5354a51 100755 --- a/build.sh +++ b/build.sh @@ -326,7 +326,7 @@ case "$IMAGE_TYPE" in fi # Run simple-cdd - debug "Stage 1/2 - Build" + debug "Stage 2/2 - Build" cd simple-cdd/ run_and_log build-simple-cdd \ --verbose \ From e48e8826b6fec5d879f5f633e86e9ab5aaa122e4 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Wed, 12 May 2021 13:58:06 +0100 Subject: [PATCH 20/46] Add OS check --- build.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.sh b/build.sh index 5354a51..ac1fcb2 100755 --- a/build.sh +++ b/build.sh @@ -171,6 +171,12 @@ debug "KALI_DIST: $KALI_DIST" export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" debug "PATH: $PATH" +if [ -e /etc/debian_version ]; then + debug "OS: $( cat /etc/debian_version )" +else + echo "ERROR: Non Debin-based OS" >&2 +fi + debug "IMAGE_TYPE: $IMAGE_TYPE" case "$IMAGE_TYPE" in live) From c671a315518296ae18351c4c7f9326b16f7367b7 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Wed, 12 May 2021 14:38:10 +0100 Subject: [PATCH 21/46] There is more than just x64! --- .gitignore | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index e0dea94..505bdd4 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,7 @@ simple-cdd/tmp build.log config/ chroot.files -live-image-amd64.contents -live-image-amd64.files -live-image-amd64.hybrid.iso.zsync -live-image-amd64.packages +live-image-*.contents +live-image-*.files +live-image-*.hybrid.iso.zsync +live-image-*.packages From 72ef3152a21b9c063087724088b0ba72102d4188 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Wed, 12 May 2021 16:58:12 +0100 Subject: [PATCH 22/46] Force overwrite - happens with installer anyway --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index ac1fcb2..2727f1b 100755 --- a/build.sh +++ b/build.sh @@ -353,7 +353,7 @@ esac set -e debug "Moving files" -mv $IMAGE_NAME $TARGET_DIR/$(target_image_name $KALI_ARCH) -mv $BUILD_LOG $TARGET_DIR/$(target_build_log $KALI_ARCH) +mv -f $IMAGE_NAME $TARGET_DIR/$(target_image_name $KALI_ARCH) +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***" From 305b60606f7cc5bf082262e0c243d1fb86d6cbb7 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 07:41:04 +0100 Subject: [PATCH 23/46] Add failure checks --- build.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build.sh b/build.sh index 2727f1b..e63588d 100755 --- a/build.sh +++ b/build.sh @@ -311,24 +311,33 @@ case "$IMAGE_TYPE" in 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 + # 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 # Update the post-install script cp bin/kali-finish-install simple-cdd/profiles/kali.postinst + [ $? -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 From d2b4645fb45f3660f4bf84d1b4b7926f10b207c7 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 07:41:37 +0100 Subject: [PATCH 24/46] Log all commands run_and_log doesn't like redirects, but I don't think thats an issue --- build.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/build.sh b/build.sh index e63588d..4dce302 100755 --- a/build.sh +++ b/build.sh @@ -261,7 +261,7 @@ case "$IMAGE_TYPE" in fi debug "Stage 1/3 - File(s)" - cp bin/kali-finish-install kali-config/common/includes.installer/ + run_and_log cp bin/kali-finish-install kali-config/common/includes.installer/ [ $? -eq 0 ] || failure debug "Stage 2/3 - Config" @@ -310,33 +310,32 @@ case "$IMAGE_TYPE" in debug "Stage 1/2 - File(s)" # Setup custom debian-cd to make our changes - cp -aT /usr/share/debian-cd simple-cdd/debian-cd + run_and_log cp -aT /usr/share/debian-cd simple-cdd/debian-cd [ $? -eq 0 ] || failure # 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' \ + run_and_log sed -i -e '/686-pae/d' \ simple-cdd/debian-cd/data/$CODENAME/exclude-udebs-i386 [ $? -eq 0 ] || failure # Update the post-install script - cp bin/kali-finish-install simple-cdd/profiles/kali.postinst + run_and_log cp bin/kali-finish-install simple-cdd/profiles/kali.postinst [ $? -eq 0 ] || failure # Configure the kali profile with the packages we want - grep -v '^#' kali-config/installer-$KALI_VARIANT/packages \ + run_and_log 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 + run_and_log 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 + run_and_log echo "grub-efi-arm64" >> simple-cdd/profiles/kali.downloads [ $? -eq 0 ] || failure fi @@ -362,7 +361,7 @@ esac set -e debug "Moving files" -mv -f $IMAGE_NAME $TARGET_DIR/$(target_image_name $KALI_ARCH) -mv -f $BUILD_LOG $TARGET_DIR/$(target_build_log $KALI_ARCH) +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***" From 6349d72df7d1927436fe457e576c9eb40b9f18d4 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 07:42:36 +0100 Subject: [PATCH 25/46] Ignore more traces of build output --- .gitignore | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 505bdd4..974e8c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,26 +1,31 @@ -binary.* -prepare.log -binary -images -cache -chroot +## Folders +.build/* +binary/* +binary.*/* +cache/* +chroot/* +config/* +images/* +local/* +simple-cdd/debian-cd/* +simple-cdd/images/* +simple-cdd/tmp/* +## Files +.mirror +build.log +chroot.files chroot.packages.install chroot.packages.live -.mirror -.stage -.lock -.build/ config/binary config/bootstrap config/common config/source -simple-cdd/debian-cd -simple-cdd/profiles/kali.downloads -simple-cdd/tmp -build.log -config/ -chroot.files live-image-*.contents live-image-*.files live-image-*.hybrid.iso.zsync live-image-*.packages +simple-cdd/profiles/kali.downloads +## Temp +.lock +.stage +prepare.log From d6dadb2c180539ad81b0afd268e06bcc5ae1d7d5 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 10:54:17 +0100 Subject: [PATCH 26/46] Add --clean option --- .getopt.sh | 3 ++- build.sh | 24 +++++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/.getopt.sh b/.getopt.sh index fd25df3..073750f 100644 --- a/.getopt.sh +++ b/.getopt.sh @@ -12,6 +12,7 @@ # --subdir # --get-image-path # --no-clean +# --clean BUILD_OPTS_SHORT="d:pa:vDs" -BUILD_OPTS_LONG="distribution:,proposed-updates,arch:,verbose,debug,salt,installer,live,variant:,version:,subdir:,get-image-path,no-clean" +BUILD_OPTS_LONG="distribution:,proposed-updates,arch:,verbose,debug,salt,installer,live,variant:,version:,subdir:,get-image-path,no-clean,clean" diff --git a/build.sh b/build.sh index 4dce302..7920261 100755 --- a/build.sh +++ b/build.sh @@ -106,11 +106,24 @@ debug() { if [ -n "$DEBUG" ]; then echo "DEBUG: $*" >&2 fi +clean() { + debug "Cleaning" + + # Live + run_and_log $SUDO lb clean --purge + + # Installer + run_and_log $SUDO rm -rf simple-cdd/tmp + run_and_log $SUDO rm -rf simple-cdd/debian-cd } # Allowed command line options . $(dirname $0)/.getopt.sh +BUILD_LOG=$(pwd)/build.log +debug "BUILD_LOG: $BUILD_LOG" +# Create empty file +: > $BUILD_LOG # Parsing command line options (see .getopt.sh) temp=$(getopt -o "$BUILD_OPTS_SHORT" -l "$BUILD_OPTS_LONG,get-image-path" -- "$@") eval set -- "$temp" @@ -128,6 +141,7 @@ while true; do --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; ;; @@ -240,6 +254,13 @@ if [ "$ACTION" = "get-image-path" ]; then exit 0 fi +if [ "$NO_CLEAN" = "" ]; then + clean +fi +if [ "$ACTION" = "clean" ]; then + exit 0 +fi + cd $(dirname $0) mkdir -p $TARGET_DIR/$TARGET_SUBDIR @@ -249,9 +270,6 @@ debug "IMAGE_NAME: $IMAGE_NAME" # Don't quit on any errors now set +e -BUILD_LOG=$(pwd)/build.log -debug "BUILD_LOG: $BUILD_LOG" -: > $BUILD_LOG case "$IMAGE_TYPE" in live) From 360ee78992d21c15e2326b904c89c43e516c1e9a Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 10:54:36 +0100 Subject: [PATCH 27/46] Fix formatting --- build.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index 7920261..461fec0 100755 --- a/build.sh +++ b/build.sh @@ -103,9 +103,11 @@ run_and_log() { } debug() { - if [ -n "$DEBUG" ]; then - echo "DEBUG: $*" >&2 - fi + if [ -n "$DEBUG" ]; then + echo "DEBUG: $*" >&2 + fi +} + clean() { debug "Cleaning" @@ -124,6 +126,7 @@ BUILD_LOG=$(pwd)/build.log debug "BUILD_LOG: $BUILD_LOG" # Create empty file : > $BUILD_LOG + # Parsing command line options (see .getopt.sh) temp=$(getopt -o "$BUILD_OPTS_SHORT" -l "$BUILD_OPTS_LONG,get-image-path" -- "$@") eval set -- "$temp" @@ -270,7 +273,6 @@ debug "IMAGE_NAME: $IMAGE_NAME" # Don't quit on any errors now set +e - case "$IMAGE_TYPE" in live) if [ "$NO_CLEAN" = "" ]; then From 142a3ba7b8170ddd7bc5a4efcad11617a69429e2 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 10:54:48 +0100 Subject: [PATCH 28/46] Remove duplicate clean --- build.sh | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/build.sh b/build.sh index 461fec0..5ada4d7 100755 --- a/build.sh +++ b/build.sh @@ -275,11 +275,6 @@ set +e case "$IMAGE_TYPE" in live) - if [ "$NO_CLEAN" = "" ]; then - debug "Stage 0/3 - Clean" - run_and_log $SUDO lb clean --purge - fi - debug "Stage 1/3 - File(s)" run_and_log cp bin/kali-finish-install kali-config/common/includes.installer/ [ $? -eq 0 ] || failure @@ -322,12 +317,6 @@ case "$IMAGE_TYPE" in fi debug "kali_mirror: $kali_mirror" - if [ "$NO_CLEAN" = "" ]; then - debug "Stage 0/2 - Clean" - run_and_log $SUDO rm -rf simple-cdd/tmp - run_and_log $SUDO rm -rf simple-cdd/debian-cd - fi - debug "Stage 1/2 - File(s)" # Setup custom debian-cd to make our changes run_and_log cp -aT /usr/share/debian-cd simple-cdd/debian-cd From dfda6f916883ff161398ff8b482ddcf9cc8a5eb1 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 10:55:09 +0100 Subject: [PATCH 29/46] Fix typo with SUDO --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 5ada4d7..7fd6c2a 100755 --- a/build.sh +++ b/build.sh @@ -249,7 +249,7 @@ if [ "$(whoami)" != "root" ]; then else SUDO="" # We're already root fi -debug "SUDO: $ACTION" +debug "SUDO: $SUDO" debug "ACTION: $ACTION" if [ "$ACTION" = "get-image-path" ]; then From fadc99ef88ba3bee3575c161a1e7717941aaf7a8 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 10:55:26 +0100 Subject: [PATCH 30/46] Group defining variables together --- build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 7fd6c2a..bea0b9c 100755 --- a/build.sh +++ b/build.sh @@ -251,6 +251,9 @@ else fi debug "SUDO: $SUDO" +IMAGE_NAME="$(image_name $KALI_ARCH)" +debug "IMAGE_NAME: $IMAGE_NAME" + debug "ACTION: $ACTION" if [ "$ACTION" = "get-image-path" ]; then echo $(target_image_name $KALI_ARCH) @@ -267,9 +270,6 @@ fi cd $(dirname $0) mkdir -p $TARGET_DIR/$TARGET_SUBDIR -IMAGE_NAME="$(image_name $KALI_ARCH)" -debug "IMAGE_NAME: $IMAGE_NAME" - # Don't quit on any errors now set +e From db5e3cfd2dd07b2075c8192ebe00992913fba1e3 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 10:56:06 +0100 Subject: [PATCH 31/46] Fix issue if folder wasn't yet there (fresh run) --- auto/clean | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/auto/clean b/auto/clean index 8221855..c1abd68 100755 --- a/auto/clean +++ b/auto/clean @@ -4,4 +4,8 @@ lb clean noauto "$@" rm -f config/binary config/bootstrap \ config/chroot config/common config/source \ config/package-lists/live.list.chroot -find config/hooks/ -type l | xargs --no-run-if-empty rm -f + +if [ -e config/hooks/ ]; then + find config/hooks/ -type l \ + | xargs --no-run-if-empty rm -f +fi From f4e3de7a1db4b7919b9cc757fd753ab276488197 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 10:56:19 +0100 Subject: [PATCH 32/46] Fix formatting to make it easier to read --- auto/clean | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/auto/clean b/auto/clean index c1abd68..70f1b17 100755 --- a/auto/clean +++ b/auto/clean @@ -1,9 +1,13 @@ #!/bin/sh lb clean noauto "$@" -rm -f config/binary config/bootstrap \ - config/chroot config/common config/source \ - config/package-lists/live.list.chroot + +rm -f config/binary \ + config/bootstrap \ + config/chroot \ + config/common \ + config/source \ + config/package-lists/live.list.chroot if [ -e config/hooks/ ]; then find config/hooks/ -type l \ From 665bb3af6f6a9efe444d0bc0602d4937d77620f8 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 11:08:44 +0100 Subject: [PATCH 33/46] Delete duplicate files and move to consistent naming location --- build.sh | 4 +- .../includes.installer/kali-finish-install | 74 ------------------- .../common/post-install}/kali-finish-install | 0 simple-cdd/profiles/kali.postinst | 74 ------------------- 4 files changed, 2 insertions(+), 150 deletions(-) delete mode 100755 kali-config/common/includes.installer/kali-finish-install rename {bin => kali-config/common/post-install}/kali-finish-install (100%) delete mode 100755 simple-cdd/profiles/kali.postinst diff --git a/build.sh b/build.sh index bea0b9c..2f4e554 100755 --- a/build.sh +++ b/build.sh @@ -276,7 +276,7 @@ set +e case "$IMAGE_TYPE" in live) debug "Stage 1/3 - File(s)" - run_and_log cp bin/kali-finish-install kali-config/common/includes.installer/ + run_and_log cp kali-config/common/post-install/kali-finish-install kali-config/common/includes.installer/ [ $? -eq 0 ] || failure debug "Stage 2/3 - Config" @@ -329,7 +329,7 @@ case "$IMAGE_TYPE" in [ $? -eq 0 ] || failure # Update the post-install script - run_and_log cp bin/kali-finish-install simple-cdd/profiles/kali.postinst + run_and_log cp kali-config/common/post-install/kali-finish-install simple-cdd/profiles/kali.postinst [ $? -eq 0 ] || failure # Configure the kali profile with the packages we want diff --git a/kali-config/common/includes.installer/kali-finish-install b/kali-config/common/includes.installer/kali-finish-install deleted file mode 100755 index 1aaac7a..0000000 --- a/kali-config/common/includes.installer/kali-finish-install +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/sh - -# The reference version of this script is maintained in -# live-build-config/bin/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 -# and in the live-build configuration). - -configure_sources_list() { - if grep -q '^deb ' /etc/apt/sources.list; then - echo "INFO: sources.list is configured, everything is fine" - return - fi - - echo "INFO: sources.list is empty, setting up a default one for Kali" - - cat >/etc/apt/sources.list </dev/null; then - echo "WARNING: user '$user' is invalid but /home/$user exists" - 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 - fi - if [ ! -x /usr/bin/zsh ]; then - 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 - done -} - -# This is generically named in case we want to add other groups in the future. -configure_usergroups() { - # Create the kaboxer group if needed - addgroup --system kaboxer || true - # Create the wireshark group if needed - addgroup --system wireshark || true - - # kaboxer - for kaboxer - # dialout - for serial access - # wireshark - capture sessions in wireshark - kali_groups="kaboxer,dialout,wireshark" - - for user in $(get_user_list); do - echo "INFO: adding user '$user' to groups '$kali_groups'" - usermod -a -G "$kali_groups" $user || true - done -} - -configure_sources_list -configure_zsh -configure_usergroups diff --git a/bin/kali-finish-install b/kali-config/common/post-install/kali-finish-install similarity index 100% rename from bin/kali-finish-install rename to kali-config/common/post-install/kali-finish-install diff --git a/simple-cdd/profiles/kali.postinst b/simple-cdd/profiles/kali.postinst deleted file mode 100755 index 1aaac7a..0000000 --- a/simple-cdd/profiles/kali.postinst +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/sh - -# The reference version of this script is maintained in -# live-build-config/bin/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 -# and in the live-build configuration). - -configure_sources_list() { - if grep -q '^deb ' /etc/apt/sources.list; then - echo "INFO: sources.list is configured, everything is fine" - return - fi - - echo "INFO: sources.list is empty, setting up a default one for Kali" - - cat >/etc/apt/sources.list </dev/null; then - echo "WARNING: user '$user' is invalid but /home/$user exists" - 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 - fi - if [ ! -x /usr/bin/zsh ]; then - 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 - done -} - -# This is generically named in case we want to add other groups in the future. -configure_usergroups() { - # Create the kaboxer group if needed - addgroup --system kaboxer || true - # Create the wireshark group if needed - addgroup --system wireshark || true - - # kaboxer - for kaboxer - # dialout - for serial access - # wireshark - capture sessions in wireshark - kali_groups="kaboxer,dialout,wireshark" - - for user in $(get_user_list); do - echo "INFO: adding user '$user' to groups '$kali_groups'" - usermod -a -G "$kali_groups" $user || true - done -} - -configure_sources_list -configure_zsh -configure_usergroups From dc7099cf0c4ec83deba9812299b241e55ddb3c4c Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 11:09:45 +0100 Subject: [PATCH 34/46] Don't track these files as they will be overwritten during build --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 974e8c8..fddb03c 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,9 @@ live-image-*.files live-image-*.hybrid.iso.zsync live-image-*.packages simple-cdd/profiles/kali.downloads +## Files overwritten during build +kali-config/common/includes.installer/kali-finish-install +simple-cdd/profiles/kali.postinst ## Temp .lock .stage From c4c1d7e86da057f79809ad3091267f5953e21b12 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 11:14:13 +0100 Subject: [PATCH 35/46] Move to new home --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fddb03c..4bfab76 100644 --- a/.gitignore +++ b/.gitignore @@ -24,10 +24,10 @@ live-image-*.contents live-image-*.files live-image-*.hybrid.iso.zsync live-image-*.packages -simple-cdd/profiles/kali.downloads ## Files overwritten during build kali-config/common/includes.installer/kali-finish-install simple-cdd/profiles/kali.postinst +simple-cdd/profiles/kali.downloads ## Temp .lock .stage From 0bf7ea3728730dd44a0077ea1b526fcb600132f0 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 15:00:11 +0100 Subject: [PATCH 36/46] Fix number typo --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 2f4e554..4b2bae3 100755 --- a/build.sh +++ b/build.sh @@ -283,7 +283,7 @@ case "$IMAGE_TYPE" in run_and_log lb config -a $KALI_ARCH $KALI_CONFIG_OPTS "$@" [ $? -eq 0 ] || failure - debug "Stage 2/3 - Build" + debug "Stage 3/3 - Build" run_and_log $SUDO lb build if [ $? -ne 0 ] || [ ! -e $IMAGE_NAME ]; then failure From c78ef580bc67b666f1fd079892ff8b158eeede01 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 15:00:23 +0100 Subject: [PATCH 37/46] Add shorthand support for arch --- build.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build.sh b/build.sh index 4b2bae3..4fd7e93 100755 --- a/build.sh +++ b/build.sh @@ -153,6 +153,11 @@ done # Set default values KALI_ARCH=${KALI_ARCH:-$HOST_ARCH} +if [ "$KALI_ARCH" == "x64" ]; then + KALI_ARCH="amd64" +elif [ "$KALI_ARCH" == "x86" ]; then + KALI_ARCH="i386" +fi debug "KALI_ARCH: $KALI_ARCH" if [ -z "$KALI_VERSION" ]; then From c00a132d10ce597d694da3c82eb82872583f8b3e Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 15:17:13 +0100 Subject: [PATCH 38/46] Remove trailing spaces --- kali-config/common/bootloaders/grub-pc/grub.cfg | 2 +- .../common/hooks/live/forensic-menu.binary | 1 - .../common/includes.installer/preseed.cfg | 4 ++-- kali-config/installer-default/packages | 2 +- simple-cdd/simple-cdd.conf | 17 ++++++++--------- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/kali-config/common/bootloaders/grub-pc/grub.cfg b/kali-config/common/bootloaders/grub-pc/grub.cfg index 92eea9b..0941fa7 100644 --- a/kali-config/common/bootloaders/grub-pc/grub.cfg +++ b/kali-config/common/bootloaders/grub-pc/grub.cfg @@ -21,7 +21,7 @@ LINUX_INSTALL if [ ! -e /boot/grub/install.cfg ]; then menuentry "Start installer with speech synthesis" { - linux KERNEL_GI speakup.synth=soft APPEND_GI + linux KERNEL_GI speakup.synth=soft APPEND_GI initrd INITRD_GI } fi diff --git a/kali-config/common/hooks/live/forensic-menu.binary b/kali-config/common/hooks/live/forensic-menu.binary index 44caff8..2acc04b 100755 --- a/kali-config/common/hooks/live/forensic-menu.binary +++ b/kali-config/common/hooks/live/forensic-menu.binary @@ -12,4 +12,3 @@ label live-forensic initrd /live/initrd.img append boot=live username=kali hostname=kali systemd.swap=no noautomount END - diff --git a/kali-config/common/includes.installer/preseed.cfg b/kali-config/common/includes.installer/preseed.cfg index ba059eb..0a42d7c 100644 --- a/kali-config/common/includes.installer/preseed.cfg +++ b/kali-config/common/includes.installer/preseed.cfg @@ -11,7 +11,7 @@ d-i mirror/http/hostname string http.kali.org d-i mirror/http/directory string /kali # Disable security, updates and backports -d-i apt-setup/services-select multiselect +d-i apt-setup/services-select multiselect # Enable contrib and non-free d-i apt-setup/non-free boolean true @@ -52,7 +52,7 @@ popularity-contest popularity-contest/participate boolean false 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-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 diff --git a/kali-config/installer-default/packages b/kali-config/installer-default/packages index 5b4d692..c7d6d42 100644 --- a/kali-config/installer-default/packages +++ b/kali-config/installer-default/packages @@ -1,7 +1,7 @@ # Full installer image # It should contain everything offered in tasksel # during initial installation so all kali-linux-* except: -# - kali-linux-everything +# - kali-linux-everything # Metapackages # You can customize the set of Kali metapackages (groups of tools) to install diff --git a/simple-cdd/simple-cdd.conf b/simple-cdd/simple-cdd.conf index 5d533af..6992657 100644 --- a/simple-cdd/simple-cdd.conf +++ b/simple-cdd/simple-cdd.conf @@ -8,21 +8,20 @@ # Profile Selection # # The following four files get included on the CD if present: -# $profile.preseed +# $profile.preseed # Debconf selections. -# $profile.packages -# Packages to be installed with the profile. Dependencies also will +# $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 +# $profile.downloads +# Additional packages to be included on the CD with this profile, but # not installed by default. -# $profile.postinst +# $profile.postinst # Post-install script that is run after installing packages. # -# During the install after base system setup, it will give you the +# 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="x-basic ltsp" @@ -111,7 +110,7 @@ local_packages="$(pwd)/local_packages" # Call mirror tools at each build- defaults to true. #do_mirror="false" -# Set your proxy (if any). +# Set your proxy (if any). #export http_proxy=http://localhost:3128 # Location of debian-cd files From d007e371ec3441da28f8af94bf68e824fb81077d Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 15:17:25 +0100 Subject: [PATCH 39/46] Fix formatting --- .gitignore | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 4bfab76..e34f87e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -## Folders +# Directories .build/* binary/* binary.*/* @@ -7,10 +7,9 @@ chroot/* config/* images/* local/* -simple-cdd/debian-cd/* simple-cdd/images/* simple-cdd/tmp/* -## Files +# Files .mirror build.log chroot.files @@ -24,11 +23,12 @@ live-image-*.contents live-image-*.files live-image-*.hybrid.iso.zsync live-image-*.packages -## Files overwritten during build +# Rverwritten due to build.sh kali-config/common/includes.installer/kali-finish-install -simple-cdd/profiles/kali.postinst +simple-cdd/debian-cd/* simple-cdd/profiles/kali.downloads -## Temp +simple-cdd/profiles/kali.postinst +# Miscellaneous .lock .stage prepare.log From d1ad9e1ea25351e1378beee548c36032e914ff45 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 16:14:29 +0100 Subject: [PATCH 40/46] Remove empty folders --- kali-config/variant-minimal/.empty | 0 simple-cdd/local_packages/.empty | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 kali-config/variant-minimal/.empty delete mode 100644 simple-cdd/local_packages/.empty diff --git a/kali-config/variant-minimal/.empty b/kali-config/variant-minimal/.empty deleted file mode 100644 index e69de29..0000000 diff --git a/simple-cdd/local_packages/.empty b/simple-cdd/local_packages/.empty deleted file mode 100644 index e69de29..0000000 From e695c81d1a98ed6a3c3da611dec533cf5e6e02f2 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 16:14:41 +0100 Subject: [PATCH 41/46] Remove un-used default profile --- 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 - 5 files changed, 7 deletions(-) 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 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 From 4b6aa7a76de756e3e538bf4dccf980ddad183310 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 16:15:41 +0100 Subject: [PATCH 42/46] Symlink to live file, rather than copying (we do it with preseed anyway) --- .gitignore | 4 +--- build.sh | 12 ++---------- .../kali-finish-install | 0 simple-cdd/profiles/kali.postinst | 1 + 4 files changed, 4 insertions(+), 13 deletions(-) rename kali-config/common/{post-install => includes.installer}/kali-finish-install (100%) create mode 120000 simple-cdd/profiles/kali.postinst diff --git a/.gitignore b/.gitignore index e34f87e..44c5d8b 100644 --- a/.gitignore +++ b/.gitignore @@ -23,11 +23,9 @@ live-image-*.contents live-image-*.files live-image-*.hybrid.iso.zsync live-image-*.packages -# Rverwritten due to build.sh -kali-config/common/includes.installer/kali-finish-install +# Overwritten due to build.sh simple-cdd/debian-cd/* simple-cdd/profiles/kali.downloads -simple-cdd/profiles/kali.postinst # Miscellaneous .lock .stage diff --git a/build.sh b/build.sh index 4fd7e93..ae1e1a8 100755 --- a/build.sh +++ b/build.sh @@ -280,15 +280,11 @@ set +e case "$IMAGE_TYPE" in live) - debug "Stage 1/3 - File(s)" - run_and_log cp kali-config/common/post-install/kali-finish-install kali-config/common/includes.installer/ - [ $? -eq 0 ] || failure - - debug "Stage 2/3 - Config" + debug "Stage 1/2 - Config" run_and_log lb config -a $KALI_ARCH $KALI_CONFIG_OPTS "$@" [ $? -eq 0 ] || failure - debug "Stage 3/3 - Build" + debug "Stage 2/2 - Build" run_and_log $SUDO lb build if [ $? -ne 0 ] || [ ! -e $IMAGE_NAME ]; then failure @@ -333,10 +329,6 @@ case "$IMAGE_TYPE" in simple-cdd/debian-cd/data/$CODENAME/exclude-udebs-i386 [ $? -eq 0 ] || failure - # Update the post-install script - run_and_log cp kali-config/common/post-install/kali-finish-install simple-cdd/profiles/kali.postinst - [ $? -eq 0 ] || failure - # Configure the kali profile with the packages we want run_and_log grep -v '^#' kali-config/installer-$KALI_VARIANT/packages \ > simple-cdd/profiles/kali.downloads diff --git a/kali-config/common/post-install/kali-finish-install b/kali-config/common/includes.installer/kali-finish-install similarity index 100% rename from kali-config/common/post-install/kali-finish-install rename to kali-config/common/includes.installer/kali-finish-install diff --git a/simple-cdd/profiles/kali.postinst b/simple-cdd/profiles/kali.postinst new file mode 120000 index 0000000..a0e67f7 --- /dev/null +++ b/simple-cdd/profiles/kali.postinst @@ -0,0 +1 @@ +../../kali-config/common/includes.installer/kali-finish-install \ No newline at end of file From 3630d2bea5e4590f362bb00592107e7b35f569bf Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 16:15:50 +0100 Subject: [PATCH 43/46] Remove un-used line --- kali-config/common/hooks/live/persistence-menu.binary | 1 - 1 file changed, 1 deletion(-) diff --git a/kali-config/common/hooks/live/persistence-menu.binary b/kali-config/common/hooks/live/persistence-menu.binary index 7c8c5d7..520f165 100755 --- a/kali-config/common/hooks/live/persistence-menu.binary +++ b/kali-config/common/hooks/live/persistence-menu.binary @@ -17,5 +17,4 @@ label live-encrypted-persistence linux /live/vmlinuz initrd /live/initrd.img append boot=live persistent=cryptsetup persistence-encryption=luks username=kali hostname=kali persistence - END From cd665ff03da14f128721f22a592d8fbdb4d37863 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 16:19:59 +0100 Subject: [PATCH 44/46] Comments where items are used (live images) --- kali-config/common/bootloaders/grub-pc/config.cfg | 1 + kali-config/common/bootloaders/grub-pc/grub.cfg | 1 + kali-config/common/bootloaders/grub-pc/live-theme/theme.txt | 1 + kali-config/common/hooks/live/forensic-menu.binary | 1 + kali-config/common/hooks/live/persistence-menu.binary | 1 + 5 files changed, 5 insertions(+) diff --git a/kali-config/common/bootloaders/grub-pc/config.cfg b/kali-config/common/bootloaders/grub-pc/config.cfg index 9de39f6..02e3e99 100644 --- a/kali-config/common/bootloaders/grub-pc/config.cfg +++ b/kali-config/common/bootloaders/grub-pc/config.cfg @@ -1,3 +1,4 @@ +# Live Image (UEFI boot) set default=0 loadfont $prefix/dejavu-bold-16.pf2 diff --git a/kali-config/common/bootloaders/grub-pc/grub.cfg b/kali-config/common/bootloaders/grub-pc/grub.cfg index 0941fa7..ebe5c20 100644 --- a/kali-config/common/bootloaders/grub-pc/grub.cfg +++ b/kali-config/common/bootloaders/grub-pc/grub.cfg @@ -1,3 +1,4 @@ +# Live Image (UEFI boot) source /boot/grub/config.cfg # Live boot diff --git a/kali-config/common/bootloaders/grub-pc/live-theme/theme.txt b/kali-config/common/bootloaders/grub-pc/live-theme/theme.txt index 3e15ec8..bd55fca 100644 --- a/kali-config/common/bootloaders/grub-pc/live-theme/theme.txt +++ b/kali-config/common/bootloaders/grub-pc/live-theme/theme.txt @@ -1,3 +1,4 @@ +# Live Image (UEFI boot) desktop-image: "../splash.png" title-color: "#ffffff" title-font: "DejaVu Sans Bold 16" diff --git a/kali-config/common/hooks/live/forensic-menu.binary b/kali-config/common/hooks/live/forensic-menu.binary index 2acc04b..27d967b 100755 --- a/kali-config/common/hooks/live/forensic-menu.binary +++ b/kali-config/common/hooks/live/forensic-menu.binary @@ -1,4 +1,5 @@ #!/bin/sh +# Live Image (BIOS boot) if [ ! -d isolinux ]; then cd binary diff --git a/kali-config/common/hooks/live/persistence-menu.binary b/kali-config/common/hooks/live/persistence-menu.binary index 520f165..a313585 100755 --- a/kali-config/common/hooks/live/persistence-menu.binary +++ b/kali-config/common/hooks/live/persistence-menu.binary @@ -1,4 +1,5 @@ #!/bin/sh +# Live Image (BIOS boot) if [ ! -d isolinux ]; then cd binary From 42df63a41d3e6f79b8afc94f29cd8c1f19333044 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 16:20:15 +0100 Subject: [PATCH 45/46] Live image text to match installer image --- kali-config/common/bootloaders/grub-pc/live-theme/theme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kali-config/common/bootloaders/grub-pc/live-theme/theme.txt b/kali-config/common/bootloaders/grub-pc/live-theme/theme.txt index bd55fca..ad8b044 100644 --- a/kali-config/common/bootloaders/grub-pc/live-theme/theme.txt +++ b/kali-config/common/bootloaders/grub-pc/live-theme/theme.txt @@ -26,7 +26,7 @@ terminal-font: "Unifont Regular 16" height = 35 align = "center" color = "#ffffff" - text = "Kali Linux Live Menu (UEFI)" + text = "Kali Linux live menu (UEFI)" font = "DejaVu Sans Bold 16" } From 30ba4008a7c7a4f2bc57d925e516ce1f34b910ea Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 13 May 2021 16:22:00 +0100 Subject: [PATCH 46/46] Remove un-used file "Start installer with speech synthesis" --- .../common/hooks/live/accessibility-menu.binary | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100755 kali-config/common/hooks/live/accessibility-menu.binary diff --git a/kali-config/common/hooks/live/accessibility-menu.binary b/kali-config/common/hooks/live/accessibility-menu.binary deleted file mode 100755 index 56d94b3..0000000 --- a/kali-config/common/hooks/live/accessibility-menu.binary +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -if [ ! -d isolinux ]; then - cd binary -fi - -if ! grep "speakup.synth=soft" isolinux/install.cfg >/dev/null; then -cat >>isolinux/install.cfg <