From 13326d951149877d296ad4e788a2dc46b6c0cd3e Mon Sep 17 00:00:00 2001 From: dfirfpi Date: Sun, 7 Jun 2020 18:10:50 +0200 Subject: [PATCH 1/3] Added fixes by @realSnoopy --- kobackupdec.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/kobackupdec.py b/kobackupdec.py index 81727f4..0aefbc1 100644 --- a/kobackupdec.py +++ b/kobackupdec.py @@ -4,6 +4,7 @@ # Huawei KoBackup backups decryptor. # # Version History +# - 20200607: merged empty CheckMsg, update folder_to_media_type by @realSnoopy # - 20200406: merged pull by @lp4n6, related to files and folders permissions # - 20200405: added Python minor version check and note (thanks @lp4n6) # - 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.Util import Counter -VERSION = '20200406' +VERSION = '20200607' # Disabling check on doc strings and naming convention. # pylint: disable=C0111,C0103 @@ -267,20 +268,25 @@ class Decryptor: binascii.hexlify(self._bkey_sha256)) salt = self._checkMsg[32:] - logging.debug('SALT[%s] = %s', len(salt), binascii.hexlify(salt)) + if salt: + logging.debug('SALT[%s] = %s', len(salt), binascii.hexlify(salt)) - res = PBKDF2(self._bkey, salt, Decryptor.dklen, Decryptor.count, - Decryptor.prf, hmac_hash_module=None) - logging.debug('KEY check expected = %s', - binascii.hexlify(self._checkMsg[:32])) - logging.debug('RESULT = %s', binascii.hexlify(res)) + res = PBKDF2(self._bkey, salt, Decryptor.dklen, Decryptor.count, + Decryptor.prf, hmac_hash_module=None) + logging.debug('KEY check expected = %s', + binascii.hexlify(self._checkMsg[:32])) + logging.debug('RESULT = %s', binascii.hexlify(res)) - if res == self._checkMsg[:32]: - logging.info('OK, backup key is correct!') - self._good = True + if res == self._checkMsg[:32]: + logging.info('OK, backup key is correct!') + self._good = True + else: + logging.error('KO, backup key is wrong!') + self._good = False else: - logging.error('KO, backup key is wrong!') - self._good = False + logging.warning('Empty CheckMsg! Cannot check backup password!') + logging.warning('Assuming the provided password is correct...') + self._good = True def decrypt_package(self, dec_material, data): if not self._good: @@ -711,7 +717,8 @@ def decrypt_files_in_root(decrypt_info, path_in, path_out): def decrypt_files_in_folder(decrypt_info, folder, path_out): - folder_to_media_type = {'movies': 'video', 'pictures': 'photo'} + folder_to_media_type = {'movies': 'video', 'pictures': 'photo', + 'audios': 'audio', } media_out_dir = path_out.absolute().joinpath('storage') media_unk_dir = path_out.absolute().joinpath('unknown') From f38df74a64c85ebe7d5bae57bfa65294fe82f7a8 Mon Sep 17 00:00:00 2001 From: Francesco Picasso Date: Sun, 7 Jun 2020 18:47:27 +0200 Subject: [PATCH 2/3] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..0213c2f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,26 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**NOTE** +Please consider that some errors could be handled only by providing the info.xml file and the files related to the issue (e.g. a file that cannot be decrypted). If the files needed to understand the bug could contain personal data of any kind, DO NOT SEND THEM. Instead, provide samples that can be shared and with a limited size. Thanks. + +**Required info (please complete the following information):** + - Huawei Kobackup version: + - Host: [Windows / Linux ] + - Kobackup script version: + - Kobackup output log (use -vvv) + +**Additional context** +Add any other context about the problem here. + +**Screenshots** +If applicable, add screenshots to help explain your problem. From e36167743d22a06cd2d9b1d76a4ebd88cb9f9174 Mon Sep 17 00:00:00 2001 From: dfirfpi Date: Sun, 7 Jun 2020 18:52:27 +0200 Subject: [PATCH 3/3] added setup.py by @michaelfsantos --- setup.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 setup.py diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..5a679db --- /dev/null +++ b/setup.py @@ -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