kooky

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2017 License: MIT Imports: 11 Imported by: 20

README

kooky

Package kooky contains routines to reach into cookie stores for Chrome and Safari, and retrieve the cookies.

You don't usually want to do this, but when you do, you do. Apparently it's common enough that there is example code scattered around the net in various languages. If you wanted it in Go, you're in luck.

It aspires to be pure Go (I spent quite a while making go-sqlite/sqlite3 work for it), but I guess the keychain parts (keybase/go-keychain) mess that up.

Status

No Maintenance Intended

Basic functionality works, on MacOS. I expect Linux to work too, since it doesn't encrypt. The API is currently not expected to be at all stable.

PRs more than welcome.

TODOs

  • Make it work on Windows. (Look at this and this to learn how to decrypt.)
  • Handle rows in Chrome's cookie DB with other than 14 columns (?)
  • Make it work for Firefox.

Example usage

usr, _ := user.Current()

var cookies []*kooky.Cookie
var err error

chrome := false
if chrome {
	cookiesFile := fmt.Sprintf("%s/Library/Application Support/Google/Chrome/Default/Cookies", usr.HomeDir)
	cookies, err = kooky.ReadChromeCookies(cookiesFile, "", "", time.Time{})
} else {
	cookiesFile := fmt.Sprintf("%s/Library/Cookies/Cookies.binarycookies", usr.HomeDir)
	cookies, err = kooky.ReadSafariCookies(cookiesFile, "", "", time.Time{})
}
if err != nil {
	return err
}
for _, cookie := range cookies {
	fmt.Println(cookie)
}

Thanks/references

Documentation

Overview

Package kooky contains routines to reach into cookie stores for Chrome and Safari, and retrieve the cookies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cookie struct {
	Domain   string
	Name     string
	Path     string
	Expires  time.Time
	Secure   bool
	HttpOnly bool
	Creation time.Time
	Value    string
}

Cookie is the struct returned by functions in this package. Similar to http.Cookie, but just a dumb struct.

func ReadChromeCookies

func ReadChromeCookies(filename string, domainFilter string, nameFilter string, expireAfter time.Time) ([]*Cookie, error)

func ReadSafariCookies

func ReadSafariCookies(filename string, domainFilter string, nameFilter string, expireAfter time.Time) ([]*Cookie, error)

func (Cookie) HttpCookie

func (c Cookie) HttpCookie() http.Cookie

HttpCookie returns an http.Cookie equivalent to this Cookie.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL