Created
November 24, 2017 12:00
-
-
Save subfission/486bd1dce787017766e0bd0a53249870 to your computer and use it in GitHub Desktop.
Secure File Wiper BashProfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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