Skip to content

Instantly share code, notes, and snippets.

@subfission
Created November 24, 2017 12:00
Show Gist options
  • Save subfission/486bd1dce787017766e0bd0a53249870 to your computer and use it in GitHub Desktop.
Save subfission/486bd1dce787017766e0bd0a53249870 to your computer and use it in GitHub Desktop.
Secure File Wiper BashProfile
# Secure File Wiper
#
# Description
# Add this function to the bottom of your bash profile for a quick
# and dirty secure file clean. Works with Linux & MacOS.
#
# @author: Zach Jetson
#
secure_delete() {
DD_FILE=$1
BLK_SZ=`wc -c < $DD_FILE`
[[ BLK_SZ -eq 0 ]] && echo "[!] Invalid file" && return
echo "Zeroing file ${DD_FILE}"
dd if=/dev/zero of=$DD_FILE count=1 conv=notrunc bs=$BLK_SZ 2> /dev/null
rm -f "$DD_FILE"
echo "[!] Securely erased $BLK_SZ bytes"
}
super_secure_delete(){
DD_FILE=$1
BLK_SZ=`wc -c < $DD_FILE`
[[ BLK_SZ -eq 0 ]] && echo "[!] Invalid file" && return
echo "DoD grade file erase ${DD_FILE}"
for ((n=1;n<8;n++))
do
dd if=/dev/zero of=$DD_FILE count=1 conv=notrunc bs=$BLK_SZ 2> /dev/null
done
rm -f "$DD_FILE"
echo "[!] Securely erased $BLK_SZ bytes"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment