rookie

repository·main·Indexed 17 days ago

https://github.com/thewh1teagle/rookie

A high-performance, cross-platform library written in Rust for loading and decrypting session cookies from various web browsers. It provides bindings for Rust, Python (rookiepy), and JavaScript (@rookie-rs/api), and includes a CLI tool that outputs decrypted cookies in JSON format. Supported browsers include Chrome, Firefox, Brave, Edge, Safari, Opera, and others across Windows, Linux, and macOS.

Tokens
11.4K
Snippets
56
Records
71
Agent score
58%

What's inside rookie

  1. Supported browsers and platforms

    main

    Rookie supports a wide range of browsers across Windows, Linux, and macOS.

    Supported Browsers:

    • Arc (Linux, macOS, Windows)
    • Brave (Linux, macOS, Windows)
    • Cachy (Linux)
    • Chrome (Linux, macOS, Windows)
    • Chromium (Linux, macOS, Windows)
    • Edge (Linux, macOS, Windows)
    • Firefox (Linux, macOS, Windows)
    • Internet Explorer (Windows)
    • LibreWolf (Linux, macOS, Windows)
    • Opera (Linux, macOS, Windows)
    • Opera GX (macOS, Windows)
    • Safari (macOS)
    • Vivaldi (Linux, macOS, Windows)
    • Zen (Linux, macOS)
  2. Understand cookie retrieval behaviors and gotchas

    main

    When using rookie, be aware of the following behaviors:

    • Password Prompts: On Linux or macOS with Chromium-based browsers, accessing cookies may trigger a password prompt from kde-wallet.
    • Session Cookies in Chrome-based browsers: Due to security features preventing external access to the cookies file, rookie may seamlessly restart the browser to bypass this. This allows session cookies to be retrieved, but they will expire once the browser is closed again.
  3. Use rookie on unsupported platforms (e.g. Android)

    main

    If you are running on an unsupported platform like Android, you can still use rookie by manually locating and providing the path to the browser's Cookies file.

    1. Find the Cookies file on the device (e.g., using find /data/data -type f -name Cookies).
    2. Pull the file to your environment.
    3. Execute the rookie-cli by passing the path to that file using the --path flag.
    ./cli --path <Cookies path>
  4. Build Node.js Bindings for rookie

    main

    Node.js bindings are built using @napi-rs/cli. Ensure you have bun installed to install the CLI globally, then run napi build within the bindings/python directory (Note: the documentation points to the bindings/python directory for Node bindings; verify path if this is a typo in the source).

    bun install -g @napi-rs/cli
    cd bindings/python
    napi build
  5. Install and use rookiepy in Python

    main

    Install the Python bindings using pip install rookiepy. The usage pattern involves calling browser functions (e.g., firefox) with a list of domains to retrieve cookie data as a list of dictionaries.

    pip install rookiepy
    import rookiepy
    cookies = rookiepy.firefox(["google.com"])
    for cookie in cookies:
        print(cookie['domain'], cookie['value'])
  6. Configure rookiepy logging levels

    main

    Logging for rookiepy is controlled via the standard Python logging module.

    To enable detailed debugging, set the root logger level to logging.DEBUG. To suppress all rookiepy logs, set the level to logging.CRITICAL.

    import logging
    
    # Enable debug logging
    logging.basicConfig()
    logging.getLogger().setLevel(logging.DEBUG)
    
    # Disable all rookiepy logging
    logging.getLogger().setLevel(logging.CRITICAL)
  7. Extract cookies from web browsers using @rookie-rs/api

    main

    The @rookie-rs/api package provides Node.js bindings for the rookie library, allowing you to programmatically extract cookies from installed web browsers. You can use the chrome() function (or other browser-specific exports) to retrieve a collection of cookies.

    import { chrome } from "@rookie-rs/api";
    
    const cookies = chrome();
    for (const cookie of cookies) {
      console.log(cookie);
    }
  8. Install and use rookie in Rust

    main

    To use rookie in a Rust project, add it via cargo. You can then call browser-specific functions (like brave) to retrieve cookies. You can optionally pass a vector of domain strings to filter the results.

    cargo add rookie
    use rookie::brave;
    
    fn main() {
        let domains = vec!["google.com"];
        let cookies = brave(Some(domains)).unwrap();
        for cookie in cookies {
            println!("{:?}", cookie);
        }
    }