Usr6 Posted June 22, 2014 Report Posted June 22, 2014 #!/usr/bin/env pythonimport sysimport osimport randomimport argparseprint """################################## 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 variabiladef writefile(fisier, drepturi, nr): with open(fisier, drepturi) as handle: handle.write(aleator(nr)) handle.closesize = os.path.getsize(args.input)print args.input, size, args.maxstrask = 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 filenamehelp:file_eraser.py -hadaugare in context menu(click dreapta):regeditHKEY_CLASSES_ROOT/*/shellNew key: Eraser(Default) REG_SZ Eraser...HKEY_CLASSES_ROOT/*/shell/EraserNew key: command(Default) REG_SZ python C:\\Python27\\file_eraser.py "%1" 1 Quote