fix: wrong browser profile path for linux

pull/125/head
ᴍᴏᴏɴD4ʀᴋ 3 years ago
parent 86d900527f
commit da2beb9453
  1. 3
      internal/browingdata/download.go
  2. 2
      internal/browingdata/password.go
  3. 7
      internal/browser/browser.go
  4. 14
      internal/browser/browser_linux.go
  5. 86
      internal/browser/browser_test.go
  6. 13
      internal/decrypter/decrypter_windows.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,

@ -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 {

@ -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)

@ -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 (

@ -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)
// }
// }
// }
// }

@ -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)

Loading…
Cancel
Save