From 9fbe49ad82b07cb8fcc8edd477a2d49dac1ad068 Mon Sep 17 00:00:00 2001 From: Patrick Neumann Date: Wed, 22 Jun 2022 12:01:50 +0000 Subject: [PATCH] sync with kali docu --- kali/make_kali-usb-stick_persistent | 32 ++++++++++++++++++----------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/kali/make_kali-usb-stick_persistent b/kali/make_kali-usb-stick_persistent index 39616ca..20d2a3d 100644 --- a/kali/make_kali-usb-stick_persistent +++ b/kali/make_kali-usb-stick_persistent @@ -6,12 +6,11 @@ # Description: Writes a kali.iso to an usb stick (optional) and # adds persistence to it step by step. # Author: Patrick Neumann (patrick@neumannsland.de) -# Platform: Kali Linux (tested: 2018.4) or +# Platform: Kali Linux (tested: 2022.2) or # Debian GNU/Linux (tested: 9.5) -# Version: 1.01 -# Date: 30.01.2019 -# Link: -# https://vcs.neumannsland.de/casualscripter/shell-scripting/src/branch/master/kali/make_kali-usb-stick_persistent +# Version: 1.03 +# Date: 22.06.2022 +# Link: https://git.neumannsland.de/casualscripter/shell-scripting # License: GPL3 # Warranty: This program is distributed WITHOUT ANY WARRANTY @@ -34,8 +33,20 @@ if [ "${#}" -gt 1 ]; then usage fi -# select usb stick -printf "Please select an usb stick:\n" +# list of external usb storage devices +printf "List of external usb storage devices:\n" +readonly USBSTORDEVS="$( ls -l /sys/dev/block | grep -E ".*usb.*[^[:digit:]]$" | awk '{ print $NF; }')" +for usbstordev in ${USBSTORDEVS} ; do + dev="${usbstordev##*/}" + dir="/sys/dev/block/${usbstordev%/*/*}" + vendor="$( cat "${dir}/vendor" )" + model="$( cat "${dir}/model" )" + printf "${dev} = ${vendor} ${model}\n" +done + +# select external usb storage device +printf "\nPlease select an external usb storage device:\n" + select USBSTICK in $( ls -l /sys/dev/block | grep -E ".*usb.*[^[:digit:]]$" | awk -F "/" '{ print $NF; }' ) ; do if [ -n "${USBSTICK}" ] ; then break ; fi done @@ -56,7 +67,7 @@ if [ "${#}" -eq 1 ]; then ISOFILE="${1}" - dd if="${ISOFILE}" of="${USBSTICK}" bs=512k + dd if="${ISOFILE}" of="${USBSTICK}" conv=fsync bs=4M status=progress fi #check if persistence is already there. @@ -66,10 +77,7 @@ if blkid "${USBSTICK}"3 | grep -F persistence &> /dev/null ; then fi # add 3rd partition to the end of the usb stick -FREE="$( parted -m "${USBSTICK}" print free | grep -F free | tail -n 1 )" -START="$( printf "${FREE}" | awk -F ":" '{ print $2; }' )" -END="$( printf "${FREE}" | awk -F ":" '{ print $3; }' )" -parted --script "${USBSTICK}" mkpart primary "${START}" "${END}" +fdisk "${USBSTICK}" <<< $( printf "n\np\n\n\n\nw" ) # format 3rd partition with ext3 and label "persistence" mkfs.ext3 -L persistence "${USBSTICK}"3