-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevastator
More file actions
executable file
·80 lines (68 loc) · 1.44 KB
/
devastator
File metadata and controls
executable file
·80 lines (68 loc) · 1.44 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#! /bin/sh
iter=1
zeroing=false
while getopts ":0hc:d:" opt; do
case ${opt} in
c)
temp=${OPTARG}
case $temp in
''|*[!0-9]*)
echo "Invalid Count"
exit 1
;;
0)
echo "Zero times? Really?"
exit 1
;;
*)
iter=$temp
;;
esac
;;
d)
if [ -c $OPTARG ]
then
device=$OPTARG
size=`diskinfo $device | awk '{print $3}'`
else
echo "Not a valid device"
exit 1
fi
;;
0)
zeroing=true
;;
h)
echo "devastator"
echo "A quick and dirty 'secure' device scrubber"
echo "Usage: $0 [optional flags] -d <device node>"
echo "Flags:"
echo "-0 enable aditional zeroing pass"
echo "-c <count> for multiple iterations"
echo "-h what you're reading"
exit
;;
*)
echo "Invalid option"
exit 1
;;
esac
done
if [ -z $device ]
then
echo "Missing device node"
exit 1
fi
count=0
while [ $count -lt $iter ]
do
count=`expr $count + 1`
echo "Pass $count of $iter"
openssl enc -bf -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | b64encode -r -)" -nosalt </dev/zero | pv -bartpes $size | dd bs=64k of=$device >/dev/null 2>&1
echo "^ thanks OpenSSL for not implementing SIGPIPE correctly"
done
if [ "$zeroing" = true ]
then
echo "Zero Pass"
dd if=/dev/zero bs=1024k | pv -bartpes $size | dd bs=1024k of=$device >/dev/null 2>&1
fi