jbsparrow / CyberDropDownloader

Bulk Gallery Downloader for Cyberdrop.me and Other Sites
GNU General Public License v3.0
164 stars 13 forks source link

[BUG] Browser cookie extraction fails due to chromium security improvement #175

Closed baccccccc closed 1 week ago

baccccccc commented 1 week ago
Editing Forum Authentication Values
? What would you like to do? Browser Cookie Extraction
? Which browser should we load cookies from? Edge
Traceback (most recent call last):
  File "C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\browser_cookie3\__init__.py", line 539, in _decrypt
    return self._decrypt_windows_chromium(value, encrypted_value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\browser_cookie3\__init__.py", line 530, in _decrypt_windows_chromium
    _, data = _crypt_unprotect_data(encrypted_value)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\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:

Traceback (most recent call last):
  File "C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\browser_cookie3\__init__.py", line 555, in _decrypt
    data = aes.decrypt_and_verify(encrypted_value[12:-16], tag)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\Cryptodome\Cipher\_mode_gcm.py", line 567, in decrypt_and_verify
    self.verify(received_mac_tag)
  File "C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\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:

Traceback (most recent call last):
  File "C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\cyberdrop_dl\main.py", line 195, in <module>
    main()
  File "C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\cyberdrop_dl\main.py", line 177, in main
    manager = startup()
              ^^^^^^^^^
  File "C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\cyberdrop_dl\main.py", line 29, in startup
    program_ui(manager)
  File "C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\cyberdrop_dl\ui\ui.py", line 190, in program_ui
    edit_authentication_values_prompt(manager)
  File "C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\cyberdrop_dl\ui\prompts\settings_authentication_prompts.py", line 43, in edit_authentication_values_prompt
    edit_forum_authentication_values_prompt(manager)
  File "C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\cyberdrop_dl\ui\prompts\settings_authentication_prompts.py", line 134, in edit_forum_authentication_values_prompt
    get_forum_cookies(manager, "edge")
  File "C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\cyberdrop_dl\utils\args\browser_cookie_extraction.py", line 24, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\cyberdrop_dl\utils\args\browser_cookie_extraction.py", line 47, in get_forum_cookies
    cookie = get_cookie(browser, forum)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\cyberdrop_dl\utils\args\browser_cookie_extraction.py", line 68, in get_cookie
    cookie = browser_cookie3.edge(domain_name=domain)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\browser_cookie3\__init__.py", line 1195, in edge
    return Edge(cookie_file, domain_name, key_file).load()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\browser_cookie3\__init__.py", line 515, in load
    value = self._decrypt(value, enc_value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<username>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\browser_cookie3\__init__.py", line 557, in _decrypt
    raise BrowserCookieError(
browser_cookie3.BrowserCookieError: Unable to get key for cookie decryption

my understanding is that CDL depends on browser_cookie3 and in fact, they already have a corresponding issue open. As such, I do not expect CDL to solve this by itself.

but maybe add a temporary warning message, so that people don't try this while it's broken? And/or allow to enter username and password instead of relying on cookies? (I know I can do this by editing authentication.yaml but not sure it works without the corresponding cookie.)

baccccccc commented 1 week ago

also, maybe improve error handling?

jbsparrow commented 1 week ago

We are working on better error handling in development branches. For newest development versions you can visit the pypi page: https://pypi.org/project/cyberdrop-dl-patched/#history

jbsparrow commented 1 week ago

Just released version 5.7.0.dev21 which is very experimental. It combines something like 7 PRs.

The changes include:

There may be a few small issues since it's such a large change but I looked over all the code and there was nothing that jumped out at me.