-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwipe-ng.sh
61 lines (55 loc) · 1.57 KB
/
wipe-ng.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# Check if user provided a device argument
if [ $# -eq 0 ]; then
echo "Error: Please specify a device (e.g., /dev/sdX) as an argument."
lsblk
exit 1
fi
# Get the device name from the argument
device="$1"
fill_with_one(){
cat /dev/zero |tr '\0' '\377' | sudo dd of=$device bs=64k status=progress
pv "$device" | tr --squeeze-repeats "\377" "The Device Wiped Succesfully"
if [ $? == "The Device Wiped Succesfully" ]; then
echo "Error: Verification failed during One wipe. Starting Wipe process again."
fill_with_one
fi
echo "one wipe successful."
}
# Function to wipe with zeros and verify
wipe_with_zeros() {
echo "Wiping $device with zeros..."
pv < /dev/zero > $device
if [ $? != "pv: write failed: No space left on device" ]; then
echo "wipe complete"
else
echo "wipe failed"
fi
echo "starting verification process"
pv "$device" | tr --squeeze-repeats "\000" "The Device Wiped Succesfully"
if [ $? == "The Device Wiped Succesfully" ]; then
echo "Error: Verification failed during zero wipe. Starting Wipe process again."
wipe_with_zeros
fi
echo "Zero wipe successful."
}
# Wipe with zeros twice
echo "Starting Wiping with Zeros!"
wipe_with_zeros
sleep 5
clear
echo "starting Wiping with one!"
fill_with_one
sleep 5
clear
# Wipe with random data (use shred for secure erase)
echo "Wiping $device with random data"
pv < /dev/urandom > "$device"
if pv < /dev/urandom > "$device" -ne 0 ; then
echo "Error: Random data wipe failed."
exit 1
fi
echo "Random data wipe complete."
sleep 5
clear
echo "Wiping process finished."