kooky

package module
v0.0.0-...-dec11fa 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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

kooky

Reaching into browser-specific, vaguely documented, possibly concurrently modified cookie stores to pilfer cookies is a bad idea. Since you've arrived here, you're almost certainly going to do it anyway. Me too. And if we're going to do the Wrong Thing, at least let's try to Do it Right.

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

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.

It also aspires to work for all three major browsers, on all three major platforms. Naturally, half of that is TODOs.

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
⌂ 换网址