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.
36 lines
872 B
36 lines
872 B
//go:build windows
|
|
|
|
package chromium
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"errors"
|
|
"os"
|
|
|
|
"github.com/tidwall/gjson"
|
|
|
|
"github.com/moond4rk/HackBrowserData/item"
|
|
"github.com/moond4rk/HackBrowserData/log"
|
|
"github.com/moond4rk/HackBrowserData/utils/fileutil"
|
|
)
|
|
|
|
var errDecodeMasterKeyFailed = errors.New("decode master key failed")
|
|
|
|
func (c *Chromium) GetMasterKey() ([]byte, error) {
|
|
keyFile, err := fileutil.ReadFile(item.TempChromiumKey)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer os.Remove(keyFile)
|
|
encryptedKey := gjson.Get(keyFile, "os_crypt.encrypted_key")
|
|
if !encryptedKey.Exists() {
|
|
return nil, nil
|
|
}
|
|
pureKey, err := base64.StdEncoding.DecodeString(encryptedKey.String())
|
|
if err != nil {
|
|
return nil, errDecodeMasterKeyFailed
|
|
}
|
|
c.masterKey, err = crypto.DPAPI(pureKey[5:])
|
|
log.Infof("%s initialized master key success", c.name)
|
|
return c.masterKey, err
|
|
}
|
|
|