mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-07-06 21:37:47 +02:00
Merge pull request #162 from moonD4rk/feat/dev
fix: find cookie file failed on windows
This commit is contained in:
@@ -3,6 +3,7 @@ package browser
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"hack-browser-data/internal/browingdata"
|
"hack-browser-data/internal/browingdata"
|
||||||
@@ -108,6 +109,7 @@ func ListBrowser() []string {
|
|||||||
var l []string
|
var l []string
|
||||||
l = append(l, typeutil.Keys(chromiumList)...)
|
l = append(l, typeutil.Keys(chromiumList)...)
|
||||||
l = append(l, typeutil.Keys(firefoxList)...)
|
l = append(l, typeutil.Keys(firefoxList)...)
|
||||||
|
sort.Strings(l)
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ var (
|
|||||||
braveProfilePath = homeDir + "/AppData/Local/BraveSoftware/Brave-Browser/User Data/Default/"
|
braveProfilePath = homeDir + "/AppData/Local/BraveSoftware/Brave-Browser/User Data/Default/"
|
||||||
speed360ProfilePath = homeDir + "/AppData/Local/360chrome/Chrome/User Data/Default/"
|
speed360ProfilePath = homeDir + "/AppData/Local/360chrome/Chrome/User Data/Default/"
|
||||||
qqBrowserProfilePath = homeDir + "/AppData/Local/Tencent/QQBrowser/User Data/Default/"
|
qqBrowserProfilePath = homeDir + "/AppData/Local/Tencent/QQBrowser/User Data/Default/"
|
||||||
operaProfilePath = homeDir + "/AppData/Roaming/Opera Software/Opera Stable/Default/"
|
operaProfilePath = homeDir + "/AppData/Roaming/Opera Software/Opera Stable/"
|
||||||
operaGXProfilePath = homeDir + "/AppData/Roaming/Opera Software/Opera GX Stable/"
|
operaGXProfilePath = homeDir + "/AppData/Roaming/Opera Software/Opera GX Stable/"
|
||||||
vivaldiProfilePath = homeDir + "/AppData/Local/Vivaldi/User Data/Default/"
|
vivaldiProfilePath = homeDir + "/AppData/Local/Vivaldi/User Data/Default/"
|
||||||
coccocProfilePath = homeDir + "/AppData/Local/CocCoc/Browser/User Data/Default/"
|
coccocProfilePath = homeDir + "/AppData/Local/CocCoc/Browser/User Data/Default/"
|
||||||
|
|||||||
@@ -124,14 +124,17 @@ func chromiumWalkFunc(items []item.Item, multiItemPaths map[string]map[item.Item
|
|||||||
return func(path string, info fs.FileInfo, err error) error {
|
return func(path string, info fs.FileInfo, err error) error {
|
||||||
for _, v := range items {
|
for _, v := range items {
|
||||||
if info.Name() == v.FileName() {
|
if info.Name() == v.FileName() {
|
||||||
parentBaseDir := fileutil.ParentBaseDir(path)
|
if strings.Contains(path, "System Profile") {
|
||||||
if parentBaseDir == "System Profile" {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if _, exist := multiItemPaths[parentBaseDir]; exist {
|
profileFolder := fileutil.ParentBaseDir(path)
|
||||||
multiItemPaths[parentBaseDir][v] = path
|
if strings.Contains(filepath.ToSlash(path), "/Network/Cookies") {
|
||||||
|
profileFolder = fileutil.BaseDir(strings.ReplaceAll(filepath.ToSlash(path), "/Network/Cookies", ""))
|
||||||
|
}
|
||||||
|
if _, exist := multiItemPaths[profileFolder]; exist {
|
||||||
|
multiItemPaths[profileFolder][v] = path
|
||||||
} else {
|
} else {
|
||||||
multiItemPaths[parentBaseDir] = map[item.Item]string{v: path}
|
multiItemPaths[profileFolder] = map[item.Item]string{v: path}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrWrongSecurityCommand = errors.New("macOS wrong security command")
|
errWrongSecurityCommand = errors.New("wrong security command")
|
||||||
ErrCouldNotFindInKeychain = errors.New("macOS could not find in keychain")
|
errCouldNotFindInKeychain = errors.New("could not be find in keychain")
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *chromium) GetMasterKey() ([]byte, error) {
|
func (c *chromium) GetMasterKey() ([]byte, error) {
|
||||||
@@ -39,19 +39,19 @@ func (c *chromium) GetMasterKey() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
if stderr.Len() > 0 {
|
if stderr.Len() > 0 {
|
||||||
if strings.Contains(stderr.String(), "could not be found") {
|
if strings.Contains(stderr.String(), "could not be found") {
|
||||||
return nil, ErrCouldNotFindInKeychain
|
return nil, errCouldNotFindInKeychain
|
||||||
}
|
}
|
||||||
return nil, errors.New(stderr.String())
|
return nil, errors.New(stderr.String())
|
||||||
}
|
}
|
||||||
chromeSecret := bytes.TrimSpace(stdout.Bytes())
|
chromeSecret := bytes.TrimSpace(stdout.Bytes())
|
||||||
if chromeSecret == nil {
|
if chromeSecret == nil {
|
||||||
return nil, ErrWrongSecurityCommand
|
return nil, errWrongSecurityCommand
|
||||||
}
|
}
|
||||||
chromeSalt := []byte("saltysalt")
|
chromeSalt := []byte("saltysalt")
|
||||||
// @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_mac.mm;l=157
|
// @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)
|
key := pbkdf2.Key(chromeSecret, chromeSalt, 1003, 16, sha1.New)
|
||||||
if key == nil {
|
if key == nil {
|
||||||
return nil, ErrWrongSecurityCommand
|
return nil, errWrongSecurityCommand
|
||||||
}
|
}
|
||||||
c.masterKey = key
|
c.masterKey = key
|
||||||
log.Infof("%s initialized master key success", c.name)
|
log.Infof("%s initialized master key success", c.name)
|
||||||
|
|||||||
@@ -1,20 +1,11 @@
|
|||||||
|
//go:build darwin
|
||||||
|
|
||||||
package decrypter
|
package decrypter
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
errSecurityKeyIsEmpty = errors.New("input [security find-generic-password -wa 'Chrome'] in terminal")
|
|
||||||
)
|
|
||||||
|
|
||||||
func Chromium(key, encryptPass []byte) ([]byte, error) {
|
func Chromium(key, encryptPass []byte) ([]byte, error) {
|
||||||
if len(encryptPass) <= 3 {
|
if len(encryptPass) <= 3 {
|
||||||
return nil, errPasswordIsEmpty
|
return nil, errPasswordIsEmpty
|
||||||
}
|
}
|
||||||
if len(key) == 0 {
|
|
||||||
return nil, errSecurityKeyIsEmpty
|
|
||||||
}
|
|
||||||
|
|
||||||
iv := []byte{32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32}
|
iv := []byte{32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32}
|
||||||
return aes128CBCDecrypt(key, iv, encryptPass[3:])
|
return aes128CBCDecrypt(key, iv, encryptPass[3:])
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
//go:build linux
|
||||||
|
|
||||||
package decrypter
|
package decrypter
|
||||||
|
|
||||||
func Chromium(key, encryptPass []byte) ([]byte, error) {
|
func Chromium(key, encryptPass []byte) ([]byte, error) {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
//go:build windows
|
||||||
|
|
||||||
package decrypter
|
package decrypter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -11,9 +13,6 @@ func Chromium(key, encryptPass []byte) ([]byte, error) {
|
|||||||
if len(encryptPass) < 3 {
|
if len(encryptPass) < 3 {
|
||||||
return nil, errPasswordIsEmpty
|
return nil, errPasswordIsEmpty
|
||||||
}
|
}
|
||||||
if len(key) == 0 {
|
|
||||||
return nil, errSecurityKeyIsEmpty
|
|
||||||
}
|
|
||||||
|
|
||||||
return aesGCMDecrypt(encryptPass[15:], key, encryptPass[3:15])
|
return aesGCMDecrypt(encryptPass[15:], key, encryptPass[3:15])
|
||||||
}
|
}
|
||||||
@@ -22,9 +21,6 @@ func ChromiumForYandex(key, encryptPass []byte) ([]byte, error) {
|
|||||||
if len(encryptPass) < 3 {
|
if len(encryptPass) < 3 {
|
||||||
return nil, errPasswordIsEmpty
|
return nil, errPasswordIsEmpty
|
||||||
}
|
}
|
||||||
if len(key) == 0 {
|
|
||||||
return nil, errSecurityKeyIsEmpty
|
|
||||||
}
|
|
||||||
// remove Prefix 'v10'
|
// remove Prefix 'v10'
|
||||||
// gcmBlockSize = 16
|
// gcmBlockSize = 16
|
||||||
// gcmTagSize = 16
|
// gcmTagSize = 16
|
||||||
|
|||||||
Reference in New Issue
Block a user