mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-19 18:58:03 +02:00
fix: find chromium key failed on windows
This commit is contained in:
@@ -112,7 +112,7 @@ func (c *YandexCreditCard) Parse(masterKey []byte) error {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
value, err = decrypter.ChromePass(masterKey, encryptValue)
|
||||
value, err = decrypter.ChromePassForYandex(masterKey, encryptValue)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -129,10 +129,10 @@ func (c *YandexPassword) Parse(masterKey []byte) error {
|
||||
if masterKey == nil {
|
||||
password, err = decrypter.DPApi(pwd)
|
||||
} else {
|
||||
password, err = decrypter.ChromePass(masterKey, pwd)
|
||||
password, err = decrypter.ChromePassForYandex(masterKey, pwd)
|
||||
}
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Errorf("decrypt yandex password error %s", err)
|
||||
}
|
||||
}
|
||||
if create > time.Now().Unix() {
|
||||
|
||||
+16
-17
@@ -2,6 +2,7 @@ package browser
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"hack-browser-data/internal/browingdata"
|
||||
@@ -42,16 +43,15 @@ func pickChromium(name, profile string) []Browser {
|
||||
// TODO: add support for 「all」 flag and set profilePath
|
||||
if name == "all" {
|
||||
for _, v := range chromiumList {
|
||||
if !fileutil.FolderExists(filepath.Clean(v.profilePath)) {
|
||||
log.Noticef("find browser %s failed, profile folder is not exist", v.name)
|
||||
continue
|
||||
}
|
||||
if b, err := chromium.New(v.name, v.storage, v.profilePath, v.items); err == nil {
|
||||
log.Noticef("find browser %s success", b.Name())
|
||||
browsers = append(browsers, b)
|
||||
} else {
|
||||
if err == chromium.ErrProfilePathNotFound {
|
||||
log.Errorf("find browser %s failed, profile folder is not exist, maybe not installed", v.name)
|
||||
continue
|
||||
} else {
|
||||
log.Errorf("new chromium error: %s", err.Error())
|
||||
}
|
||||
log.Errorf("new chromium error: %s", err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,15 +59,14 @@ func pickChromium(name, profile string) []Browser {
|
||||
if profile == "" {
|
||||
profile = c.profilePath
|
||||
}
|
||||
if !fileutil.FolderExists(filepath.Clean(profile)) {
|
||||
log.Fatalf("find browser %s failed, profile folder is not exist", c.name)
|
||||
}
|
||||
b, err := chromium.New(c.name, c.storage, profile, c.items)
|
||||
if err != nil {
|
||||
if err == chromium.ErrProfilePathNotFound {
|
||||
log.Fatalf("find browser %s failed, profile folder is not exist, maybe not installed", c.name)
|
||||
} else {
|
||||
log.Fatalf("new chromium error:", err)
|
||||
return nil
|
||||
}
|
||||
log.Fatalf("new chromium error:", err)
|
||||
}
|
||||
log.Noticef("find browser %s success", b.Name())
|
||||
browsers = append(browsers, b)
|
||||
}
|
||||
return browsers
|
||||
@@ -83,17 +82,17 @@ func pickFirefox(name, profile string) []Browser {
|
||||
} else {
|
||||
profile = fileutil.ParentDir(profile)
|
||||
}
|
||||
if !fileutil.FolderExists(filepath.Clean(profile)) {
|
||||
log.Noticef("find browser firefox %s failed, profile folder is not exist", v.name)
|
||||
continue
|
||||
}
|
||||
if multiFirefox, err := firefox.New(v.name, v.storage, profile, v.items); err == nil {
|
||||
for _, b := range multiFirefox {
|
||||
log.Noticef("find browser firefox %s success", b.Name())
|
||||
browsers = append(browsers, b)
|
||||
}
|
||||
} else {
|
||||
if err == firefox.ErrProfilePathNotFound {
|
||||
log.Errorf("find browser firefox %s failed, profile folder is not exist", v.name)
|
||||
} else {
|
||||
log.Error(err)
|
||||
}
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
return browsers
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package chromium
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -9,6 +8,7 @@ import (
|
||||
|
||||
"hack-browser-data/internal/browingdata"
|
||||
"hack-browser-data/internal/item"
|
||||
"hack-browser-data/internal/log"
|
||||
"hack-browser-data/internal/utils/fileutil"
|
||||
"hack-browser-data/internal/utils/typeutil"
|
||||
)
|
||||
@@ -22,20 +22,12 @@ type chromium struct {
|
||||
itemPaths map[item.Item]string
|
||||
}
|
||||
|
||||
var (
|
||||
ErrProfilePathNotFound = errors.New("profile path not found")
|
||||
)
|
||||
|
||||
// New create instance of chromium browser, fill item's path if item is existed.
|
||||
func New(name, storage, profilePath string, items []item.Item) (*chromium, error) {
|
||||
c := &chromium{
|
||||
name: name,
|
||||
storage: storage,
|
||||
}
|
||||
// TODO: Handle file path is not exist
|
||||
if !fileutil.FolderExists(profilePath) {
|
||||
return nil, ErrProfilePathNotFound
|
||||
}
|
||||
itemsPaths, err := c.getItemPath(profilePath, items)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -72,7 +64,7 @@ func (c *chromium) BrowsingData() (*browingdata.Data, error) {
|
||||
func (c *chromium) copyItemToLocal() error {
|
||||
for i, path := range c.itemPaths {
|
||||
if fileutil.FolderExists(path) {
|
||||
if err := fileutil.CopyDir(path, i.String()); err != nil {
|
||||
if err := fileutil.CopyDir(path, i.String(), "lock"); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
@@ -95,6 +87,8 @@ func (c *chromium) getItemPath(profilePath string, items []item.Item) (map[item.
|
||||
var itemPaths = make(map[item.Item]string)
|
||||
parentDir := fileutil.ParentDir(profilePath)
|
||||
baseDir := fileutil.BaseDir(profilePath)
|
||||
log.Infof("%s profile parentDir: %s", c.name, parentDir)
|
||||
log.Infof("%s profile baseDir: %s", c.name, baseDir)
|
||||
err := filepath.Walk(parentDir, chromiumWalkFunc(items, itemPaths, baseDir))
|
||||
if err != nil {
|
||||
return itemPaths, err
|
||||
|
||||
@@ -28,9 +28,7 @@ var (
|
||||
|
||||
// New returns a new firefox instance.
|
||||
func New(name, storage, profilePath string, items []item.Item) ([]*firefox, error) {
|
||||
if !fileutil.FolderExists(profilePath) {
|
||||
return nil, ErrProfilePathNotFound
|
||||
}
|
||||
|
||||
f := &firefox{
|
||||
name: name,
|
||||
storage: storage,
|
||||
|
||||
@@ -45,8 +45,11 @@ func ReadFile(filename string) (string, error) {
|
||||
return string(s), err
|
||||
}
|
||||
|
||||
func CopyDir(src, dst string) error {
|
||||
return cp.Copy(src, dst)
|
||||
func CopyDir(src, dst, skip string) error {
|
||||
s := cp.Options{Skip: func(src string) (bool, error) {
|
||||
return strings.Contains(strings.ToLower(src), skip), nil
|
||||
}}
|
||||
return cp.Copy(src, dst, s)
|
||||
}
|
||||
|
||||
func Filename(browser, item, ext string) string {
|
||||
|
||||
Reference in New Issue
Block a user