mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-27 19:22:22 +02:00
refactor: refactor package with gofumpt
This commit is contained in:
@@ -39,6 +39,7 @@ func New(name, storage, profilePath string, items []item.Item) ([]*chromium, err
|
||||
name: fileutil.BrowserName(name, user),
|
||||
items: typeutil.Keys(itemPaths),
|
||||
itemPaths: itemPaths,
|
||||
storage: storage,
|
||||
})
|
||||
}
|
||||
return chromiumList, nil
|
||||
@@ -90,7 +91,7 @@ func (c *chromium) copyItemToLocal() error {
|
||||
}
|
||||
|
||||
func (c *chromium) getItemPath(profilePath string, items []item.Item) (map[item.Item]string, error) {
|
||||
var itemPaths = make(map[item.Item]string)
|
||||
itemPaths := make(map[item.Item]string)
|
||||
parentDir := fileutil.ParentDir(profilePath)
|
||||
baseDir := fileutil.BaseDir(profilePath)
|
||||
err := filepath.Walk(parentDir, chromiumWalkFunc(items, itemPaths, baseDir))
|
||||
@@ -102,7 +103,8 @@ func (c *chromium) getItemPath(profilePath string, items []item.Item) (map[item.
|
||||
}
|
||||
|
||||
func (c *chromium) getMultiItemPath(profilePath string, items []item.Item) (map[string]map[item.Item]string, error) {
|
||||
var multiItemPaths = make(map[string]map[item.Item]string)
|
||||
// multiItemPaths is a map of user to item path, map[profile 1][item's name & path key pair]
|
||||
multiItemPaths := make(map[string]map[item.Item]string)
|
||||
parentDir := fileutil.ParentDir(profilePath)
|
||||
err := filepath.Walk(parentDir, chromiumWalkFunc2(items, multiItemPaths))
|
||||
if err != nil {
|
||||
@@ -126,6 +128,7 @@ func (c *chromium) getMultiItemPath(profilePath string, items []item.Item) (map[
|
||||
}
|
||||
t[userDir] = v
|
||||
t[userDir][item.ChromiumKey] = keyPath
|
||||
fillLocalStoragePath(t[userDir], item.ChromiumLocalStorage)
|
||||
}
|
||||
return t, nil
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//go:build darwin
|
||||
|
||||
package chromium
|
||||
|
||||
import (
|
||||
@@ -46,7 +48,7 @@ func (c *chromium) GetMasterKey() ([]byte, error) {
|
||||
if chromeSecret == nil {
|
||||
return nil, ErrWrongSecurityCommand
|
||||
}
|
||||
var chromeSalt = []byte("saltysalt")
|
||||
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)
|
||||
if key == nil {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//go:build linux
|
||||
|
||||
package chromium
|
||||
|
||||
import (
|
||||
@@ -60,7 +62,7 @@ func (c *chromium) GetMasterKey() ([]byte, error) {
|
||||
// @https://source.chromium.org/chromium/chromium/src/+/main:components/os_crypt/os_crypt_linux.cc;l=100
|
||||
chromiumSecret = []byte("peanuts")
|
||||
}
|
||||
var chromiumSalt = []byte("saltysalt")
|
||||
chromiumSalt := []byte("saltysalt")
|
||||
// @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_linux.cc
|
||||
key := pbkdf2.Key(chromiumSecret, chromiumSalt, 1, 16, sha1.New)
|
||||
c.masterKey = key
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//go:build windows
|
||||
|
||||
package chromium
|
||||
|
||||
import (
|
||||
@@ -13,9 +15,7 @@ import (
|
||||
"hack-browser-data/internal/utils/fileutil"
|
||||
)
|
||||
|
||||
var (
|
||||
errDecodeMasterKeyFailed = errors.New("decode master key failed")
|
||||
)
|
||||
var errDecodeMasterKeyFailed = errors.New("decode master key failed")
|
||||
|
||||
func (c *chromium) GetMasterKey() ([]byte, error) {
|
||||
keyFile, err := fileutil.ReadFile(item.TempChromiumKey)
|
||||
|
||||
Reference in New Issue
Block a user