This commit is contained in:
realSnoopy 2020-06-08 12:58:57 +02:00
commit e7e67afa0a
2 changed files with 26 additions and 13 deletions

View File

@ -4,6 +4,7 @@
# Huawei KoBackup backups decryptor. # Huawei KoBackup backups decryptor.
# #
# Version History # Version History
# - 20200607: merged empty CheckMsg, update folder_to_media_type by @realSnoopy
# - 20200406: merged pull by @lp4n6, related to files and folders permissions # - 20200406: merged pull by @lp4n6, related to files and folders permissions
# - 20200405: added Python minor version check and note (thanks @lp4n6) # - 20200405: added Python minor version check and note (thanks @lp4n6)
# - 2020test: rewritten to handle v9 and v10 backups # - 2020test: rewritten to handle v9 and v10 backups
@ -56,7 +57,7 @@ from Crypto.Hash import HMAC
from Crypto.Protocol.KDF import PBKDF2 from Crypto.Protocol.KDF import PBKDF2
from Crypto.Util import Counter from Crypto.Util import Counter
VERSION = '20200406' VERSION = '20200607'
# Disabling check on doc strings and naming convention. # Disabling check on doc strings and naming convention.
# pylint: disable=C0111,C0103 # pylint: disable=C0111,C0103
@ -266,8 +267,8 @@ class Decryptor:
logging.debug('SHA256(BKEY)[%s] = %s', len(self._bkey_sha256), logging.debug('SHA256(BKEY)[%s] = %s', len(self._bkey_sha256),
binascii.hexlify(self._bkey_sha256)) binascii.hexlify(self._bkey_sha256))
try:
salt = self._checkMsg[32:] salt = self._checkMsg[32:]
if salt:
logging.debug('SALT[%s] = %s', len(salt), binascii.hexlify(salt)) logging.debug('SALT[%s] = %s', len(salt), binascii.hexlify(salt))
res = PBKDF2(self._bkey, salt, Decryptor.dklen, Decryptor.count, res = PBKDF2(self._bkey, salt, Decryptor.dklen, Decryptor.count,
@ -282,16 +283,10 @@ class Decryptor:
else: else:
logging.error('KO, backup key is wrong!') logging.error('KO, backup key is wrong!')
self._good = False self._good = False
else:
except: logging.warning('Empty CheckMsg! Cannot check backup password!')
print() logging.warning('Assuming the provided password is correct...')
logging.error('NEW TYPE of backup found!')
logging.error('no check for correct key! will try to decrypt anyway...')
logging.error('be SURE that pass is correct!')
print()
input('press ENTER to continue...or cancel script with CTRL + C')
self._good = True self._good = True
pass
def decrypt_package(self, dec_material, data): def decrypt_package(self, dec_material, data):
if not self._good: if not self._good:
@ -722,7 +717,8 @@ def decrypt_files_in_root(decrypt_info, path_in, path_out):
def decrypt_files_in_folder(decrypt_info, folder, path_out): def decrypt_files_in_folder(decrypt_info, folder, path_out):
folder_to_media_type = {'movies': 'video', 'pictures': 'photo', 'audios': 'audio', } folder_to_media_type = {'movies': 'video', 'pictures': 'photo',
'audios': 'audio', }
media_out_dir = path_out.absolute().joinpath('storage') media_out_dir = path_out.absolute().joinpath('storage')
media_unk_dir = path_out.absolute().joinpath('unknown') media_unk_dir = path_out.absolute().joinpath('unknown')

17
setup.py Normal file
View File

@ -0,0 +1,17 @@
# Setup file for compiling the python script with cx_Freeze (https://github.com/anthony-tuininga/cx_Freeze)
from cx_Freeze import setup, Executable
executables = [
Executable('kobackupdec.py')
]
setup(name='KoBackupDec',
# Change build number to the current one
version='20200607',
description='HiSuite / KoBackup Decryptor',
executables=executables
)
# Compile the python script to an executable with: python setup.py build
# Build an Windows installation Package with: python setup.py bdist_msi