From da2beb945359ef71cbdb86a33427ad35d8297eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=8D=E1=B4=8F=E1=B4=8F=C9=B4D4=CA=80=E1=B4=8B?= Date: Thu, 14 Apr 2022 14:53:16 +0800 Subject: [PATCH] fix: wrong browser profile path for linux --- internal/browingdata/download.go | 3 +- internal/browingdata/password.go | 2 +- internal/browser/browser.go | 7 +- internal/browser/browser_linux.go | 14 ++-- internal/browser/browser_test.go | 86 ------------------------- internal/decrypter/decrypter_windows.go | 13 ++++ 6 files changed, 28 insertions(+), 97 deletions(-) delete mode 100644 internal/browser/browser_test.go diff --git a/internal/browingdata/download.go b/internal/browingdata/download.go index d9294d9..0419f90 100644 --- a/internal/browingdata/download.go +++ b/internal/browingdata/download.go @@ -2,7 +2,6 @@ package browingdata import ( "database/sql" - "fmt" "os" "sort" "strings" @@ -35,7 +34,7 @@ func (c *ChromiumDownload) Parse(masterKey []byte) error { totalBytes, startTime, endTime int64 ) if err := rows.Scan(&targetPath, &tabUrl, &totalBytes, &startTime, &endTime, &mimeType); err != nil { - fmt.Println(err) + log.Warn(err) } data := download{ TargetPath: targetPath, diff --git a/internal/browingdata/password.go b/internal/browingdata/password.go index a578937..8652792 100644 --- a/internal/browingdata/password.go +++ b/internal/browingdata/password.go @@ -106,7 +106,7 @@ func (c *YandexPassword) Parse(masterKey []byte) error { encryptPass: pwd, LoginUrl: url, } - log.Debug(login) + if len(pwd) > 0 { var err error if masterKey == nil { diff --git a/internal/browser/browser.go b/internal/browser/browser.go index efd87cf..2e11720 100644 --- a/internal/browser/browser.go +++ b/internal/browser/browser.go @@ -43,6 +43,7 @@ func pickChromium(name string) []Browser { if b, err := chromium.New(c.name, c.storage, c.profilePath, c.items); err == nil { browsers = append(browsers, b) } else { + // TODO: show which browser find failed if strings.Contains(err.Error(), "profile path is not exist") { continue } @@ -74,7 +75,11 @@ func pickFirefox(name string) []Browser { multiFirefox, err := firefox.New(v.name, v.storage, v.profilePath, v.items) // TODO: Handle error if err != nil { - panic(err) + if strings.Contains(err.Error(), "profile path is not exist") { + fmt.Println(err.Error()) + } else { + panic(err) + } } for _, browser := range multiFirefox { browsers = append(browsers, browser) diff --git a/internal/browser/browser_linux.go b/internal/browser/browser_linux.go index f4722a4..0a3eb45 100644 --- a/internal/browser/browser_linux.go +++ b/internal/browser/browser_linux.go @@ -71,14 +71,14 @@ var ( ) var ( - firefoxProfilePath = homeDir + "/.mozilla/firefox/*.default-release*/" - chromeProfilePath = homeDir + "/.config/google-chrome/*/" - chromiumProfilePath = homeDir + "/.config/chromium/*/" - edgeProfilePath = homeDir + "/.config/microsoft-edge*/*/" - braveProfilePath = homeDir + "/.config/BraveSoftware/Brave-Browser/*/" - chromeBetaProfilePath = homeDir + "/.config/google-chrome-beta/*/" + firefoxProfilePath = homeDir + "/.mozilla/firefox/" + chromeProfilePath = homeDir + "/.config/google-chrome/" + chromiumProfilePath = homeDir + "/.config/chromium/" + edgeProfilePath = homeDir + "/.config/microsoft-edge*/" + braveProfilePath = homeDir + "/.config/BraveSoftware/Brave-Browser/" + chromeBetaProfilePath = homeDir + "/.config/google-chrome-beta/" operaProfilePath = homeDir + "/.config/opera/" - vivaldiProfilePath = homeDir + "/.config/vivaldi/*/" + vivaldiProfilePath = homeDir + "/.config/vivaldi/" ) const ( diff --git a/internal/browser/browser_test.go b/internal/browser/browser_test.go deleted file mode 100644 index 5046ca0..0000000 --- a/internal/browser/browser_test.go +++ /dev/null @@ -1,86 +0,0 @@ -package browser - -import ( - "fmt" - "testing" - - "hack-browser-data/internal/browser/chromium" - "hack-browser-data/internal/item" - "hack-browser-data/internal/outputter" -) - -func TestPickChromium(t *testing.T) { - -} - -func TestGetChromiumItemAbsPath(t *testing.T) { - p := `/Library/Application Support/Google/Chrome/` - p = homeDir + p - c, err := chromium.New("chrome", "Chrome", p, item.DefaultChromium) - if err != nil { - t.Error(err) - } - data, err := c.GetBrowsingData() - if err != nil { - t.Error(err) - } - output := outputter.New("json") - - if err != nil { - t.Error(err) - } - for _, v := range data.Sources { - f, err := output.CreateFile("result", v.Name()+".json") - if err != nil { - panic(err) - } - if err := output.Write(v, f); err != nil { - panic(err) - } - } -} - -func TestPickBrowsers(t *testing.T) { - browsers := PickBrowser("all") - for _, v := range browsers { - fmt.Println(v.Name()) - } - // filetype := "json" - // dir := "result" - // output := outputter.New(filetype) -} - -// func TestPickFirefox(t *testing.T) { -// browsers := pickFirefox("all") -// filetype := "json" -// dir := "result" -// output := outputter.New(filetype) -// if err := output.MakeDir("result"); err != nil { -// panic(err) -// } -// for _, b := range browsers { -// fmt.Printf("%+v\n", b) -// if err := b.CopyItemFileToLocal(); err != nil { -// panic(err) -// } -// masterKey, err := b.GetMasterKey() -// if err != nil { -// fmt.Println(err) -// } -// browserName := b.Name() -// multiData := b.GetBrowsingData() -// for _, data := range multiData { -// if err := data.Parse(masterKey); err != nil { -// fmt.Println(err) -// } -// filename := fmt.Sprintf("%s_%s.%s", browserName, data.Name(), filetype) -// file, err := output.CreateFile(dir, filename) -// if err != nil { -// panic(err) -// } -// if err := output.Write(data, file); err != nil { -// panic(err) -// } -// } -// } -// } diff --git a/internal/decrypter/decrypter_windows.go b/internal/decrypter/decrypter_windows.go index 7dda3f0..debc8f4 100644 --- a/internal/decrypter/decrypter_windows.go +++ b/internal/decrypter/decrypter_windows.go @@ -16,6 +16,19 @@ func ChromePass(key, encryptPass []byte) ([]byte, error) { } } +func ChromePassForYandex(key, encryptPass []byte) ([]byte, error) { + if len(encryptPass) > 15 { + // remove Prefix 'v10' + // gcmBlockSize = 16 + // gcmTagSize = 16 + // gcmMinimumTagSize = 12 // NIST SP 800-38D recommends tags with 12 or more bytes. + // gcmStandardNonceSize = 12 + return aesGCMDecrypt(encryptPass[12:], key, encryptPass[0:12]) + } else { + return nil, errPasswordIsEmpty + } +} + // chromium > 80 https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_win.cc func aesGCMDecrypt(crypted, key, nounce []byte) ([]byte, error) { block, err := aes.NewCipher(key)