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

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

Closed
baccccccc opened this issue Oct 19, 2024 · 3 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@baccccccc
Copy link

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 baccccccc added the bug Something isn't working label Oct 19, 2024
@baccccccc
Copy link
Author

also, maybe improve error handling?

@jbsparrow
Copy link
Owner

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
Copy link
Owner

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

The changes include:

  • Rotating log files (no more overwriting old logs! Will probably make it keep something like 5 previous logs.)
  • Add support for https://tokyomotion.net URLs
  • Add support for https://xxxbunker.com URLs
  • Drop the temp referrer table only if it exists
  • Update bunkr crawler to fix some rare error conditions
  • Prevents crashes when there are insufficient permissions to move a file
  • Simplify hashing conditions
  • Update bunkr crawler to work with new website
  • Fix an issue with deleting empty files
  • Add support for https://saint2.su albums
  • Add a universal cookie manager (I don't believe that we can fix the cookie extraction issue but we added an option to manually input them
  • Fix scan_folder being saved as a pathlib.Path object.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants