feat: support edge-dev for linux

pull/83/head
ᴍᴏᴏɴD4ʀᴋ 4 years ago
parent 6bd26e8854
commit 4cc3f7d334
  1. 11
      core/browser.go
  2. 13
      core/browser_darwin.go
  3. 23
      core/browser_linux.go
  4. 3
      core/browser_windows.go
  5. 14
      core/decrypt/decrypt_windows.go

@ -99,11 +99,12 @@ type Chromium struct {
name string name string
profilePath string profilePath string
keyPath string keyPath string
storage string // use for linux browser
secretKey []byte secretKey []byte
} }
func NewChromium(profile, key, name string) (Browser, error) { func NewChromium(profile, key, name, storage string) (Browser, error) {
return &Chromium{profilePath: profile, keyPath: key, name: name}, nil return &Chromium{profilePath: profile, keyPath: key, name: name, storage: storage}, nil
} }
func (c *Chromium) GetName() string { func (c *Chromium) GetName() string {
@ -149,7 +150,7 @@ type Firefox struct {
keyPath string keyPath string
} }
func NewFirefox(profile, key, name string) (Browser, error) { func NewFirefox(profile, key, name, storage string) (Browser, error) {
return &Firefox{profilePath: profile, keyPath: key, name: name}, nil return &Firefox{profilePath: profile, keyPath: key, name: name}, nil
} }
@ -221,7 +222,7 @@ func PickBrowser(name string) ([]Browser, error) {
name = strings.ToLower(name) name = strings.ToLower(name)
if name == "all" { if name == "all" {
for _, v := range browserList { for _, v := range browserList {
b, err := v.New(v.ProfilePath, v.KeyPath, v.Name) b, err := v.New(v.ProfilePath, v.KeyPath, v.Name, v.Storage)
if err != nil { if err != nil {
log.Error(err) log.Error(err)
} }
@ -229,7 +230,7 @@ func PickBrowser(name string) ([]Browser, error) {
} }
return browsers, nil return browsers, nil
} else if choice, ok := browserList[name]; ok { } else if choice, ok := browserList[name]; ok {
b, err := choice.New(choice.ProfilePath, choice.KeyPath, choice.Name) b, err := choice.New(choice.ProfilePath, choice.KeyPath, choice.Name, choice.Storage)
browsers = append(browsers, b) browsers = append(browsers, b)
return browsers, err return browsers, err
} }

@ -20,8 +20,14 @@ var (
ProfilePath string ProfilePath string
Name string Name string
KeyPath string KeyPath string
New func(profile, key, name string) (Browser, error) Storage string
New func(profile, key, name, storage string) (Browser, error)
}{ }{
"firefox": {
ProfilePath: fireFoxProfilePath,
Name: firefoxName,
New: NewFirefox,
},
"chrome": { "chrome": {
ProfilePath: chromeProfilePath, ProfilePath: chromeProfilePath,
Name: chromeName, Name: chromeName,
@ -32,11 +38,6 @@ var (
Name: edgeName, Name: edgeName,
New: NewChromium, New: NewChromium,
}, },
"firefox": {
ProfilePath: fireFoxProfilePath,
Name: firefoxName,
New: NewFirefox,
},
} }
) )

@ -12,6 +12,12 @@ import (
const ( const (
fireFoxProfilePath = "/home/*/.mozilla/firefox/*.default-release/" fireFoxProfilePath = "/home/*/.mozilla/firefox/*.default-release/"
chromeProfilePath = "/home/*/.config/google-chrome/*/" chromeProfilePath = "/home/*/.config/google-chrome/*/"
edgeProfilePath = "/home/*/.config/microsoft-edge*/*/"
)
const (
chromeStorageName = "Chrome Safe Storage"
edgeStorageName = "Chromium Safe Storage"
) )
var ( var (
@ -19,7 +25,8 @@ var (
ProfilePath string ProfilePath string
Name string Name string
KeyPath string KeyPath string
New func(profile, key, name string) (Browser, error) Storage string
New func(profile, key, name, storage string) (Browser, error)
}{ }{
"firefox": { "firefox": {
ProfilePath: fireFoxProfilePath, ProfilePath: fireFoxProfilePath,
@ -29,6 +36,13 @@ var (
"chrome": { "chrome": {
ProfilePath: chromeProfilePath, ProfilePath: chromeProfilePath,
Name: chromeName, Name: chromeName,
Storage: chromeStorageName,
New: NewChromium,
},
"edge": {
ProfilePath: edgeProfilePath,
Name: edgeName,
Storage: edgeStorageName,
New: NewChromium, New: NewChromium,
}, },
} }
@ -62,24 +76,25 @@ func (c *Chromium) InitSecretKey() error {
return err return err
} }
for _, item := range items { for _, item := range items {
i, err := item.GetLabel() label, err := item.GetLabel()
if err != nil { if err != nil {
log.Error(err) log.Error(err)
continue continue
} }
if i == "Chrome Safe Storage" { if label == c.storage {
se, err := item.GetSecret(session.Path()) se, err := item.GetSecret(session.Path())
if err != nil { if err != nil {
log.Error(err)
return err return err
} }
chromeSecret = se.Value chromeSecret = se.Value
} }
} }
} }
var chromeSalt = []byte("saltysalt")
if chromeSecret == nil { if chromeSecret == nil {
return errDbusSecretIsEmpty return errDbusSecretIsEmpty
} }
var chromeSalt = []byte("saltysalt")
// @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_linux.cc // @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_linux.cc
key := pbkdf2.Key(chromeSecret, chromeSalt, 1, 16, sha1.New) key := pbkdf2.Key(chromeSecret, chromeSalt, 1, 16, sha1.New)
c.secretKey = key c.secretKey = key

@ -28,7 +28,8 @@ var (
ProfilePath string ProfilePath string
Name string Name string
KeyPath string KeyPath string
New func(profile, key, name string) (Browser, error) Storage string
New func(profile, key, name, storage string) (Browser, error)
}{ }{
"chrome": { "chrome": {
ProfilePath: os.Getenv("USERPROFILE") + chromeProfilePath, ProfilePath: os.Getenv("USERPROFILE") + chromeProfilePath,

@ -62,20 +62,6 @@ func (b *dataBlob) ToByteArray() []byte {
} }
// chrome < 80 https://chromium.googlesource.com/chromium/src/+/76f496a7235c3432983421402951d73905c8be96/components/os_crypt/os_crypt_win.cc#82 // chrome < 80 https://chromium.googlesource.com/chromium/src/+/76f496a7235c3432983421402951d73905c8be96/components/os_crypt/os_crypt_win.cc#82
func decryptStringWithDPAPI(data []byte) ([]byte, error) {
dllCrypt := syscall.NewLazyDLL("Crypt32.dll")
dllKernel := syscall.NewLazyDLL("Kernel32.dll")
procDecryptData := dllCrypt.NewProc("CryptUnprotectData")
procLocalFree := dllKernel.NewProc("LocalFree")
var outBlob dataBlob
r, _, err := procDecryptData.Call(uintptr(unsafe.Pointer(NewBlob(data))), 0, 0, 0, 0, 0, uintptr(unsafe.Pointer(&outBlob)))
if r == 0 {
return nil, err
}
defer procLocalFree.Call(uintptr(unsafe.Pointer(outBlob.pbData)))
return outBlob.ToByteArray(), nil
}
func DPApi(data []byte) ([]byte, error) { func DPApi(data []byte) ([]byte, error) {
dllCrypt := syscall.NewLazyDLL("Crypt32.dll") dllCrypt := syscall.NewLazyDLL("Crypt32.dll")
dllKernel := syscall.NewLazyDLL("Kernel32.dll") dllKernel := syscall.NewLazyDLL("Kernel32.dll")

Loading…
Cancel
Save