Skip to content

Repository files navigation

CookiesTool

This is a maintained fork of BinaryCookies.

Convert cookies between:

  • BinaryCookies (Apple)
  • EditThisCookie (JSON)
  • Perl::LWP
  • Netscape HTTP Cookie File (Mozilla, curl).
  • JSON
  • Property List (XML)

Supports macOS 10.15 and above, iOS 13.0 and above.

TODOs

  • Unit Tests
  • Framework Target & SPM Support

Usage

Usage: CookiesTool [OPTIONS]... [FILE]...
Convert between Apple BinaryCookies, EditThisCookie (JSON), Perl::LWP and Netscape HTTP Cookie File.
Command options are (-l is the default):
-h | --help show this message and exit
-l | --lint check the cookies file for syntax errors
-c | --convert FORMAT rewrite cookies file in format
-o | --output PATH specify file path name for result;
the -o option is used with -c, and is only useful
with one file argument;
-r | --readable if writing JSON, output in human-readable form
FORMAT is one of: binarycookies edit-this-cookie netscape perl-lwp

File Format

File

FieldEndiannessTypeSizeDescription
MagicBEUTF-84"cook", no terminator
Number of pagesBEUnsigned Int4
Page N sizeBEUnsigned Int4Repeat for N pages
Page NPage N sizePage N content
ChecksumBEUnsigned Int4Sum every 4th byte for each page
FooterBE80x071720050000004b
MetadataBinary Property ListContains NSHTTPCookieAcceptPolicy value

Page

FieldEndiannessTypeSizeDescription
HeaderBE40x00000100
Number of cookiesLEUnsigned Int4
Cookie N offsetLEUnsigned Int4Repeat for N cookies
Footer40x00000000
Cookie NCookie N sizeCookie N content

Cookie

FieldEndiannessTypeSizeDescription
SizeLEUnsigned Int4Size in bytes
VersionLEUnsigned Int40 or 1
FlagsLEBit field4isSecure = 1, isHTTPOnly = 1 << 2, unknown1 = 1 << 3, unknown2 = 1 << 4
Has portLEUnsigned Int40 or 1
URL OffsetLEUnsigned Int4Offset from the start of the cookie
Name OffsetLEUnsigned Int4Offset from the start of the cookie
Path OffsetLEUnsigned Int4Offset from the start of the cookie
Value OffsetLEUnsigned Int4Offset from the start of the cookie
Comment OffsetLEUnsigned Int4Offset from the start of the cookie, 0x00000000 if not present
Comment URL OffsetLEUnsigned Int4Offset from the start of the cookie, 0x00000000 if not present
ExpirationLEDouble8Number of seconds since 00:00:00 UTC on 1 January 2001
CreationLEDouble8Number of seconds since 00:00:00 UTC on 1 January 2001
PortLEUnsigned Int2Only present if the "Has port" field is 1
CommentLEStringNull-terminated, optional
Comment URLLEStringNull-terminated, optional
URLLEStringNull-terminated
NameLEStringNull-terminated
PathLEStringNull-terminated
ValueLEStringNull-terminated

About

Convert cookies between BinaryCookies (Apple), EditThisCookie (JSON), Perl::LWP and Netscape HTTP Cookie File (Mozilla, curl).

Topics

Resources

Stars

24 stars

Watchers

3 watching

Forks

Releases

Contributors

Languages