Since wipe has no GUI and therefore isn't that convenient to use, I wrote one as a shell script using zenity (the command sfill from www.thc.org is used to securely wipe free space). Please comment to see if anything can be improved. Especially wiping multiple files where file names contain spaces was difficult to do and probably not implemented in a very elegant fashion, but at least it works!
--------------------------------------
#!/bin/bash
# Kwipe v0.1 (c) Adrian Zenz
# main menu
kwiping () {
type=`/usr/bin/zenity --list --title "Kwipe v0.1" --width="260" --height="230" --text="What do you want to wipe?" --column="Please select:" "Wipe files" "Wipe folders" "Wipe hard drives / USB sticks" "Wipe empty space on drives"`
if [ "$?" == "1" ]
then
exit 1
fi
# ************ WIPE FILES
if [ "$type" == "Wipe files" ]
then
files1=`/usr/bin/zenity --title "Select file(s) to wipe" --file-selection --multiple --separator='" "'`
if [ "$?" == "1" ]
then
kwiping
fi
pass=`zenity --text="Select number of passes for the wiping" --scale --value=5 --min-value=1 --max-value=20`
if [ "$?" == "1" ]
then
kwiping
fi
# Ensure that all file names are enclosed by "" since they might contain spaces
h='"'
files=$h$files1$h
/usr/bin/zenity --title="WARNING" --text="The file(s) $files will be wiped with $pass passes! This operation cannot be undone! Are you sure?" --question
if [ "$?" == "1" ]
then
kwiping
fi
# Prevent wiping of root-owned files which for some reason can occur when executing /var/tmp/wipe_files
echo -ne "cat " > /var/tmp/wipe_files
echo -ne $files >> /var/tmp/wipe_files
chmod 700 /var/tmp/wipe_files
chmod +x /var/tmp/wipe_files
/var/tmp/wipe_files > /dev/null
if [ "$?" == "1" ]
then
/usr/bin/zenity --error --text="The file(s) $files could not be wiped! Check file permissions or run kwipe as root."
rm -f /var/tmp/wipe_files
kwiping
fi
# Create execution file for wiping the files (necessary since the command 'wipe $files' doesn't work if file names contain spaces)
echo -ne "/usr/bin/wipe -cfsqk -Z -Q 1 " > /var/tmp/wipe_files
echo -ne $files >> /var/tmp/wipe_files
chmod 700 /var/tmp/wipe_files
chmod +x /var/tmp/wipe_files
count="0"
t="100"
(
while [ $count -lt $pass ]
do
# maths for zenity progress bar
count=$(expr $count + 1)
perc=$(expr $t / $pass)
p=$(expr $count \* $perc - 1)
echo $p
/var/tmp/wipe_files
done ) | zenity --progress --title="File Wiping" --text="Wiping in progress..." --percentage=0 --auto-close
# Wipe filenames without wiping the file again & delete the file
echo -ne "/usr/bin/wipe -cfsq -l 1K -Q 1 " > /var/tmp/wipe_files
echo -ne $files >> /var/tmp/wipe_files
chmod 700 /var/tmp/wipe_files
chmod +x /var/tmp/wipe_files
/var/tmp/wipe_files
if [ "$?" != "0" ]
then
/usr/bin/zenity --error --text="The file(s) $files could not be wiped! Check file permissions or run kwipe as root."
rm -f /var/tmp/wipe_files
else
/usr/bin/zenity --info --text="The file(s) $files was/were successfully wiped!"
rm -f /var/tmp/wipe_files
fi
fi
# ************** WIPE DIRECTORIES
if [ "$type" == "Wipe folders" ]
then
files=`/usr/bin/zenity --title "Select folder to wipe (wipes all contents and sub-folders!)" --file-selection --directory`
if [ "$?" == "1" ]
then
kwiping
fi
pass=`zenity --text="Number of passes for the wiping" --scale --value=5 --min-value=1 --max-value=20`
if [ "$?" == "1" ]
then
kwiping
fi
/usr/bin/zenity --title="WARNING" --text="The folder $files and all its contents and sub-folders will be wiped with $pass passes! This operation cannot be undone! Are you sure? [Note: the folder name must not contain any spaces]" --question
if [ "$?" == "1" ]
then
kwiping
fi
count="0"
t="100"
(
while [ $count -lt $pass ]
do
# maths for zenity progress bar
count=$(expr $count + 1)
perc=$(expr $t / $pass)
p=$(expr $count \* $perc - 1)
echo $p
/usr/bin/wipe -rcfsqk -Z -Q 1 $files
done ) | zenity --progress --title="Folder Wiping" --text="Wiping in progress..." --percentage=0 --auto-close
# Wipe filenames without wiping the file again & delete the file
/usr/bin/wipe -rcfsq -l 1K -Q 1 $files
if [ "$?" != "0" ]
then
/usr/bin/zenity --error --text="The folder $files could not be wiped! Check file permissions or run kwipe as root."
else
/usr/bin/zenity --info --text="The folder $files was successfully wiped!"
fi
fi
# ************** WIPE DEVICES
if [ "$type" == "Wipe hard drives / USB sticks" ]
then
# Get drive info
mount | awk '{print $1}' | grep -E "/dev/sd|/dev/hd" > /var/tmp/drives_list
i="0"
while read line
do
i=$((i + 1))
drive[$i]=$line
drive_size[$i]=`df -h | grep $line | awk '{print $2}'`
done < /var/tmp/drives_list
rm -f /var/tmp/drives_list
wdrive=`/usr/bin/zenity --list --title "Select drive to wipe" --text="Select drive to wipe:" --column="Drive name" --column="Size (MB/GB)" ${drive[1]} ${drive_size[1]} ${drive[2]} ${drive_size[2]} ${drive[3]} ${drive_size[3]} ${drive[4]} ${drive_size[4]} ${drive[5]} ${drive_size[5]} ${drive[6]} ${drive_size[6]} ${drive[7]} ${drive_size[7]} ${drive[8]} ${drive_size[8]} ${drive[9]} ${drive_size[9]} ${drive[10]} ${drive_size[10]} ${drive[11]} ${drive_size[11]} ${drive[12]} ${drive_size[12]} ${drive[13]} ${drive_size[13]}`
if [ "$?" == "1" ]
then
kwiping
fi
pass=`zenity --text="Select number of passes for the wiping" --scale --value=5 --min-value=1 --max-value=20`
if [ "$?" == "1" ]
then
kwiping
fi
df -h | grep $wdrive | awk '{print $2}' > /var/tmp/drive_size
drive_info=`cat /var/tmp/drive_size`
rm -f /var/tmp/drive_size
/usr/bin/zenity --title="WARNING" --text="The drive $wdrive [size $drive_info ] will be wiped with $pass passes! This operation cannot be undone! Are you sure?" --question
if [ "$?" == "1" ]
then
kwiping
fi
count="0"
t="100"
(
while [ $count -lt $pass ]
do
# maths for zenity progress bar
count=$(expr $count + 1)
perc=$(expr $t / $pass)
p=$(expr $count \* $perc - 1)
echo $p
/usr/bin/kdesu -c "/usr/bin/wipe -fqk -Q 1 $wdrive"
done ) | zenity --progress --title="File Wiping" --text="Wiping in progress..." --percentage=0
/usr/bin/zenity --info --text="The drive $files was wiped, but result of wiping process cannot be confirmed. Please verify yourself."
fi
# **************** WIPE EMPTY SPACE
if [ "$type" == "Wipe empty space on drives" ]
then
# Get drive info
mount | awk '{print $1}' | grep -E "/dev/sd|/dev/hd" > /var/tmp/drives_list
i="0"
while read line
do
i=$((i + 1))
drive[$i]=$line
drive_size[$i]=`df -h | grep $line | awk '{print $2}'`
done < /var/tmp/drives_list
rm -f /var/tmp/drives_list
wdrive=`/usr/bin/zenity --list --title "Select drive" --text="Select drive for wiping free space:" --column="Drive name" --column="Size (MB/GB)" ${drive[1]} ${drive_size[1]} ${drive[2]} ${drive_size[2]} ${drive[3]} ${drive_size[3]} ${drive[4]} ${drive_size[4]} ${drive[5]} ${drive_size[5]} ${drive[6]} ${drive_size[6]} ${drive[7]} ${drive_size[7]} ${drive[8]} ${drive_size[8]} ${drive[9]} ${drive_size[9]} ${drive[10]} ${drive_size[10]} ${drive[11]} ${drive_size[11]} ${drive[12]} ${drive_size[12]} ${drive[13]} ${drive_size[13]}`
if [ "$?" == "1" ]
then
kwiping
fi
pass=`zenity --text="Select number of passes for the wiping" --scale --value=5 --min-value=1 --max-value=20`
if [ "$?" == "1" ]
then
kwiping
fi
df -h | grep $wdrive | awk '{print $2}' > /var/tmp/drive_size
drive_info=`cat /var/tmp/drive_size`
rm -f /var/tmp/drive_size
/usr/bin/zenity --title="WARNING" --text="The free space on drive $wdrive [size $drive_info ] will be wiped with $pass passes. This will not delete any files on the drive. Do you wish to proceed?" --question
if [ "$?" == "1" ]
then
kwiping
fi
fspace=`df | grep $wdrive | awk '{print $4}'`
wdrivepath=`mount | grep $wdrive | awk '{print $3}'`
count="0"
t="100"
(
while [ $count -lt $pass ]
do
# maths for zenity progress bar
count=$(expr $count + 1)
perc=$(expr $t / $pass)
p=$(expr $count \* $perc - 1)
echo $p
/usr/bin/kdesu -c "/usr/bin/sfill -l -l $wdrivepath"
done ) | zenity --progress --title="Free Space Wiping" --text="Wiping in progress..." --percentage=0 --auto-close
/usr/bin/zenity --info --text="The free space on drive $wdrive was wiped!"
fi
exit 0
}
kwiping
--------------------------------------
#!/bin/bash
# Kwipe v0.1 (c) Adrian Zenz
# main menu
kwiping () {
type=`/usr/bin/zenity --list --title "Kwipe v0.1" --width="260" --height="230" --text="What do you want to wipe?" --column="Please select:" "Wipe files" "Wipe folders" "Wipe hard drives / USB sticks" "Wipe empty space on drives"`
if [ "$?" == "1" ]
then
exit 1
fi
# ************ WIPE FILES
if [ "$type" == "Wipe files" ]
then
files1=`/usr/bin/zenity --title "Select file(s) to wipe" --file-selection --multiple --separator='" "'`
if [ "$?" == "1" ]
then
kwiping
fi
pass=`zenity --text="Select number of passes for the wiping" --scale --value=5 --min-value=1 --max-value=20`
if [ "$?" == "1" ]
then
kwiping
fi
# Ensure that all file names are enclosed by "" since they might contain spaces
h='"'
files=$h$files1$h
/usr/bin/zenity --title="WARNING" --text="The file(s) $files will be wiped with $pass passes! This operation cannot be undone! Are you sure?" --question
if [ "$?" == "1" ]
then
kwiping
fi
# Prevent wiping of root-owned files which for some reason can occur when executing /var/tmp/wipe_files
echo -ne "cat " > /var/tmp/wipe_files
echo -ne $files >> /var/tmp/wipe_files
chmod 700 /var/tmp/wipe_files
chmod +x /var/tmp/wipe_files
/var/tmp/wipe_files > /dev/null
if [ "$?" == "1" ]
then
/usr/bin/zenity --error --text="The file(s) $files could not be wiped! Check file permissions or run kwipe as root."
rm -f /var/tmp/wipe_files
kwiping
fi
# Create execution file for wiping the files (necessary since the command 'wipe $files' doesn't work if file names contain spaces)
echo -ne "/usr/bin/wipe -cfsqk -Z -Q 1 " > /var/tmp/wipe_files
echo -ne $files >> /var/tmp/wipe_files
chmod 700 /var/tmp/wipe_files
chmod +x /var/tmp/wipe_files
count="0"
t="100"
(
while [ $count -lt $pass ]
do
# maths for zenity progress bar
count=$(expr $count + 1)
perc=$(expr $t / $pass)
p=$(expr $count \* $perc - 1)
echo $p
/var/tmp/wipe_files
done ) | zenity --progress --title="File Wiping" --text="Wiping in progress..." --percentage=0 --auto-close
# Wipe filenames without wiping the file again & delete the file
echo -ne "/usr/bin/wipe -cfsq -l 1K -Q 1 " > /var/tmp/wipe_files
echo -ne $files >> /var/tmp/wipe_files
chmod 700 /var/tmp/wipe_files
chmod +x /var/tmp/wipe_files
/var/tmp/wipe_files
if [ "$?" != "0" ]
then
/usr/bin/zenity --error --text="The file(s) $files could not be wiped! Check file permissions or run kwipe as root."
rm -f /var/tmp/wipe_files
else
/usr/bin/zenity --info --text="The file(s) $files was/were successfully wiped!"
rm -f /var/tmp/wipe_files
fi
fi
# ************** WIPE DIRECTORIES
if [ "$type" == "Wipe folders" ]
then
files=`/usr/bin/zenity --title "Select folder to wipe (wipes all contents and sub-folders!)" --file-selection --directory`
if [ "$?" == "1" ]
then
kwiping
fi
pass=`zenity --text="Number of passes for the wiping" --scale --value=5 --min-value=1 --max-value=20`
if [ "$?" == "1" ]
then
kwiping
fi
/usr/bin/zenity --title="WARNING" --text="The folder $files and all its contents and sub-folders will be wiped with $pass passes! This operation cannot be undone! Are you sure? [Note: the folder name must not contain any spaces]" --question
if [ "$?" == "1" ]
then
kwiping
fi
count="0"
t="100"
(
while [ $count -lt $pass ]
do
# maths for zenity progress bar
count=$(expr $count + 1)
perc=$(expr $t / $pass)
p=$(expr $count \* $perc - 1)
echo $p
/usr/bin/wipe -rcfsqk -Z -Q 1 $files
done ) | zenity --progress --title="Folder Wiping" --text="Wiping in progress..." --percentage=0 --auto-close
# Wipe filenames without wiping the file again & delete the file
/usr/bin/wipe -rcfsq -l 1K -Q 1 $files
if [ "$?" != "0" ]
then
/usr/bin/zenity --error --text="The folder $files could not be wiped! Check file permissions or run kwipe as root."
else
/usr/bin/zenity --info --text="The folder $files was successfully wiped!"
fi
fi
# ************** WIPE DEVICES
if [ "$type" == "Wipe hard drives / USB sticks" ]
then
# Get drive info
mount | awk '{print $1}' | grep -E "/dev/sd|/dev/hd" > /var/tmp/drives_list
i="0"
while read line
do
i=$((i + 1))
drive[$i]=$line
drive_size[$i]=`df -h | grep $line | awk '{print $2}'`
done < /var/tmp/drives_list
rm -f /var/tmp/drives_list
wdrive=`/usr/bin/zenity --list --title "Select drive to wipe" --text="Select drive to wipe:" --column="Drive name" --column="Size (MB/GB)" ${drive[1]} ${drive_size[1]} ${drive[2]} ${drive_size[2]} ${drive[3]} ${drive_size[3]} ${drive[4]} ${drive_size[4]} ${drive[5]} ${drive_size[5]} ${drive[6]} ${drive_size[6]} ${drive[7]} ${drive_size[7]} ${drive[8]} ${drive_size[8]} ${drive[9]} ${drive_size[9]} ${drive[10]} ${drive_size[10]} ${drive[11]} ${drive_size[11]} ${drive[12]} ${drive_size[12]} ${drive[13]} ${drive_size[13]}`
if [ "$?" == "1" ]
then
kwiping
fi
pass=`zenity --text="Select number of passes for the wiping" --scale --value=5 --min-value=1 --max-value=20`
if [ "$?" == "1" ]
then
kwiping
fi
df -h | grep $wdrive | awk '{print $2}' > /var/tmp/drive_size
drive_info=`cat /var/tmp/drive_size`
rm -f /var/tmp/drive_size
/usr/bin/zenity --title="WARNING" --text="The drive $wdrive [size $drive_info ] will be wiped with $pass passes! This operation cannot be undone! Are you sure?" --question
if [ "$?" == "1" ]
then
kwiping
fi
count="0"
t="100"
(
while [ $count -lt $pass ]
do
# maths for zenity progress bar
count=$(expr $count + 1)
perc=$(expr $t / $pass)
p=$(expr $count \* $perc - 1)
echo $p
/usr/bin/kdesu -c "/usr/bin/wipe -fqk -Q 1 $wdrive"
done ) | zenity --progress --title="File Wiping" --text="Wiping in progress..." --percentage=0
/usr/bin/zenity --info --text="The drive $files was wiped, but result of wiping process cannot be confirmed. Please verify yourself."
fi
# **************** WIPE EMPTY SPACE
if [ "$type" == "Wipe empty space on drives" ]
then
# Get drive info
mount | awk '{print $1}' | grep -E "/dev/sd|/dev/hd" > /var/tmp/drives_list
i="0"
while read line
do
i=$((i + 1))
drive[$i]=$line
drive_size[$i]=`df -h | grep $line | awk '{print $2}'`
done < /var/tmp/drives_list
rm -f /var/tmp/drives_list
wdrive=`/usr/bin/zenity --list --title "Select drive" --text="Select drive for wiping free space:" --column="Drive name" --column="Size (MB/GB)" ${drive[1]} ${drive_size[1]} ${drive[2]} ${drive_size[2]} ${drive[3]} ${drive_size[3]} ${drive[4]} ${drive_size[4]} ${drive[5]} ${drive_size[5]} ${drive[6]} ${drive_size[6]} ${drive[7]} ${drive_size[7]} ${drive[8]} ${drive_size[8]} ${drive[9]} ${drive_size[9]} ${drive[10]} ${drive_size[10]} ${drive[11]} ${drive_size[11]} ${drive[12]} ${drive_size[12]} ${drive[13]} ${drive_size[13]}`
if [ "$?" == "1" ]
then
kwiping
fi
pass=`zenity --text="Select number of passes for the wiping" --scale --value=5 --min-value=1 --max-value=20`
if [ "$?" == "1" ]
then
kwiping
fi
df -h | grep $wdrive | awk '{print $2}' > /var/tmp/drive_size
drive_info=`cat /var/tmp/drive_size`
rm -f /var/tmp/drive_size
/usr/bin/zenity --title="WARNING" --text="The free space on drive $wdrive [size $drive_info ] will be wiped with $pass passes. This will not delete any files on the drive. Do you wish to proceed?" --question
if [ "$?" == "1" ]
then
kwiping
fi
fspace=`df | grep $wdrive | awk '{print $4}'`
wdrivepath=`mount | grep $wdrive | awk '{print $3}'`
count="0"
t="100"
(
while [ $count -lt $pass ]
do
# maths for zenity progress bar
count=$(expr $count + 1)
perc=$(expr $t / $pass)
p=$(expr $count \* $perc - 1)
echo $p
/usr/bin/kdesu -c "/usr/bin/sfill -l -l $wdrivepath"
done ) | zenity --progress --title="Free Space Wiping" --text="Wiping in progress..." --percentage=0 --auto-close
/usr/bin/zenity --info --text="The free space on drive $wdrive was wiped!"
fi
exit 0
}
kwiping