Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/cixtor/binarycookies

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/cixtor/binarycookies

  • v1.3.0
  • Source
  • Go
  • Socket score

Version published
Created
Source

Binary Cookies GoReport GoDoc

Go (golang) implementation of an encoder and decoder for the Binary Cookies file format used by Safari and other applications based on WebKit to store HTTP cookies. A CLI program is also included to allow you to inspect and manipulate the binary cookies from the commodity of your Terminal.

Usage

If you are going to use this Go module in your project:

go get github.com/cixtor/binarycookies

If you want to install the command line interface (CLI):

go get github.com/cixtor/binarycookies/cmd/binarycookies

Example

The majority of macOS applications store their web cookies in ~/Library/Cookies/ while others —using containers— do so in ~/Library/Containers/<APP_ID>/Data/Library/Cookies/. We can use simple Unix commands to find all these files and dump their content using the CLI, like so:

find ~/Library/Cookies/ -name "*.binarycookies" -exec binarycookies {} \;

Specification

Binary Cookies are binary files containing several pieces of data that together form an array of objects representing persistent web cookies for different applications in the macOS and iOS application ecosystem. Nowadays, almost every application implements some sort of web view to offer in-app purchases and license validation. All the information transmitted via these web views is stored in these binary files.

Note: BE stands for Big-endian and LE stands for Little-endian.

VariableSizeTypeDescription
signature4byteFile signature must be equal to []byte{0x636f6f6b} or String("cook")
numPages4BE_uint32Number of pages in the file
pageOffset4BE_uint32Page offset. Repeat this N times where N = numPages
pageStart4byteMarks the beginning of a page. Must be equal to []byte{0x00000100}
numCookies4LE_uint32Number of cookies in the page
cookieOffset4LE_uint32Cookie offset. Repeat this N times where N = numCookies
pageEnd4byteMarks the end of a page. Must be equal to []byte{0x00000000}

Immediately after pageEnd we can read the page cookies. Repeat the steps below N times where N = numCookies.

VariableSizeTypeDescription
cookieSize4LE_uint32Cookie size. Number of bytes associated to the cookie
unknownOne4byteUnknown field possibly related to the cookie flags
cookieFlags4LE_uint320x0:None - 0x1:Secure - 0x4:HttpOnly - 0x5:Secure+HttpOnly
unknownTwo4byteUnknown field possibly related to the cookie flags
domainOffset4LE_uint32Cookie domain offset
nameOffset4LE_uint32Cookie name offset
pathOffset4LE_uint32Cookie path offset
valueOffset4LE_uint32Cookie value offset
commentOffset4LE_uint32Cookie comment offset
endHeader4byteMarks the end of a header. Must be equal to []byte{0x00000000}
expires8float64Cookie expiration time in Mac epoch time. Add 978307200 to turn into Unix
creation8float64Cookie creation time in Mac epoch time. Add 978307200 to turn into Unix
commentNLE_uint32Cookie comment string. N = domainOffset - commentOffset
domainNLE_uint32Cookie domain string. N = nameOffset - domainOffset
nameNLE_uint32Cookie name string. N = pathOffset - nameOffset
pathNLE_uint32Cookie path string. N = valueOffset - pathOffset
valueNLE_uint32Cookie value string. N = cookieSize - valueOffset

Immediately after the last cookie in the page we can read another page with pageStart.

The last cookie of the last page in the file is followed by an 8-bytes checksum.

An optional number of bytes follow the checksum, these are part of a Binary Property List that contains a dictionary with additional information like the cookie accept policy for all tasks within sessions based on the software configuration. A bplist00 file is a completely different file format we need to decode separately. The first 4-bytes after the checksum are the BE_uint32 representing the size of the binary property list. The remaining bytes represent the data we need to decode using a bplist parser.

FAQs

Package last updated on 19 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc