Jump to content
Usr6

[Python] Almost secure file eraser

Recommended Posts

Posted

KHJnuaX.jpg

#!/usr/bin/env python

import sys

import os

import random

import argparse

print """

#################################

# Rst Almost secure file eraser #

# Usr6 #

#################################"""

parser = argparse.ArgumentParser(description="RST Almost secure file eraser")

parser.add_argument("input", metavar="path/file",

help="sterge fisierul")

parser.add_argument("-m", "--maxstr", metavar="nr", default = 3000000,

help="cati octeti vor fi scrisi la fiecare trecere")

args = parser.parse_args()

def aleator(l):

print random.choice("~*&^%$#@!"),

variabila = ''

for i in range(l):

variabila += random.choice('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890')

return variabila

def writefile(fisier, drepturi, nr):

with open(fisier, drepturi) as handle:

handle.write(aleator(nr))

handle.close

size = os.path.getsize(args.input)

print args.input, size, args.maxstr

ask = raw_input("Esti sigur ca vrei sa-l stergi definitiv?(y/n): ")

if ask != "Yes" and ask != "YES" and ask != "yes" and ask != "Y" and ask != "y":

sys.exit("Nu am sters nimic")

if size <= int(args.maxstr):

writefile(args.input, "wb", size)

else:

writefile(args.input, "wb", int(args.maxstr))

size -= int(args.maxstr)

while size !=0:

if size <= int(args.maxstr):

writefile(args.input, "ab", size)

break

else:

writefile(args.input, "ab", int(args.maxstr))

size -= int(args.maxstr)

if not os.remove(args.input):

print "\n%s deleted" %(args.input)

sys.exit(raw_input("press enter..."))

utilizare:


file_eraser.py filename

help:


file_eraser.py -h

adaugare in context menu(click dreapta):regedit

HKEY_CLASSES_ROOT/*/shell
New key: Eraser
(Default) REG_SZ Eraser...
HKEY_CLASSES_ROOT/*/shell/Eraser
New key: command
(Default) REG_SZ python C:\\Python27\\file_eraser.py "%1"

  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...