Skip to content

Instantly share code, notes, and snippets.

@naftulikay
Created July 10, 2014 03:34
Show Gist options
  • Save naftulikay/a2a262d64e0c39eff06a to your computer and use it in GitHub Desktop.
Save naftulikay/a2a262d64e0c39eff06a to your computer and use it in GitHub Desktop.
Android Secure Shred
#!/sbin/sh
# To be used with extreme caution.
# This script will utterly and totally obliterate any block device
# you pass to it. It was designed for use on Android for secure
# wiping of devices, but could probably be used otherwise.
# DO NOT USE THIS UNLESS YOU ARE ABSOLUTELY SURE OF WHAT YOU'RE DOING
help_text="usage: obliterate [partition]"
if [ -z "$1" ]; then
echo "$help_text" >&2
exit 1
fi
# must be a block device
if [ ! -b "$1" ]; then
echo "$1 is not a block device; we can't obliterate it." >&2
exit 1
fi
##################################
### ALL HAIL DESTROYER OF DISKS ##
##################################
echo "YOUR DISK IS ABOUT TO BE UTTERLY OBLITERATED, YOU HAVE 5 SECONDS TO CANCEL (Ctrl+C)"
sleep 6
# zero it out, baby
echo "$1: zeroing out everything..."
dd if=/dev/zero of=$1 bs=512
# random it out, baby
echo "$1: randoming out everything..."
dd if=/dev/urandom of=$1 bs=512
# final zero pass
echo "$1: final zero pass..."
dd if=/dev/zero of=$1 bs=512
echo "Your disk has been OBLITERATED."
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment