bincookie
Loading...
Searching...
No Matches
Classes | Macros | Enumerations | Functions
bincookie.h File Reference

A parser for Apple's proprietary binary cookie storage format. More...

Go to the source code of this file.

Classes

struct  bincookie_iter_state_t
 Keeps track of iteration state when iterating cookie file pages. More...
 
struct  bincookie_cookie_t
 Cookie data structure. More...
 
struct  bincookie_page_t
 Cookie page structure. A page can consist of 1 or more cookies. More...
 
struct  bincookie_t
 bincookie file structure. More...
 

Macros

#define bincookie_is_secure(cookie_ptr)
 
#define bincookie_domain_access_full(cookie_ptr)
 Check if a cookie can be used on all subdomains of its original domain.
 
#define bincookie_iter_state_init(s)
 Initialise a bincookie_iter_state_t structure.
 
#define bincookie_domain(c)
 Get the domain of a cookie.
 
#define bincookie_path(c)
 Get the path of a cookie.
 
#define bincookie_name(c)
 Get the name of a cookie.
 
#define bincookie_value(c)
 Get the value of a cookie.
 
#define APPLE_EPOCH_OFFSET   978307200
 Difference between Apple's epoch (2001-01-01) and UNIX.
 
#define bincookie_expiration_time(c)
 Get the expiration time of a cookie.
 
#define bincookie_creation_time(c)
 Get the creation time of a cookie.
 

Enumerations

enum  bincookie_flag { secure , http_only }
 Security enabled for a cookie. More...
 

Functions

static bool bincookie_validate_pages (const bincookie_t *bc, size_t num_bytes)
 
static bincookie_t *const bincookie_init_file (FILE *fin)
 Read a binarycookies file.
 
static bincookie_t *const bincookie_init_path (const char *file_path)
 Read a binarycookies file.
 
static bincookie_page_t *const bincookie_iter_pages (const bincookie_t *bc, bincookie_iter_state_t *const state)
 Iterate pages of a binarycookies file.
 
static bincookie_cookie_t *const bincookie_iter_cookies (const bincookie_page_t *page, unsigned int *i)
 Iterate cookies of a page.
 

Detailed Description

A parser for Apple's proprietary binary cookie storage format.

Based on the Python script by Satishb3 satis.nosp@m.hb3@.nosp@m.secur.nosp@m.ityl.nosp@m.earn..nosp@m.net

Macro Definition Documentation

◆ bincookie_creation_time

#define bincookie_creation_time (   c)

Get the creation time of a cookie.

Parameters
cPointer to a bincookie_cookie_t structure.

◆ bincookie_domain

#define bincookie_domain (   c)

Get the domain of a cookie.

Parameters
cPointer to a bincookie_cookie_t structure.

◆ bincookie_domain_access_full

#define bincookie_domain_access_full (   cookie_ptr)

Check if a cookie can be used on all subdomains of its original domain.

Parameters
cookie_ptrPointer to a bincookie_cookie_t structure.

◆ bincookie_expiration_time

#define bincookie_expiration_time (   c)

Get the expiration time of a cookie.

Parameters
cPointer to a bincookie_cookie_t structure.

◆ bincookie_is_secure

#define bincookie_is_secure (   cookie_ptr)

Check if a cookie has the secure bit enabled (only to be accessed over HTTPS).

Parameters
cookie_ptrPointer to a bincookie_cookie_t data structure.

◆ bincookie_iter_state_init

#define bincookie_iter_state_init (   s)

Initialise a bincookie_iter_state_t structure.

Parameters
sbincookie_iter_state_t structure.

◆ bincookie_name

#define bincookie_name (   c)

Get the name of a cookie.

Parameters
cPointer to a bincookie_cookie_t structure. \

◆ bincookie_path

#define bincookie_path (   c)

Get the path of a cookie.

Parameters
cPointer to a bincookie_cookie_t structure. \

◆ bincookie_value

#define bincookie_value (   c)

Get the value of a cookie.

Parameters
cPointer to a bincookie_cookie_t structure.

Enumeration Type Documentation

◆ bincookie_flag

Security enabled for a cookie.

A cookie can be either or these values or 2 or more values OR'd together.

Enumerator
secure 

Cookie can only be used with HTTPS

http_only 

Cookie cannot be accessed by JavaScript

Function Documentation

◆ bincookie_init_file()

static bincookie_t *const bincookie_init_file ( FILE *  fin)
inlinestatic

Read a binarycookies file.

Parameters
finOpened file handle.
Returns
Pointer to a bincookie_t structure or NULL.

◆ bincookie_init_path()

static bincookie_t *const bincookie_init_path ( const char *  file_path)
inlinestatic

Read a binarycookies file.

Parameters
file_pathFile path string.
Returns
Pointer to a bincookie_t structure or NULL.

◆ bincookie_iter_cookies()

static bincookie_cookie_t *const bincookie_iter_cookies ( const bincookie_page_t page,
unsigned int *  i 
)
inlinestatic

Iterate cookies of a page.

Parameters
pagePointer to bincookie_page_t structure.
iPointer to an integer to keep track of index.
Returns
Pointer to a bincookie_cookie_t structure or NULL.

◆ bincookie_iter_pages()

static bincookie_page_t *const bincookie_iter_pages ( const bincookie_t bc,
bincookie_iter_state_t *const  state 
)
inlinestatic

Iterate pages of a binarycookies file.

Parameters
bcPointer to bincookie_t structure.
statePointer to bincookie_iter_state_t object.
Returns
Pointer to a bincookie_page_t structure or NULL.

◆ bincookie_validate_pages()

static bool bincookie_validate_pages ( const bincookie_t bc,
size_t  num_bytes 
)
inlinestatic

Validate that every page header, cookie offset table, and cookie referenced by a loaded buffer lies within its bounds.

The fixed header and the byte-swapped page size table must already have been validated by the caller. This routine checks the remaining file-controlled counts and offsets so that subsequent iteration cannot read or write outside the buffer that was read from disk.

Parameters
bcPointer to a fully read bincookie_t buffer.
num_bytesSize of the buffer in bytes.
Returns
true when the structure is internally consistent, otherwise false.