browserutils / kooky

Go code to read cookies from browser cookie stores.
MIT License
210 stars 41 forks source link

Chrome: Can't get cookies properly #47

Closed wengooooo closed 2 years ago

wengooooo commented 3 years ago

I can't get cookies on both Win7 and Win10 platforms.

Os: windows 10 Chrome: 94

Test Code:

package main

import (
    "fmt"
    "github.com/zellyn/kooky/chrome"
    "log"
    "os"
    "runtime"
)

func UserHomeDir() string {
    if runtime.GOOS == "windows" {
        home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")
        if home == "" {
            home = os.Getenv("USERPROFILE")
        }
        return home
    }
    return os.Getenv("HOME")
}

func main() {
    homeDir := UserHomeDir()
    cookiesFile := homeDir + "\\AppData\\Local" + "\\Google\\Chrome\\User Data\\Default\\Cookies"

    cookies, err := chrome.ReadCookies(cookiesFile)

    if err != nil {
        log.Fatal(err)
    }
    for _, cookie := range cookies {
        fmt.Println(cookie)
    }
}

win10 error message :

2021/10/16 16:41:12 expected column [encrypted_value] to be []byte; got string with value v104�ڥ 8�D�Vy����7( ��И?G; :�<хf�JO턻�|'�(J�_�

Os: windows 7 Chrome: 94

win7 error message :

panic: crypto/cipher: input not full blocks

goroutine 1 [running]:
crypto/cipher.(*cbcDecrypter).CryptBlocks(0x11c90150, 0x11cba3c0, 0x41, 0x41, 0x
11cba003, 0x41, 0x41)

But I can get cookies normally using python's browser_cookie3 package

purpl3F0x commented 2 years ago

Same issue happening to me also