コード例 #1
0
def DecryptFile(filePath, encryptPass):
    pyAesCrypt.decryptFile((filePath + ".aes"), filePath, encryptPass)
    secure_delete.secure_random_seed_init()
    secure_delete.secure_delete(
        (filePath + ".aes"))  #deletes the encrypted file after decrypting
    print("File decrypted")
    RevealData()
    sys.exit("Completed")
コード例 #2
0
def delete_file(request, filename, username):
    if UploadedFile.objects.filter(filename=filename,
                                   username=username).exists():
        secure_delete.secure_random_seed_init()
        secure_delete.secure_delete(f'{FILES}/{username}/{filename}')
        UploadedFile.objects.filter(filename=filename,
                                    username=username).delete()

    return redirect(index)
コード例 #3
0
def EncryptFile(filePath, encryptPass, keyphrase):
    pyAesCrypt.encryptFile(
        filePath, (filePath + '.aes'),
        encryptPass)  # encrypt to aes, default buffer is 64k
    print("File Encrypted")
    secure_delete.secure_random_seed_init()
    secure_delete.secure_delete(
        filePath
    )  # deletes the original plaintext file leaving only encrypted aes
    checkKeyphrase(filePath, encryptPass, keyphrase)
コード例 #4
0
    def get(request, username, filename):
        if UploadedFile.objects.filter(filename=filename,
                                       username=username).exists():
            secure_delete.secure_random_seed_init()
            secure_delete.secure_delete(f'{FILES}/{username}/{filename}')
            UploadedFile.objects.filter(filename=filename,
                                        username=username).delete()
            return response.Response(status=status.HTTP_200_OK)

        return response.Response(status=status.HTTP_404_NOT_FOUND)
コード例 #5
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('PATH', nargs='?', type=str)
    parser.add_argument('--count', default=1, type=int)
    parser.add_argument('--wipe_free_space', action='store_true')
    parser.add_argument('--upset_inodes', action='store_true')
    args = parser.parse_args()
    if args.PATH is None:
        parser.print_help()
        exit(0)
    if os.path.exists(args.PATH) is False:
        pass
    else:
        secure_delete.secure_delete(args.PATH, args.count)
    if args.wipe_free_space is True:
        secure_delete.wipe_free_space(args.PATH)
    if args.upset_inodes is True:
        secure_delete.upset_inodes(args.PATH, args.count)
    return
コード例 #6
0
    def wipe(self):
        errortext = []
        secure_delete.secure_random_seed_init()
        tree = etree.parse("data.xml")
        for i in tree.getroot():
            if i.tag.startswith('loc'):
                for target in i.getiterator():
                    for (root, dirs, files) in walk(target.text):           #wipe each file (3 passes by default) then remove directory
                        for f in files:                                     #if there is an error, log it and move on to the next file
                            try:
                                secure_delete.secure_delete(path.join(root, f))
                                secure_delete.os_force_remove(path.join(root, f))
                                secure_delete.upset_inodes(path.join(root, f))
                                rmtree(target.text)
                            except Exception as e:
                                # print(e)
                                errortext.append(str(e))
                                pass
        try: #now let's delete the temporary archives.
            secure_delete.secure_delete(tree.find('storage').text + '/temp')
            secure_delete.os_force_remove(tree.find('storage').text + '/temp')
            secure_delete.upset_inodes(tree.find('storage').text + '/temp')
            rmtree(tree.find('storage').text + '/temp')
        except: # Exception as e:
            # print(e)
            #errortext.append(str(e))
            pass

        if not errortext:
            text = "<strong>WARNING: the archive can be decrypted with the password in its <u>HASHED FORM</u>.</strong><br>Use any online tool to obtain it, selecting the algorithm SHA3_512."
            self.sendmail("wiped", text)
        else:           #if there were errors, add them to the report email. Which I won't read, since I'm dead.
            text = "<strong>WARNING: the archive can be decrypted with the password in its <u>HASHED FORM</u>.</strong><br>Use any online tool to obtain it, selecting the algorithm SHA3_512.<br><br>"
            for i in errortext:
                text = text + str(i) + '<br>'
            self.sendmail("wiped", text)

        self.shutdown()
コード例 #7
0
def delete_main(base_dir):
    print('Start Deleting')
    secure_delete.secure_random_seed_init()
    add_to_report('directory', base_dir)
    list_paths = secure_delete.enum_paths(base_dir)
    deleted_file_count = 0
    for file in list_paths:
        log = {
            'log_filename': os.path.basename(file),
            'log_hash': sha256sum(file),
            'log_path': file,
            'log_status': ''
        }
        try:
            secure_delete.secure_delete(file)
            log['log_status'] = 'Cleaned'
            deleted_file_count = deleted_file_count + 1
        except Exception as e:
            log['log_status'] = e.message
        add_to_report('log', log)
    #delete the folder
    shutil.rmtree(base_dir, ignore_errors=True)
    add_to_report('deleted_file',
                  '%d/%d' % (deleted_file_count, len(list_paths)))
コード例 #8
0
def DeleteFile(filePath):
    print("Incorrect phrase...deleting file")
    secure_delete.secure_random_seed_init()  #delete file if keyphrase fails
    secure_delete.secure_delete((filePath + ".aes"))
    exit()
コード例 #9
0
def delete(arg):
    # Delete files securely
    if arg == "delete":
        try:
            secure_delete.secure_random_seed_init()
            secure_delete.secure_delete("vote.state")
            secure_delete.secure_delete("recount.file")
        except IOError:
            print("Error in deleting files securely")

    elif arg == "delete recount":
        try:
            secure_delete.secure_random_seed_init()
            secure_delete.secure_delete("recount.file")
        except IOError:
            print("Error in deleting recount file securely")

    elif arg == "create":
        try:
            secure_delete.secure_random_seed_init()
            secure_delete.secure_delete("vote.state")
        except IOError:
            print("First run, creating election...")

    elif arg == "crash":
        try:
            secure_delete.secure_random_seed_init()
            secure_delete.secure_delete("vote.state")
        except IOError:
            print("Error in deleting files at crash")

    elif arg == "results":
        try:
            secure_delete.secure_random_seed_init()
            secure_delete.secure_delete("vote.state")
            raise SystemExit
        except IOError:
            print("Error in deleting files after results")