Last active
September 23, 2019 15:42
-
-
Save ramizdemiurge/62807691e0494ccfcaeb1a54da3fac01 to your computer and use it in GitHub Desktop.
🧹 Data wiper
This file contains 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
#!/usr/bin/python3 | |
#sudo apt install wipe | |
import os | |
import sys | |
def query_yes_no(question, default="yes"): | |
valid = {"yes": True, "y": True, "ye": True, | |
"no": False, "n": False} | |
if default is None: | |
prompt = " [y/n] " | |
elif default == "yes": | |
prompt = " [Y/n] " | |
elif default == "no": | |
prompt = " [y/N] " | |
else: | |
raise ValueError("invalid default answer: '%s'" % default) | |
while True: | |
sys.stdout.write(question + prompt) | |
choice = input().lower() | |
if default is not None and choice == '': | |
return valid[default] | |
elif choice in valid: | |
return valid[choice] | |
else: | |
sys.stdout.write("Please respond with 'yes' or 'no' " | |
"(or 'y' or 'n').\n") | |
first_arg = sys.argv[1] | |
if first_arg == "-h" or first_arg == "--help": | |
print("Shreds a data") | |
print("Send file path in arg, and add / if it's a folder") | |
elif query_yes_no("Wipe/shred "+first_arg+ "?"): | |
if first_arg.endswith("/"): | |
os.system("wipe -q -rf " + first_arg) | |
else: | |
os.system("shred -n 3 -u -z -v " + first_arg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment