Giter Site home page Giter Site logo

rookie's People

Contributors

aldaronlau avatar thewh1teagle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

rookie's Issues

[Bug]: It doesn't work correctly with Octo Browser

What happened?

Hello, really grateful for your software, it's saved me a lot of time. However, there's a minor issue – it doesn't work properly with Octo Browser (https://octobrowser.net/). I've come up with a quick fix that addresses this problem, but I've never worked with Rust before, and I'd appreciate if you (the author) could resolve this bug related to cookie unloading via Python bindings from Octo Browser. Here's the link to my commit that resolves this issue with Octo Browser (Chromium): igorank@859f6d7

Steps to reproduce

  1. call function: rookiepy.any_browser(db_path=db_path, key_path=key_path, domains=None)
  2. Unlocking chrome database, it may take a while (sometimes up to minute)
    thread '' panicked at rookie-rs\src\browser\chromium.rs:89:36:
    range end index 3 out of range for slice of length 1
    note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
    Exception in thread Thread-1:
    File "C:\Users\work\Documents\Projects\fb-multi-tasker\cookie_manager.py", line 15, in _load_cookies_from_db
    cookies = rookiepy.any_browser(db_path=db_path, key_path=key_path, domains=None)
    pyo3_runtime.PanicException: range end index 3 out of range for slice of length 1

What browsers are you seeing the problem on?

Chromium

Relevant log output

Unlocking chrome database, it may take a while (sometimes up to minute)
thread '<unnamed>' panicked at rookie-rs\src\browser\chromium.rs:89:36:
range end index 3 out of range for slice of length 1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Exception in thread Thread-1:
File "C:\Users\work\Documents\Projects\fb-multi-tasker\cookie_manager.py", line 15, in _load_cookies_from_db
    cookies = rookiepy.any_browser(db_path=db_path, key_path=key_path, domains=None)
pyo3_runtime.PanicException: range end index 3 out of range for slice of length 1

Incorrect expiry times

Consider the following python script (using v0.2.7):

import browser_cookie3, rookiepy

print('browser_cookie3:')
for c in browser_cookie3.firefox(domain_name='test.wikipedia.org'):
    print(c.name, c.expires)

print('\nrookiepy:')
for c in rookiepy.firefox(['test.wikipedia.org']):
    print(c.name, c.expires)

prints the following:

browser_cookie3:
testwikiss0-UserID 1728238484
testwikiUserID 1728238484
testwikiss0-UserName 1728238484
testwikiUserName 1728238484
WMF-Last-Access 1699444800
WMF-DP 1696723200
NetworkProbeLimit 1696706087
testwikiSession None
ss0-testwikiSession None
testwikimwuser-sessionId None

rookiepy:
testwikiss0-UserID 1728238484000
testwikiUserID 1728238484000
testwikiss0-UserName 1728238484000
testwikiUserName 1728238484000
WMF-Last-Access 1699444800000
WMF-DP 1696723200000
NetworkProbeLimit 1696706087000
testwikiSession 2012062492654
ss0-testwikiSession 2012062492654
testwikimwuser-sessionId 2012062492654

Note that expiry values returned by rookiepy are 1000 times greater than the ones in browser_cookie3. (they are in milliseconds instead of the expected seconds)

Also, for the last three items, rookiepy has returned 2012062492654 instead of None. This currently does not cause issue, because it is in milliseconds, but if we convert values to second then the cookie is expired.

[Bug]: Firefox: Incomplete profiles.ini parsing

What happened?

On Firefox setups with an empty "Profile0" profile (happens when some other profile is the default):

PanicException: called `Result::unwrap()` on an `Err` value: cant find any brave cookies file

You have to parse the [Install...] section in the profiles.ini file and find out the actual profile to use. Ideally one could optionally select a specific profile.

See here:
n8henrie/pycookiecheat@1e609f3#diff-ad7e90379c804b2614f8dc3d28249a1dd014408fffcc78a1f501b1f454ba68efR54-R89

Steps to reproduce

  1. Create a new, pristine, Firefox profiles directory
  2. firefox --ProfileManager
  3. Create a second profile and make it default.
  4. Open Firefox, open google.com. Cookies are stored.
  5. Then:
~ ❯ python -m venv .test
~ ❯ .test/bin/pip install rookiepy
Collecting rookiepy
  Obtaining dependency information for rookiepy from https://files.pythonhosted.org/packages/48/51/09a1ae45a89414a9d5c41017dd41633cfe218211e1e3e05db5ccc6814d4e/rookiepy-0.3.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
  Downloading rookiepy-0.3.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (599 bytes)
Downloading rookiepy-0.3.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.7 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.7/3.7 MB 5.4 MB/s eta 0:00:00
Installing collected packages: rookiepy
Successfully installed rookiepy-0.3.3

~ ❯ .test/bin/pip install ipython
[...]
~ ❯ .test/bin/ipython
Python 3.11.6 (main, Nov 14 2023, 09:36:21) [GCC 13.2.1 20230801]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.18.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import rookiepy

In [2]: cookies = rookiepy.firefox(["google.com"])
thread '<unnamed>' panicked at bindings/python/src/lib.rs:33:44:
called `Result::unwrap()` on an `Err` value: cant find any brave cookies file
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---------------------------------------------------------------------------
PanicException                            Traceback (most recent call last)
Cell In[2], line 1
----> 1 cookies = rookiepy.firefox(["google.com"])

PanicException: called `Result::unwrap()` on an `Err` value: cant find any brave cookies file

What browsers are you seeing the problem on?

Firefox

Relevant log output

No response

Retrieving session cookies expires them

Hello,

When using rookiepy to retrieve the sessionid cookie for a website, it directly expires the session, so I can't use it to login with my script. I use Microsoft Edge and the cookie expires when I use load() or edge() methods, even if I don't use the cookie in a request.

Is it a problem with rookiepy or with the website I'm trying to connect ? It's weird because with browser_cookie3, before the chromium update, it worked perfectly.

Thanks

[Bug]: panicked at macos

What happened?

RUST_BACKTRACE=1 cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.12s
Running target/debug/cookie_helper
thread 'main' panicked at 'called Result::unwrap() on an Err value: decrypt_encrypted_value failed', src/main.rs:5:56
stack backtrace:
0: rust_begin_unwind
at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:593:5
1: core::panicking::panic_fmt
at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:67:14
2: core::result::unwrap_failed
at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/result.rs:1651:5
3: core::result::Result<T,E>::unwrap
at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/result.rs:1076:23
4: cookie_helper::main
at ./src/main.rs:5:32
5: core::ops::function::FnOnce::call_once
at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

Steps to reproduce

use rookie::{self, common::enums::Cookie};

fn main() {
let domains = Some(vec!["google.com"]); // set to None to get all
let cookies: Vec = rookie::chrome(domains).unwrap();
println!("{cookies:?}");
}
1.cargo run

What browsers are you seeing the problem on?

Chrome

Relevant log output

No response

[Bug]: Chrome config additional profiles may have "Cookies" filename instead of "Cookie"

What happened?

In config.rs, the Chrome config data_paths list is lacking additional patterns,

"%LOCALAPPDATA%/Google/Chrome{channel}/User Data/Profile */Network/Cookies", /*notice the s at the end*/
...
"%APPDATA%/Google/Chrome{channel}/User Data/Profile */Network/Cookies"

I have witnessed first-hand this file being created instead of Cookie for Chrome 118.0.5993.71 with a signed-in google account attached. I would consider this a bug over a feature request because all the rest of the Chromium-based browser configs have it already. I can submit a PR if you want it, but the solution in this case is so trivial I don't think its worth the extra effort rather than rolling this fix into the next update.

Steps to reproduce

  1. Install Chrome 118.0.5993.71
  2. Sign the browser into a new Google account
  3. A new Profile directory is created, i.e. Profile n/
  4. Check the cookie database name, Cookies instead of Cookie under Profile n/Network/.

What browsers are you seeing the problem on?

Chrome

Relevant log output

No response

[Feature Request]: Dealing with cookies with "Session" expiry

Describe the feature

At this time, I have observed in Chrome, 118.0.5993.71 at the very least, that cookies set as Expiry=Session do what they say on the tin: they are not stored within the database file at anytime.

I am fairly certain this is a unsolvable problem within the confines of the "reading the Cookies database file" solution that this project and those like it rely on to provide functionality, however, I think it would be worth opening at issue on this, if for no other reason than to direct future users to this, as this will certainly become a regularly-asked question. I have yet to see mention of this fundamental gap in functionality mentioned for this project in the documentation, much to the dismay of those who embark on using this code to solve their problem, only to find their one problem cannot be solved by these means.

For said future developers with this problem: my one recommendation to you is to write a browser extension to read the cookie when it is sent by the server, if there is no other option (like submitting a login form instead, which I suppose you've already considered by now).

If you don't think this issue will have any benefit to you/this project, feel free to close it, no hard feelings. :)

python 3.12 wheels on windows and macOS

It seems like python 3.12 wheels are only available for linux: https://pypi.org/project/rookiepy/#files

Is it possible to provide python 3.12 wheels on windows and macOS? Thanks.


Edit:

Seems like python3.12 was not present on the runner for the latest release: https://github.com/thewh1teagle/rookie/actions/runs/6435145142/job/17475799007#step:4:247

Github runner image with python 3.12 is still prerelease (https://github.com/actions/runner-images/releases/tag/win22%2F20231005.1), so your runner did not have python3.12 on it

You can wait about 1 week for github runner with python 3.12 to be released and fully rolled out (https://github.com/actions/runner-images#available-images), by then python 3.12 wheels should be built the next time you run github action without further modifications, or you can modify github action to do this without further waiting:

- name: Set up Python 3.12
  uses: actions/setup-python@v4
  with:
    python-version: "3.12"
    allow-prereleases: true

cant decrypt value

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)

[Feature Request]: Error size cannot be known at compilation time.

Describe the feature

Currently the Error type used is Box<dyn Error> which cannot be known at compilation time, which prevents using the ? operator within a method that returns Result.

Using a crate such as thiserror or even anyhow if you'd rather not have strict Error types would solve this and make using this library easier.

error[E0277]: the size for values of type `dyn std::error::Error` cannot be known at compilation time
  --> src\lib.rs:29:44
   |
29 |         let cookies = rookie::load(domains)?;
   |                                            ^ doesn't have a size known at compile-time
   |
   = help: the trait `Sized` is not implemented for `dyn std::error::Error`
   = help: the following other types implement trait `FromResidual<R>`:
             <Result<T, F> as FromResidual<Yeet<E>>>
             <Result<T, F> as FromResidual<Result<Infallible, E>>>
   = note: required for `Box<dyn std::error::Error>` to implement `std::error::Error`
   = note: required for `anyhow::Error` to implement `From<Box<dyn std::error::Error>>`
   = note: required for `Result<SpotifyLyrics, anyhow::Error>` to implement `FromResidual<Result<Infallible, Box<dyn std::error::Error>>>`

error[E0277]: `dyn std::error::Error` cannot be sent between threads safely
   --> src\lib.rs:29:44
    |
29  |         let cookies = rookie::load(domains)?;
    |                                            ^ `dyn std::error::Error` cannot be sent between threads safely
    |
    = help: the trait `Send` is not implemented for `dyn std::error::Error`
    = help: the following other types implement trait `FromResidual<R>`:
              <Result<T, F> as FromResidual<Yeet<E>>>
              <Result<T, F> as FromResidual<Result<Infallible, E>>>
    = note: required for `Unique<dyn std::error::Error>` to implement `Send`
note: required because it appears within the type `Box<dyn Error>`
   --> C:\Users\Admin\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\alloc\src\boxed.rs:195:12
    |
195 | pub struct Box<
    |            ^^^
    = note: required for `anyhow::Error` to implement `From<Box<dyn std::error::Error>>`
    = note: required for `Result<SpotifyLyrics, anyhow::Error>` to implement `FromResidual<Result<Infallible, Box<dyn std::error::Error>>>`

error[E0277]: `dyn std::error::Error` cannot be shared between threads safely
   --> src\lib.rs:29:44
    |
29  |         let cookies = rookie::load(domains)?;
    |                                            ^ `dyn std::error::Error` cannot be shared between threads safely
    |
    = help: the trait `Sync` is not implemented for `dyn std::error::Error`
    = help: the following other types implement trait `FromResidual<R>`:
              <Result<T, F> as FromResidual<Yeet<E>>>
              <Result<T, F> as FromResidual<Result<Infallible, E>>>
    = note: required for `Unique<dyn std::error::Error>` to implement `Sync`
note: required because it appears within the type `Box<dyn Error>`
   --> C:\Users\Admin\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\alloc\src\boxed.rs:195:12
    |
195 | pub struct Box<
    |            ^^^
    = note: required for `anyhow::Error` to implement `From<Box<dyn std::error::Error>>`
    = note: required for `Result<SpotifyLyrics, anyhow::Error>` to implement `FromResidual<Result<Infallible, Box<dyn std::error::Error>>>`

For more information about this error, try `rustc --explain E0277`.

[Bug]: microsoft-edge-dev cookie file path should be dev instead of Dev?

What happened?

Hello,
I just found rookiepy says cannot find my microsoft edge browser's cookie. Then I digged a little bit and found it's searching for cookie file in ~/.config/microsoft-edge-Dev, but the edge browser (installed by Archlinux AUR package microsoft-edge-dev-bin) is using lower case dev, i.e ~/.config/microsoft-edge-dev.

After I created a synmbolic link microsoft-edge-Dev to microsoft-edge-dev, it's working greatly now.

Not sure if it's a bug worth fixing, just list it here in case other people met same issue.
Thanks for this nice package BTW.

Steps to reproduce

Archlinux, install AUR package microsoft-edge-dev-bin.
Run msedge, and double check ~/.config/microsoft-edge-dev is created.
use rookiepy to extract edge cookie, it reports error:

thread '<unnamed>' panicked at bindings/python/src/lib.rs:67:41:                                                                                                                              called `Result::unwrap()` on an `Err` value: can't find any cookies file                                                                                                                      note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "<string>", line 1, in <module>                                                         
pyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: can't find any cookies file

What browsers are you seeing the problem on?

Edge

Relevant log output

thread '<unnamed>' panicked at bindings/python/src/lib.rs:67:41:                                                                                                                              called `Result::unwrap()` on an `Err` value: can't find any cookies file                                                                                                                      note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "<string>", line 1, in <module>                                                         
pyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: can't find any cookies file

Some cookies are missing(?)

import browser_cookie3, rookiepy

print(f'{len(rookiepy.firefox())=}')
print(f'{len(browser_cookie3.firefox())=}')

print(len(rookiepy.firefox(['google.com'])))
print(len(browser_cookie3.firefox(domain_name='google.com')))

On my Windows 10 system the above scripts prints:

len(rookiepy.firefox())=675
len(browser_cookie3.firefox())=7104
47
51

Not sure if my method of comparison above is correct, but it looks to me that browser_cookie3 is able to find more cookies.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.