browsercookie icon indicating copy to clipboard operation
browsercookie copied to clipboard

Cookie extraction stopped working on Chrome 130 (Mac OS)

Open emiespo opened this issue 1 year ago • 2 comments

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.

emiespo avatar Oct 31 '24 19:10 emiespo

same problem on me,check https://github.com/borisbabic/browser_cookie3/issues/214 and https://github.com/borisbabic/browser_cookie3/issues/210
it may help

realwatch avatar Nov 05 '24 07:11 realwatch

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.

emiespo avatar Nov 29 '24 16:11 emiespo