108 lines
4.1 KiB
Bash
108 lines
4.1 KiB
Bash
#!/bin/bash
|
|
|
|
###############################
|
|
# @author: Bram Prieshof #
|
|
###############################
|
|
|
|
#Live Ramdisk/Usb Check
|
|
if [ $(findmnt -T /run/live/medium | awk '{print $2}' | sed '1d' | grep -o '.*[^0-9]') == "/dev/shm" ]; then
|
|
TERM=ansi whiptail --nocancel --title "WipeStation: Welcome" --msgbox " Running from ram,\n Please make sure the bootable usb is disconnected" 8 60
|
|
fi
|
|
|
|
# function to dubble confirm the users action
|
|
FuncConfirm(){
|
|
if ! (whiptail --title "WipeStation: Confirmation" --defaultno --yes-button "Yes, erase all data" --yesno " WARNING! WARNING! WARNING! \n All data on connected disk(s) will be wiped and lost. \n\n Do you want to continue?" 10 78); then
|
|
return 1
|
|
fi
|
|
if ! (whiptail --title "WipeStation: Confirmation" --defaultno --yes-button "Yes, erase all data" --yesno " Just to be sure, \n All data on connected disk(s) will be wiped and lost.\n\n Do you want to continue?" 10 78); then
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
#ABAN function(Not in use, Broken on debian11/Bullseye)
|
|
## To enable add the following to the menu:
|
|
# "ABAN" "Use Anthony Boot And Nuke erase data on all disks" \
|
|
FuncABAN(){
|
|
#Ask for confirmation before starting task
|
|
FuncConfirm
|
|
local exitstatusConfirm=$?
|
|
[[ "$exitstatusConfirm" = 1 ]] && return 1;
|
|
#Run Job
|
|
sudo ABAN DESTROY ALL DATA
|
|
}
|
|
|
|
#wipefs function
|
|
FuncWipefs(){
|
|
#Ask for confirmation before starting task
|
|
FuncConfirm
|
|
local exitstatusConfirm=$?
|
|
[[ "$exitstatusConfirm" = 1 ]] && return 1;
|
|
#loop through all disk and wipe them
|
|
for disk in $(ls /sys/block | grep -v "loop\|sr\|fd\|$(findmnt -T /run/live/medium | awk '{print $2}' | sed -e 's#/dev/###' -e '1d' | grep -o '.*[^0-9]')")
|
|
do
|
|
echo "Erasing $disk"
|
|
sudo /usr/sbin/wipefs -a /dev/$disk
|
|
done
|
|
}
|
|
|
|
#scrub function
|
|
FuncScrub(){
|
|
#Ask for scrub/wipe methode
|
|
ScrubMETHOD=$(
|
|
whiptail --title "WipeStation: scrub select wipe methode" --menu "Make your choice" 16 100 9 \
|
|
"nnsa" "4-pass, NNSA Policy Letter NAP-14.1-C (XVI-8)" \
|
|
"dod" "4-pass, DoD 5220.22-M section 8-306 procedure" \
|
|
"bsi" "9-pass, recommended by the German Center of Security in Information" \
|
|
"gutmann" "5-pass, sequence from Gutmanns paper." \
|
|
"schneier" "7-pass, Bruce Schneier method" \
|
|
"pfitzner7" "7-random-pass, Roy Pfitzner method." \
|
|
"pfitzner33" "33-random-pass, Roy Pfitzner method." \
|
|
"usarmy" "US Army AR380-19 method" \
|
|
"fillzero" "1-pass, fill with zerros." \
|
|
"fillff" "1-pass, fill with ones." \
|
|
"random" "1-pass, fill with random data." \
|
|
"random2" "2-pass, fill with random data." 3>&2 2>&1 1>&3
|
|
)
|
|
local exitstatusMenu=$?
|
|
[[ "$exitstatusMenu" = 1 ]] && return 1;
|
|
#Ask for confirmation before starting
|
|
FuncConfirm
|
|
local exitstatusConfirm=$?
|
|
[[ "$exitstatusConfirm" = 1 ]] && return 1;
|
|
#loop through all disk and wipe them
|
|
for disk in $(ls /sys/block | grep -v "loop\|sr\|fd\|$(findmnt -T /run/live/medium | awk '{print $2}' | sed -e 's#/dev/###' -e '1d' | grep -o '.*[^0-9]')")
|
|
do
|
|
echo "Erasing $disk"
|
|
sudo scrub -p $ScrubMETHOD /dev/$disk
|
|
done
|
|
}
|
|
|
|
# Main Menu
|
|
while true; do
|
|
MainMenu=$(
|
|
whiptail --nocancel --title "WipeStation: Main menu" --menu "Make your choice" 16 100 9 \
|
|
"Wipefs" "Remove all partitons, and clear MBR" \
|
|
"Scrub" "Use scrub to erase data on all disks" \
|
|
"Exit" "Exit to shell" \
|
|
"Reboot" "" \
|
|
"Poweroff" "" 3>&2 2>&1 1>&3
|
|
)
|
|
case $MainMenu in
|
|
"Poweroff")
|
|
sudo poweroff
|
|
exit
|
|
;;
|
|
"Reboot")
|
|
sudo reboot
|
|
;;
|
|
"Exit")
|
|
exit
|
|
;;
|
|
*)
|
|
Func$MainMenu
|
|
;;
|
|
esac
|
|
unset MainMenu
|
|
whiptail --nocancel --title "WipeStation: Done" --msgbox " Operation completed \n Press enter to return to the main menu" 8 60
|
|
done
|