thewh1teagle / rookie

Load cookies from your web browsers
https://crates.io/crates/rookie
MIT License
207 stars 18 forks source link

cant decrypt value #4

Closed benhacka closed 1 year ago

benhacka commented 1 year ago

Unfortunately, apparently this lib is also broken and does not work with chrome because decrypt.

Trace:

cookies = rookiepy.chrome()
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "cant decrypt value"', src/lib.rs:85:43
...
PanicException: called `Result::unwrap()` on an `Err` value: "cant decrypt value"

Arch Linux, google-chrome (Stable Channel) 117.0.5938.132-1 (from aur)

thewh1teagle commented 1 year ago

The only thing which isn't implemented yet is decryption in Linux using Secret Storage Most of the time chrome doesn't use it on Linux and simply use constant key for encrypt. Looks like it's enabled on your os Does browser_cookie3 works for you with chrome?

Try the following: pip install browser_cookie3

import browser_cookie3
cj = browser_cookie3.chrome()
print(cj)

Let me know if it works for you, if so I will implement it in rookie If it doesn't work for you either with browser_cookie3 let me know too

benhacka commented 1 year ago

Hello. Yeah, it works

thewh1teagle commented 1 year ago

I added support for libsecret and kdewallet in new version

pip install -U rookiepy

from rookiepy import chrome, to_dict
cookies = chrome()
print(to_dict(cookies))

You can try it.

let me know if it works :)

uvlad7 commented 1 year ago

So, with kdewallet, it requires manual action to unlock it, right? Can you add this into the README?

thewh1teagle commented 1 year ago

@uvlad7 I'm not sure if it always require manual action to unlock it, I think that it's enough to open the browser once since the computer booted and then it works without asking

Does it opened password prompt for you? If so, the browser was opened since you booted to the OS?

uvlad7 commented 1 year ago

As far as I know, each keyring needs to be opened once after a login (default keyring is opened during a login). Yes, I got a prompt once (during the first try), and yep, browser was opened.

thewh1teagle commented 1 year ago

@uvlad7 In my case, when the browser already open it doesn't requires prompt for unlock kwallet.

uvlad7 commented 1 year ago

I tried to relogin and yes, after that I got that prompt again. But I was thinking why is it required at all, so I pressed cancel and, surprisingly, I got the same result I'd got before when I unlocked the keyring. So, I assume you try to access the default one, but trigger something else. 1st invocation - browsers weren't started, 2nd - they were, the same result. In both cases the popup has appeared, but I clicked Cancel. Screenshot from 2023-10-06 02-03-31 . Screenshot from 2023-10-06 02-02-31

Btw I don't understand where this cookie came from, I haven't found this value in both my chromes, and of course I have much more that 1 cookie on google.com. And rookiepy.chrome(["mail.google.com"]) returns an empty result.

I also don't understand how to distinguish multiple chromes (I have stable and beta installed):

vladimir@np940x5n:~$ {   IFS=:;   ls -H $PATH; } | grep google-chrome
google-chrome
google-chrome-beta
google-chrome-stable
google-chrome
google-chrome-beta
google-chrome-stable
vladimir@np940x5n:~$ which google-chrome
/usr/bin/google-chrome
vladimir@np940x5n:~$ which google-chrome-beta 
/usr/bin/google-chrome-beta
vladimir@np940x5n:~$ which google-chrome-stable 
/usr/bin/google-chrome-stable
vladimir@np940x5n:~$ ll /usr/bin/google-chrome
lrwxrwxrwx 1 root root 31 сак 21  2020 /usr/bin/google-chrome -> /etc/alternatives/google-chrome*
vladimir@np940x5n:~$ ll /etc/alternatives/google-chrome
lrwxrwxrwx 1 root root 29 сак 21  2020 /etc/alternatives/google-chrome -> /usr/bin/google-chrome-stable*
vladimir@np940x5n:~$ ll /usr/bin/google-chrome-beta
lrwxrwxrwx 1 root root 42 вер 20 05:46 /usr/bin/google-chrome-beta -> /opt/google/chrome-beta/google-chrome-beta*
vladimir@np940x5n:~$ ll /usr/bin/google-chrome-stable
lrwxrwxrwx 1 root root 32 вер 27 07:05 /usr/bin/google-chrome-stable -> /opt/google/chrome/google-chrome*
vladimir@np940x5n:~$ ll /usr/bin/google-chrome-stable
lrwxrwxrwx 1 root root 32 вер 27 07:05 /usr/bin/google-chrome-stable -> /opt/google/chrome/google-chrome*
thewh1teagle commented 1 year ago

@uvlad7 You get the same result when clicking cancel because it takes cookies from another chrome browsers as well from different paths and channels (only chrome browsers)

thewh1teagle commented 1 year ago

@uvlad7 I added this section to the readme

@benhacka I close this issue as for inactivity, feel free to reopen if you encounter any problems with decryption