sync with kali docu

This commit is contained in:
Patrick Neumann 2022-06-22 12:01:50 +00:00
parent dfedda1454
commit 9fbe49ad82

View File

@ -6,12 +6,11 @@
# Description: Writes a kali.iso to an usb stick (optional) and # Description: Writes a kali.iso to an usb stick (optional) and
# adds persistence to it step by step. # adds persistence to it step by step.
# Author: Patrick Neumann (patrick@neumannsland.de) # 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) # Debian GNU/Linux (tested: 9.5)
# Version: 1.01 # Version: 1.03
# Date: 30.01.2019 # Date: 22.06.2022
# Link: # Link: https://git.neumannsland.de/casualscripter/shell-scripting
# https://vcs.neumannsland.de/casualscripter/shell-scripting/src/branch/master/kali/make_kali-usb-stick_persistent
# License: GPL3 # License: GPL3
# Warranty: This program is distributed WITHOUT ANY WARRANTY # Warranty: This program is distributed WITHOUT ANY WARRANTY
@ -34,8 +33,20 @@ if [ "${#}" -gt 1 ]; then
usage usage
fi fi
# select usb stick # list of external usb storage devices
printf "Please select an usb stick:\n" 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 select USBSTICK in $( ls -l /sys/dev/block | grep -E ".*usb.*[^[:digit:]]$" | awk -F "/" '{ print $NF; }' ) ; do
if [ -n "${USBSTICK}" ] ; then break ; fi if [ -n "${USBSTICK}" ] ; then break ; fi
done done
@ -56,7 +67,7 @@ if [ "${#}" -eq 1 ]; then
ISOFILE="${1}" ISOFILE="${1}"
dd if="${ISOFILE}" of="${USBSTICK}" bs=512k dd if="${ISOFILE}" of="${USBSTICK}" conv=fsync bs=4M status=progress
fi fi
#check if persistence is already there. #check if persistence is already there.
@ -66,10 +77,7 @@ if blkid "${USBSTICK}"3 | grep -F persistence &> /dev/null ; then
fi fi
# add 3rd partition to the end of the usb stick # add 3rd partition to the end of the usb stick
FREE="$( parted -m "${USBSTICK}" print free | grep -F free | tail -n 1 )" fdisk "${USBSTICK}" <<< $( printf "n\np\n\n\n\nw" )
START="$( printf "${FREE}" | awk -F ":" '{ print $2; }' )"
END="$( printf "${FREE}" | awk -F ":" '{ print $3; }' )"
parted --script "${USBSTICK}" mkpart primary "${START}" "${END}"
# format 3rd partition with ext3 and label "persistence" # format 3rd partition with ext3 and label "persistence"
mkfs.ext3 -L persistence "${USBSTICK}"3 mkfs.ext3 -L persistence "${USBSTICK}"3