browserutils / kooky

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

Had an issue with chrome/edge specific cookie #54

Closed ricardogolez closed 11 months ago

ricardogolez commented 1 year ago

Error was: Crypto/Cipher: input not full blocks

and it's tracing back to decrypt function when using edge.ReadCookies(fPath)/chrome.ReadCookies(fPath) for ubuntu and windows

function throwing the error: CryptBlocks @ if len(src)%x.BlockSize != 0

ricardogolez commented 1 year ago

Btw, it's working on non-admin side. I noticed that you're getting the local state file which is from the current user so my problem is I'm getting it from a direct path because I'm using an executable as a service. This problem occurs when I use this function(s) as an admin executable because it's getting the local state file from root not from path down from the specified fPath

example is C:\Users\\AppData\Roaming\Mozilla\Firefox\Profiles\\Network\Cookies

when I run as admin, the os.Getenv(AppData) returns a different Path but the target cookies is the top one

srlehn commented 1 year ago

The "Local State" file is being looked for 1 or 2 directories above the directory of the cookie store - this does not depend on the user. Chrome encrypts cookies on Windows with CryptProtectData without setting CRYPTPROTECT_LOCAL_MACHINE restricting the decryption to the current user. The keyrings on Linux also make the decryption user bound.

ricardogolez commented 1 year ago

Thanks for the reply! I still encounter this issue especially running it on admin

srlehn commented 1 year ago

For now i believe that you can only get/decrypt a cookie that was created by the same user.

Did you run the browser session that created the cookie also under the admin user?

ricardogolez commented 1 year ago

No, but the service was running on admin. it works perfectly if the program is run outside program files (tested it on flag commands and also running the service's program on desktop folder).

srlehn commented 11 months ago

Closing this as not a bug. You have to read the Chrome cookie values under the same user the browser which set those was executed.