From 38034ad07b01521035242992d30694d5293d1d1f Mon Sep 17 00:00:00 2001 From: GurpreetKang <68566314+GurpreetKang@users.noreply.github.com> Date: Mon, 8 Aug 2022 16:32:18 -0700 Subject: [PATCH 1/5] Update BitwardenDecrypt.py --- BitwardenDecrypt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BitwardenDecrypt.py b/BitwardenDecrypt.py index 90bc9cf..7d6a2c1 100644 --- a/BitwardenDecrypt.py +++ b/BitwardenDecrypt.py @@ -399,8 +399,8 @@ def decryptBitwardenJSON(options): organizationKeys = datafile['keys']['organizationKeys']['encrypted'] # Get/Decrypt All Organization Keys - for uuid, key in organizationKeys.items(): - BitwardenSecrets['OrgSecrets'][uuid] = decryptRSA(key, BitwardenSecrets['RSAPrivateKey']) + for uuid in organizationKeys.items(): + BitwardenSecrets['OrgSecrets'][uuid[0]] = decryptRSA(uuid[1]['key'], BitwardenSecrets['RSAPrivateKey']) for a in datafile['data']: From 062864703581fd661f548dd6b79833644511ee1c Mon Sep 17 00:00:00 2001 From: GurpreetKang <68566314+GurpreetKang@users.noreply.github.com> Date: Mon, 8 Aug 2022 16:32:43 -0700 Subject: [PATCH 2/5] Revert "Update BitwardenDecrypt.py" This reverts commit 38034ad07b01521035242992d30694d5293d1d1f. --- BitwardenDecrypt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BitwardenDecrypt.py b/BitwardenDecrypt.py index 7d6a2c1..90bc9cf 100644 --- a/BitwardenDecrypt.py +++ b/BitwardenDecrypt.py @@ -399,8 +399,8 @@ def decryptBitwardenJSON(options): organizationKeys = datafile['keys']['organizationKeys']['encrypted'] # Get/Decrypt All Organization Keys - for uuid in organizationKeys.items(): - BitwardenSecrets['OrgSecrets'][uuid[0]] = decryptRSA(uuid[1]['key'], BitwardenSecrets['RSAPrivateKey']) + for uuid, key in organizationKeys.items(): + BitwardenSecrets['OrgSecrets'][uuid] = decryptRSA(key, BitwardenSecrets['RSAPrivateKey']) for a in datafile['data']: From 0e60d2082197e186564e55cb415684222d797580 Mon Sep 17 00:00:00 2001 From: GurpreetKang <68566314+GurpreetKang@users.noreply.github.com> Date: Mon, 8 Aug 2022 16:37:48 -0700 Subject: [PATCH 3/5] Fix for format change in Bitwarden Desktop 2022.8.0 Initial fix for data.json file format change introduced in Bitwarden Desktop 2022.8.0. (#17) While this works for new data.json files from v2022.8.0, it will fail on files from older versions. --- BitwardenDecrypt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BitwardenDecrypt.py b/BitwardenDecrypt.py index 90bc9cf..7d6a2c1 100644 --- a/BitwardenDecrypt.py +++ b/BitwardenDecrypt.py @@ -399,8 +399,8 @@ def decryptBitwardenJSON(options): organizationKeys = datafile['keys']['organizationKeys']['encrypted'] # Get/Decrypt All Organization Keys - for uuid, key in organizationKeys.items(): - BitwardenSecrets['OrgSecrets'][uuid] = decryptRSA(key, BitwardenSecrets['RSAPrivateKey']) + for uuid in organizationKeys.items(): + BitwardenSecrets['OrgSecrets'][uuid[0]] = decryptRSA(uuid[1]['key'], BitwardenSecrets['RSAPrivateKey']) for a in datafile['data']: From c604c2968e4f0f55344e11a5b97a4bc0e3c4ca32 Mon Sep 17 00:00:00 2001 From: GurpreetKang <68566314+GurpreetKang@users.noreply.github.com> Date: Mon, 8 Aug 2022 16:58:38 -0700 Subject: [PATCH 4/5] Fix for format change in Bitwarden Desktop v2022.8.0 Fix for data.json file format change introduced in Bitwarden Desktop 2022.8.0. (#17) Fix support for pre Desktop 2022.8.0 data.json files. --- BitwardenDecrypt.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/BitwardenDecrypt.py b/BitwardenDecrypt.py index 7d6a2c1..20e9484 100644 --- a/BitwardenDecrypt.py +++ b/BitwardenDecrypt.py @@ -400,9 +400,16 @@ def decryptBitwardenJSON(options): # Get/Decrypt All Organization Keys for uuid in organizationKeys.items(): - BitwardenSecrets['OrgSecrets'][uuid[0]] = decryptRSA(uuid[1]['key'], BitwardenSecrets['RSAPrivateKey']) + # File Format >= Desktop 2022.8.0 + if type(uuid[1]) is dict: + BitwardenSecrets['OrgSecrets'][uuid[0]] = decryptRSA(uuid[1]['key'], BitwardenSecrets['RSAPrivateKey']) + # File Format < Desktop 2022.8.0 + elif type(uuid[1]) is str: + BitwardenSecrets['OrgSecrets'][uuid[0]] = decryptRSA(uuid[1], BitwardenSecrets['RSAPrivateKey']) + else: + print(f"ERROR: Could Not Determine Organization Keys From File Format") + - for a in datafile['data']: supportedGroups = ['folders', 'ciphers', 'collections', 'organizations'] From 5c36331d185df38d664faf3fba968f633f63fb60 Mon Sep 17 00:00:00 2001 From: GurpreetKang <68566314+GurpreetKang@users.noreply.github.com> Date: Mon, 8 Aug 2022 17:08:54 -0700 Subject: [PATCH 5/5] Fix for format change in Bitwarden Desktop v2022.8.0 Code cleanup. #17 --- BitwardenDecrypt.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/BitwardenDecrypt.py b/BitwardenDecrypt.py index 20e9484..ecd3c37 100644 --- a/BitwardenDecrypt.py +++ b/BitwardenDecrypt.py @@ -399,13 +399,13 @@ def decryptBitwardenJSON(options): organizationKeys = datafile['keys']['organizationKeys']['encrypted'] # Get/Decrypt All Organization Keys - for uuid in organizationKeys.items(): + for uuid, value in organizationKeys.items(): # File Format >= Desktop 2022.8.0 - if type(uuid[1]) is dict: - BitwardenSecrets['OrgSecrets'][uuid[0]] = decryptRSA(uuid[1]['key'], BitwardenSecrets['RSAPrivateKey']) + if type(value) is dict: + BitwardenSecrets['OrgSecrets'][uuid] = decryptRSA(value['key'], BitwardenSecrets['RSAPrivateKey']) # File Format < Desktop 2022.8.0 - elif type(uuid[1]) is str: - BitwardenSecrets['OrgSecrets'][uuid[0]] = decryptRSA(uuid[1], BitwardenSecrets['RSAPrivateKey']) + elif type(value) is str: + BitwardenSecrets['OrgSecrets'][uuid] = decryptRSA(value, BitwardenSecrets['RSAPrivateKey']) else: print(f"ERROR: Could Not Determine Organization Keys From File Format")