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

Cookie extraction stopped working on Chrome 130 (Mac OS) #26

Open
emiespo opened this issue Oct 31, 2024 · 2 comments
Open

Cookie extraction stopped working on Chrome 130 (Mac OS) #26

emiespo opened this issue Oct 31, 2024 · 2 comments

Comments

@emiespo
Copy link

emiespo commented Oct 31, 2024

I have been using browsercookie in a custom script to fetch API values (for months), but it seems the latest version of Chrome changed something and bc is not able to extract cookies anymore.

Chrome version: Version 130.0.6723.92 (Official Build) (arm64) - Mac OS Sonoma 14.7.1 (23H222)

Traceback (most recent call last):
  File "scripts/script.py", line 98, in cookie_extract
    cj = browsercookie.chrome()
         ^^^^^^^^^^^^^^^^^^^^^^
  File "projects/miscellaneous-scripts/.venv/lib/python3.12/site-packages/browsercookie/__init__.py", line 540, in chrome
    return Chrome(cookie_files).load()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "projects/miscellaneous-scripts/.venv/lib/python3.12/site-packages/browsercookie/__init__.py", line 99, in load
    for cookie in sorted(self.get_cookies(), key=lambda cookie: cookie.expires):
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "projects/miscellaneous-scripts/.venv/lib/python3.12/site-packages/browsercookie/__init__.py", line 168, in get_cookies
    value = self._decrypt(item[5], item[6], item[4], item[1], key=key)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "projects/miscellaneous-scripts/.venv/lib/python3.12/site-packages/browsercookie/__init__.py", line 195, in _decrypt
    return clean(decrypted)
           ^^^^^^^^^^^^^^^^
  File "projects/miscellaneous-scripts/.venv/lib/python3.12/site-packages/browsercookie/__init__.py", line 188, in clean
    return x[:-last].decode('utf8')
           ^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbc in position 1: invalid start byte

I tried to delete cookies a few times and got different values for the hex value of the byte in position 1.

Please note that the same script still works perfectly under Firefox, whereas using Safari the script does not throw an error and just exits back to the shell.

@realwatch
Copy link

realwatch commented Nov 5, 2024

same problem on me,check borisbabic/browser_cookie3#214 and borisbabic/browser_cookie3#210
it may help

@emiespo
Copy link
Author

emiespo commented Nov 29, 2024

Thanks I tried the patched branch, now it won't die with an error anymore, but still the cookies I need are missing (actually the entire domain is gone).

For now I'll stick to using Firefox instead of Chrome.

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

No branches or pull requests

2 participants