Portable Opera fails
I've got 78.0.4093.206 opera on win7, in portable mode (non installed)
trying to manually import cookies file:
site_cookies = browser_cookie3.opera(cookie_file=r'D:\Progs\Opera_Chr\profile\data\Cookies')
File starts with: "SQLite format 3" Forwards slash doesnt make a difference.
Gives error:
Traceback (most recent call last):
File "C:\python36\lib\site-packages\browser_cookie3\__init__.py", line 317, in _decrypt
return self._decrypt_windows_chromium(value, encrypted_value)
File "C:\python36\lib\site-packages\browser_cookie3\__init__.py", line 308, in _decrypt_windows_chromium
_, data = crypt_unprotect_data(encrypted_value)
File "C:\python36\lib\site-packages\browser_cookie3\__init__.py", line 98, 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 "<stdin>", line 1, in <module>
File "C:\python36\lib\site-packages\browser_cookie3\__init__.py", line 608, in opera
return Opera(cookie_file, domain_name, key_file).load()
File "C:\python36\lib\site-packages\browser_cookie3\__init__.py", line 293, in load
value = self._decrypt(item[5], item[6])
File "C:\python36\lib\site-packages\browser_cookie3\__init__.py", line 321, in _decrypt
if not self.key:
AttributeError: 'Opera' object has no attribute 'key'
Manually reading installed chrome cookies work
site_cookies = browser_cookie3.chrome(cookie_file=r'C:\Users\jasmine\AppData\Local\Google\Chrome\User Data\Default\Cookies')
Opera's sqlite structure is exactly the same as Chrome's. Looks like rows are fetched but decoding of blobs fail, but only for Opera type. Fails at this:
if not windll.crypt32.CryptUnprotectData(
byref(blob_in), byref(desc), byref(blob_entropy),
reserved, prompt_struct, flags, byref(blob_out)
):
raise RuntimeError('Failed to decrypt the cipher text with DPAPI')
This script works, it uses 'Local State' to get the keys: https://gist.github.com/GramThanos/1a9f47267b447507cf4e8538d6340e2a
@mrx23dot browser_cookie3 has this functionality too. You just need to pass the path of the Local State file to argument key_file.
Cheers, just tried it's still complaining:
import browser_cookie3
site_cookies = browser_cookie3.opera(cookie_file=r'D:\Progs\Opera_Chr\profile\data\Cookies', key_file=r'D:\Progs\Opera_Chr\profile\data\Local State')
Failed to decrypt the cipher text with DPAPI
Is there a self test we could include just to prove that the dll is working
assert dec(enc('test')) == 'test'
Weirdly I don't have 'info_cache' nor 'profile' in Local State only these:
dict_keys(['ab_testing', 'adblocker', 'bookmarks', 'browser', 'browserjs', 'chars', 'component_updater', 'data_use_measurement', 'dns_over_https', 'flow_service', 'freedom', 'geolocation', 'hardware_acceleration_mode', 'hardware_acceleration_mode_previous', 'http_original_content_length', 'http_received_content_length', 'icon_version', 'intl', 'last_version', 'location', 'os_crypt', 'partner_content', 'password_manager', 'plugins', 'prefs_override', 'profile_network_context_service', 'protocol_handler', 'rich_hints', 'session_id_generator_last_value', 'shutdown', 'siteprefs', 'subresource_filter', 'sync', 'task_manager', 'ui', 'update', 'updateclientdata', 'user_experience_metrics', 'yandex'])
Are these enough to get the key?
The key file path should be D:\Progs\Opera_Chr\profile\Local State.
Any Local State file in D:\Progs\Opera_Chr\profile? (E.g.: D:\Progs\Opera_Chr\profile\Local State)
That's correct I used: cookie_file=r'D:\Progs\Opera_Chr\profile\data\Cookies', key_file=r'D:\Progs\Opera_Chr\profile\data\Local State' it exists, see it's content above.
Here is a fresh install in portable mode, you can try it yourself: both_files.zip
Can you confirm your key_file path is correct? It should be on D:\Progs\Opera_Chr\profile\Local State, not D:\Progs\Opera_Chr\profile\data\Local State.
Notice that the Cookies and the Local State file are not in the same folder.
For me they are in the same folder, even when I reinstalled them into a new folder and set usb-portable mode during install.
It can find the files the problem is that the content is different in portable mode. See file attached above.
