Skip to main content

Python Binary Cookies (de)serializer

Project description

Github Actions Status

Binary Cookies

Python library and CLI tool for reading and writing binary cookies files.

Requirements

  • Python 3.9 or higher

Installation

pip install binarycookies

If you want to use the parser as CLI, it's recommended to use pipx to install the package in an isolated environment.

pipx install binarycookies

Basic Usage CLI

After installation, you can use the command-line interface to read a binary cookies file:

bcparser <path_to_binary_cookies_file>

Replace <path_to_binary_cookies_file> with the path to the binary cookie file you want to read.

Basic Usage Python

Deserialization

import binarycookies 

with open("path/to/cookies.binarycookies", "rb") as f:
    cookies = binarycookies.load(f)

Serialization

import binarycookies 

cookie = {
    "name": "session_id",
    "value": "abc123",
    "url": "https://example.com",
    "path": "/",
    "create_datetime": "2023-10-01T12:34:56+00:00",
    "expiry_datetime": "2023-12-31T23:59:59+00:00",
    "flag": "Secure"
}

with open("path/to/cookies.binarycookies", "wb") as f:
    binarycookies.dump(cookie, f)

Output Types

The bcparser CLI supports two output types: json (default) and ascii.

JSON Output

The json output type formats the cookies as a JSON array, making it easy to parse and manipulate programmatically.

Example usage:

bcparser path/to/cookies.binarycookies --output json

Example output JSON:

[
  {
    "name": "session_id",
    "value": "abc123",
    "url": "https://example.com",
    "path": "/",
    "create_datetime": "2023-10-01T12:34:56+00:00",
    "expiry_datetime": "2023-12-31T23:59:59+00:00",
    "flag": "Secure"
  },
  {
    "name": "user_token",
    "value": "xyz789",
    "url": "https://example.com",
    "path": "/account",
    "create_datetime": "2023-10-01T12:34:56+00:00",
    "expiry_datetime": "2023-12-31T23:59:59+00:00",
    "flag": "HttpOnly"
  }
]

ASCII Output

The ascii output type formats the cookies in a simple, line-by-line text format, making it easy to read and pipe to other command-line tools.

Example usage:

bcparser path/to/cookies.binarycookies --output ascii

Example output ASCII:

Name: session_id
Value: abc123
URL: https://example.com
Path: /
Created: 2023-10-01T12:34:56+00:00
Expires: 2023-12-31T23:59:59+00:00
Flag: Secure
----------------------------------------
Name: user_token
Value: xyz789
URL: https://example.com
Path: /account
Created: 2023-10-01T12:34:56+00:00
Expires: 2023-12-31T23:59:59+00:00
Flag: HttpOnly
----------------------------------------

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! If you find a bug or have a feature request, please open an issue on GitHub. Pull requests are also welcome.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

binary_cookies_parser-2.0.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

binary_cookies_parser-2.0.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file binary_cookies_parser-2.0.1.tar.gz.

File metadata

  • Download URL: binary_cookies_parser-2.0.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.12.9 Linux/6.8.0-1021-azure

File hashes

Hashes for binary_cookies_parser-2.0.1.tar.gz
Algorithm Hash digest
SHA256 cd3be43da1604c7644f4aee2f4723c74f9837464c535d51fb217e02d7fd31acc
MD5 a270a4a94d23b77ad13c5fbf99b04abf
BLAKE2b-256 6f93f8176343863ac2d1a03cd0fc51b9ce1c1dd8ae7210c2246f4dc43b631b6f

See more details on using hashes here.

File details

Details for the file binary_cookies_parser-2.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for binary_cookies_parser-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 461ea176eeb8e9f8b7b697af975896b1ba2b59d20cdb8d34c79bcb378d3be491
MD5 afcc294aaef3fe454b35f84476c86e5c
BLAKE2b-256 b66c6410e3846e41168c1e3823f7123d7e47d28e1766913297dec7cef662cfac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page