-
Notifications
You must be signed in to change notification settings - Fork 11
/
cookies_windows.go
46 lines (40 loc) · 1014 Bytes
/
cookies_windows.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//go:build windows
package rbxmk
import (
"bytes"
"net/http"
"github.com/anaminus/rbxmk/rtypes"
"github.com/danieljoos/wincred"
)
func cookiesFromStudio() rtypes.Cookies {
const domain = `roblox.com`
const credBaseName = `https://www.` + domain + `:RobloxStudioAuth`
const cookieListName = credBaseName + `Cookies`
cookieList, err := wincred.GetGenericCredential(cookieListName)
if err != nil {
return nil
}
acceptedCookies := map[string]string{}
for _, name := range bytes.Split(cookieList.CredentialBlob, []byte{';'}) {
if len(name) == 0 {
continue
}
acceptedCookies[credBaseName+string(name)] = string(name)
}
creds, err := wincred.List()
if err != nil {
return nil
}
var cookies rtypes.Cookies
for _, cred := range creds {
if name, ok := acceptedCookies[cred.TargetName]; ok {
cookies = append(cookies, rtypes.Cookie{Cookie: &http.Cookie{
Name: name,
Domain: domain,
Secure: true,
Value: string(cred.CredentialBlob),
}})
}
}
return cookies
}