You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HackBrowserData/core/browser_darwin.go

78 lines
1.8 KiB

package core
import (
"bytes"
"crypto/sha1"
"errors"
"os/exec"
"golang.org/x/crypto/pbkdf2"
)
const (
chromeProfilePath = "/Users/*/Library/Application Support/Google/Chrome/*/"
edgeProfilePath = "/Users/*/Library/Application Support/Microsoft Edge/*/"
fireFoxProfilePath = "/Users/*/Library/Application Support/Firefox/Profiles/*.default-release/"
braveProfilePath = "/Users/*/Library/Application Support/BraveSoftware/Brave-Browser/*/"
)
var (
browserList = map[string]struct {
ProfilePath string
Name string
KeyPath string
Storage string
New func(profile, key, name, storage string) (Browser, error)
}{
"firefox": {
ProfilePath: fireFoxProfilePath,
Name: firefoxName,
New: NewFirefox,
},
"chrome": {
ProfilePath: chromeProfilePath,
Name: chromeName,
New: NewChromium,
},
"edge": {
ProfilePath: edgeProfilePath,
Name: edgeName,
New: NewChromium,
},
"brave": {
ProfilePath: braveProfilePath,
Name: braveName,
New: NewChromium,
},
}
)
func (c *Chromium) InitSecretKey() error {
var (
cmd *exec.Cmd
stdout, stderr bytes.Buffer
)
// ➜ security find-generic-password -wa 'Chrome'
cmd = exec.Command("security", "find-generic-password", "-wa", c.name)
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err := cmd.Run()
if err != nil {
return err
}
if stderr.Len() > 0 {
err = errors.New(stderr.String())
return err
}
temp := stdout.Bytes()
chromeSecret := temp[:len(temp)-1]
if chromeSecret == nil {
return errChromeSecretIsEmpty
}
var chromeSalt = []byte("saltysalt")
// @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_mac.mm;l=157
key := pbkdf2.Key(chromeSecret, chromeSalt, 1003, 16, sha1.New)
c.secretKey = key
return nil
}