Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chromium: handle latest sqlite schema #215

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

Arth-ur
Copy link
Contributor

@Arth-ur Arth-ur commented Oct 25, 2024

@Eitol
Copy link

Eitol commented Oct 26, 2024

@borisbabic Support for the latest version of Chrome is broken. This fixes the problem

@wimglenn
Copy link
Contributor

wimglenn commented Oct 28, 2024

Until a fix is merged, to install directly from this PR:

pip install --force-reinstall git+https://github.com/borisbabic/browser_cookie3.git@refs/pull/215/head

@amitkumarwali
Copy link

Until a fix is merged, to install directly from this PR:

pip install git+https://github.com/borisbabic/browser_cookie3.git@refs/pull/215/head

I still get error after this, am i missing something?

On Chrome:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\amitw\AppData\Local\Programs\Python\Python311\Lib\site-packages\browser_cookie3\__init__.py", line 578, in _decrypt
    data = aes.decrypt_and_verify(encrypted_value[12:-16], tag)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\amitw\AppData\Local\Programs\Python\Python311\Lib\site-packages\Cryptodome\Cipher\_mode_gcm.py", line 567, in decrypt_and_verify
    self.verify(received_mac_tag)
  File "C:\Users\amitw\AppData\Local\Programs\Python\Python311\Lib\site-packages\Cryptodome\Cipher\_mode_gcm.py", line 508, in verify
    raise ValueError("MAC check failed")
ValueError: MAC check failed


During handling of the above exception, another exception occurred:


File "C:\Users\amitw\AppData\Local\Programs\Python\Python311\Lib\site-packages\browser_cookie3\__init__.py", line 1186, in chrome
    return Chrome(cookie_file, domain_name, key_file).load()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\amitw\AppData\Local\Programs\Python\Python311\Lib\site-packages\browser_cookie3\__init__.py", line 516, in load
    value = self._decrypt(value, enc_value, has_integrity_check_for_cookie_domain)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\amitw\AppData\Local\Programs\Python\Python311\Lib\site-packages\browser_cookie3\__init__.py", line 580, in _decrypt
    raise BrowserCookieError(
browser_cookie3.BrowserCookieError: Unable to get key for cookie decryption

On Vivaldi


Traceback (most recent call last):
  File "C:\Users\amitw\AppData\Local\Programs\Python\Python311\Lib\site-packages\browser_cookie3\__init__.py", line 562, in _decrypt
    return self._decrypt_windows_chromium(value, encrypted_value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\amitw\AppData\Local\Programs\Python\Python311\Lib\site-packages\browser_cookie3\__init__.py", line 553, in _decrypt_windows_chromium
    _, data = _crypt_unprotect_data(encrypted_value)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\amitw\AppData\Local\Programs\Python\Python311\Lib\site-packages\browser_cookie3\__init__.py", line 89, in _crypt_unprotect_data
    raise RuntimeError('Failed to decrypt the cipher text with DPAPI')
RuntimeError: Failed to decrypt the cipher text with DPAPI

During handling of the above exception, another exception occurred:


File "C:\Users\amitw\AppData\Local\Programs\Python\Python311\Lib\site-packages\browser_cookie3\__init__.py", line 1228, in vivaldi
    return Vivaldi(cookie_file, domain_name, key_file).load()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\amitw\AppData\Local\Programs\Python\Python311\Lib\site-packages\browser_cookie3\__init__.py", line 516, in load
    value = self._decrypt(value, enc_value, has_integrity_check_for_cookie_domain)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\amitw\AppData\Local\Programs\Python\Python311\Lib\site-packages\browser_cookie3\__init__.py", line 582, in _decrypt
    return data.decode()
           ^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd8 in position 3: invalid continuation byte

@bluesmilery
Copy link

bluesmilery commented Oct 29, 2024

@amitkumarwali
Try the following command:
pip install --force-reinstall --no-deps git+https://github.com/borisbabic/browser_cookie3.git@refs/pull/215/head

--force-reinstall: This flag is used to overwrite the installation of browser_cookie3.
--no-deps: This flag is used to prevent upgrading other dependent packages.

@amitkumarwali
Copy link

@amitkumarwali Try the following command: pip install --force-reinstall --no-deps git+https://github.com/borisbabic/browser_cookie3.git@refs/pull/215/head

--force-reinstall: This flag is used to overwrite the installation of browser_cookie3. --no-deps: This flag is used to prevent upgrading other dependent packages.

Thank you for taking out time and suggesting fix, appreciate it.

Tried the above way but this doesnt seem to work for me. Also tried in a complete new venv but still end up in same error as stated above. In case i can check/debug something, please let me know. thank you again.

     83 if not ctypes.windll.crypt32.CryptUnprotectData(
     84         ctypes.byref(blob_in), ctypes.byref(
     85             desc), ctypes.byref(blob_entropy),
     86         reserved, prompt_struct, CRYPTPROTECT_UI_FORBIDDEN, ctypes.byref(
     87             blob_out)
     88 ):
---> 89     raise RuntimeError('Failed to decrypt the cipher text with DPAPI')
     91 description = desc.value

RuntimeError: Failed to decrypt the cipher text with DPAPI

During handling of the above exception, another exception occurred





    [507] if mac1.digest() != mac2.digest():
--> [508]     raise ValueError("MAC check failed")
ValueError: MAC check failed





    578             data = aes.decrypt_and_verify(encrypted_value[12:-16], tag)
    579         except ValueError:
--> 580             raise BrowserCookieError(
    581                 'Unable to get key for cookie decryption')
    582         return data.decode()
    584 if value or (encrypted_value[:3] not in [b'v11', b'v10']):

BrowserCookieError: Unable to get key for cookie decryption

@Arth-ur Arth-ur force-pushed the chrome-schema-update branch from ed7b3b9 to a3790b9 Compare October 31, 2024 19:19
@Arth-ur
Copy link
Contributor Author

Arth-ur commented Oct 31, 2024

@amitkumarwali I've updated my branch, could you try again if it fixes your problem on Vivaldi?

I don't think it will fix Chrome on Windows because of this https://security.googleblog.com/2024/07/improving-security-of-chrome-cookies-on.html

@amitkumarwali
Copy link

@Arth-ur - thank you, this fixed my issue on Vivaldi. Appreciate your kind and quick help.

@justinnewitter
Copy link

This PR fixes the issue for me as well. Hope this gets into a release soon 😄

@pjaudiomv
Copy link

@rafiibrahim8 any chance we can get some eyes on this

@AlexUnderTheTable
Copy link

AlexUnderTheTable commented Nov 26, 2024

Until a fix is merged, to install directly from this PR:

pip install --force-reinstall git+https://github.com/borisbabic/browser_cookie3.git@refs/pull/215/head

WARNING: Did not find branch or tag 'refs/pull/215/head', assuming revision or ref
How to install this fix?

@ehbello
Copy link

ehbello commented Nov 26, 2024

WARNING: Did not find branch or tag 'refs/pull/215/head', assuming revision or ref

That's a warning. You can ignore it 😉

@Xylot
Copy link

Xylot commented Dec 2, 2024

@borisbabic @rafiibrahim8 Can we get this reviewed & merged? It would be a huge help to those currently relying on the PR branch

@borisbabic borisbabic merged commit 6109dab into borisbabic:master Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BrowserCookieError: Unable to get key for cookie decryption