예제 #1
0
def decrypt_all(files, key=None, password=None):
    key = key or decrypt.key_from_password(password or decrypt.prompt_for_password())
    
    print "Decrypting files"
    failed_files = []
    for file_name in files:
        success = dbdecrypt.decrypt_if_not_db_file(file_name, key, options.extension)
        if not success:
            failed_files.append(file_name)
    if failed_files:
        print "\n\n\nWARNING: Some of the files failed to decrypt!  \nType another password to attempt to decrypt these files, \nor leave blank to continue without decrypting the remaining files.\n"
        another_password = decrypt.prompt_for_password()
        if another_password:
            decrypt_all(failed_files, password=another_password)
예제 #2
0
def decrypt_all(files, key=None, password=None):
    key = key or decrypt.key_from_password(password
                                           or decrypt.prompt_for_password())

    print "Decrypting files"
    failed_files = []
    for file_name in files:
        success = dbdecrypt.decrypt_if_not_db_file(file_name, key,
                                                   options.extension)
        if not success:
            failed_files.append(file_name)
    if failed_files:
        print "\n\n\nWARNING: Some of the files failed to decrypt!  \nType another password to attempt to decrypt these files, \nor leave blank to continue without decrypting the remaining files.\n"
        another_password = decrypt.prompt_for_password()
        if another_password:
            decrypt_all(failed_files, password=another_password)
예제 #3
0
        decrypt.decrypt([file_name], key, extension)
        if is_funf_database(file_name):
            print "Success!"
            return True
        else:
            print "FAILED!!!!"
            print "File is either encrypted with another method, another key, or is not a valid sqlite3 db file."
            print "Keeping original file."
            shutil.move(decrypt.backup_file(file_name, extension), file_name)
            return False

if __name__ == '__main__':
    usage = "%prog [options] [sqlite_file1.db [sqlite_file2.db...]]"
    description = "Safely decrypt Sqlite3 db files.  Checks to see if the file can be opened by Sqlite.  If so, the file is left alone, otherwise the file is decrypted.  Uses the decrypt script, so it always keeps a backup of the original encrypted files. "
    parser = OptionParser(usage="%s\n\n%s" % (usage, description))
    parser.add_option("-i", "--inplace", dest="extension", default=None,
                      help="The extension to rename the original file to.  Will not overwrite file if it already exists. Defaults to '%s'." % decrypt.default_extension,)
    parser.add_option("-k", "--key", dest="key", default=None,
                      help="The DES key used to decrypt the files.  Uses the default hard coded one if one is not supplied.",)
    parser.add_option("-p", "--pass", dest="password", default=None,
                      help="The password used to decrypt the files.",)
    (options, args) = parser.parse_args()
    if options.key:
        key = options.key
    elif options.password:
        key = decrypt.key_from_password(options.password)
    else:
        key = decrypt.key_from_password(decrypt.prompt_for_password())
    for file_name in args:
        decrypt_if_not_db_file(file_name, key, options.extension)
예제 #4
0
if __name__ == "__main__":
    usage = "%prog [options] [sqlite_file1.db [sqlite_file2.db...]]"
    description = "Safely decrypt Sqlite3 db files.  Checks to see if the file can be opened by Sqlite.  If so, the file is left alone, otherwise the file is decrypted.  Uses the decrypt script, so it always keeps a backup of the original encrypted files. "
    parser = OptionParser(usage="%s\n\n%s" % (usage, description))
    parser.add_option(
        "-i",
        "--inplace",
        dest="extension",
        default=None,
        help="The extension to rename the original file to.  Will not overwrite file if it already exists. Defaults to '%s'."
        % decrypt.default_extension,
    )
    parser.add_option(
        "-k",
        "--key",
        dest="key",
        default=None,
        help="The DES key used to decrypt the files.  Uses the default hard coded one if one is not supplied.",
    )
    (options, args) = parser.parse_args()
    key = options.key if options.key else decrypt.key_from_password(decrypt.prompt_for_password())

    try:
        for file_name in args:
            decrypt_if_not_db_file(file_name, key, options.extension)
    except Exception as e:
        import sys

        sys.exit("ERROR: " + str(e))
예제 #5
0
            print "Keeping original file."
            shutil.move(decrypt.backup_file(file_name, extension), file_name)
            return False


if __name__ == '__main__':
    usage = "%prog [options] [sqlite_file1.db [sqlite_file2.db...]]"
    description = "Safely decrypt Sqlite3 db files.  Checks to see if the file can be opened by Sqlite.  If so, the file is left alone, otherwise the file is decrypted.  Uses the decrypt script, so it always keeps a backup of the original encrypted files. "
    parser = OptionParser(usage="%s\n\n%s" % (usage, description))
    parser.add_option(
        "-i",
        "--inplace",
        dest="extension",
        default=None,
        help=
        "The extension to rename the original file to.  Will not overwrite file if it already exists. Defaults to '%s'."
        % decrypt.default_extension,
    )
    parser.add_option(
        "-k",
        "--key",
        dest="key",
        default=None,
        help=
        "The DES key used to decrypt the files.  Uses the default hard coded one if one is not supplied.",
    )
    (options, args) = parser.parse_args()
    key = options.key if options.key else decrypt.key_from_password(
        decrypt.prompt_for_password())
    for file_name in args:
        decrypt_if_not_db_file(file_name, key, options.extension)
예제 #6
0
    else:
        #print ("Attempting to decrypt: '%s'..." % file_name),
        decrypt.decrypt([file_name], key, extension)
        if is_funf_database(file_name):
            #print "Success!"
            return True
        else:
            print "FAILED!!!!"
            print "File is either encrypted with another method, another key, or is not a valid sqlite3 db file."
            print "Keeping original file."
            shutil.move(decrypt.backup_file(file_name, extension), file_name)
            return False

if __name__ == '__main__':
    usage = "%prog [options] [sqlite_file1.db [sqlite_file2.db...]]"
    description = "Safely decrypt Sqlite3 db files.  Checks to see if the file can be opened by Sqlite.  If so, the file is left alone, otherwise the file is decrypted.  Uses the decrypt script, so it always keeps a backup of the original encrypted files. "
    parser = OptionParser(usage="%s\n\n%s" % (usage, description))
    parser.add_option("-i", "--inplace", dest="extension", default=None,
                      help="The extension to rename the original file to.  Will not overwrite file if it already exists. Defaults to '%s'." % decrypt.default_extension,)
    parser.add_option("-k", "--key", dest="key", default=None,
                      help="The DES key used to decrypt the files.  Uses the default hard coded one if one is not supplied.",)
    (options, args) = parser.parse_args()
    key = options.key if options.key else decrypt.key_from_password(decrypt.prompt_for_password())
    
    try:
        for file_name in args:
            decrypt_if_not_db_file(file_name, key, options.extension)
    except Exception as e:
        import sys
        sys.exit("ERROR: " + str(e))