fix: wrong browser profile path for linux

pull/121/head
ᴍᴏᴏɴD4ʀᴋ 3 years ago
parent 6928944b53
commit 4d403e2866
  1. 3
      internal/browingdata/download.go
  2. 2
      internal/browingdata/password.go
  3. 5
      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 ( import (
"database/sql" "database/sql"
"fmt"
"os" "os"
"sort" "sort"
"strings" "strings"
@ -35,7 +34,7 @@ func (c *ChromiumDownload) Parse(masterKey []byte) error {
totalBytes, startTime, endTime int64 totalBytes, startTime, endTime int64
) )
if err := rows.Scan(&targetPath, &tabUrl, &totalBytes, &startTime, &endTime, &mimeType); err != nil { if err := rows.Scan(&targetPath, &tabUrl, &totalBytes, &startTime, &endTime, &mimeType); err != nil {
fmt.Println(err) log.Warn(err)
} }
data := download{ data := download{
TargetPath: targetPath, TargetPath: targetPath,

@ -106,7 +106,7 @@ func (c *YandexPassword) Parse(masterKey []byte) error {
encryptPass: pwd, encryptPass: pwd,
LoginUrl: url, LoginUrl: url,
} }
log.Debug(login)
if len(pwd) > 0 { if len(pwd) > 0 {
var err error var err error
if masterKey == nil { 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 { if b, err := chromium.New(c.name, c.storage, c.profilePath, c.items); err == nil {
browsers = append(browsers, b) browsers = append(browsers, b)
} else { } else {
// TODO: show which browser find failed
if strings.Contains(err.Error(), "profile path is not exist") { if strings.Contains(err.Error(), "profile path is not exist") {
continue continue
} }
@ -74,8 +75,12 @@ func pickFirefox(name string) []Browser {
multiFirefox, err := firefox.New(v.name, v.storage, v.profilePath, v.items) multiFirefox, err := firefox.New(v.name, v.storage, v.profilePath, v.items)
// TODO: Handle error // TODO: Handle error
if err != nil { if err != nil {
if strings.Contains(err.Error(), "profile path is not exist") {
fmt.Println(err.Error())
} else {
panic(err) panic(err)
} }
}
for _, browser := range multiFirefox { for _, browser := range multiFirefox {
browsers = append(browsers, browser) browsers = append(browsers, browser)
} }

@ -71,14 +71,14 @@ var (
) )
var ( var (
firefoxProfilePath = homeDir + "/.mozilla/firefox/*.default-release*/" firefoxProfilePath = homeDir + "/.mozilla/firefox/"
chromeProfilePath = homeDir + "/.config/google-chrome/*/" chromeProfilePath = homeDir + "/.config/google-chrome/"
chromiumProfilePath = homeDir + "/.config/chromium/*/" chromiumProfilePath = homeDir + "/.config/chromium/"
edgeProfilePath = homeDir + "/.config/microsoft-edge*/*/" edgeProfilePath = homeDir + "/.config/microsoft-edge*/"
braveProfilePath = homeDir + "/.config/BraveSoftware/Brave-Browser/*/" braveProfilePath = homeDir + "/.config/BraveSoftware/Brave-Browser/"
chromeBetaProfilePath = homeDir + "/.config/google-chrome-beta/*/" chromeBetaProfilePath = homeDir + "/.config/google-chrome-beta/"
operaProfilePath = homeDir + "/.config/opera/" operaProfilePath = homeDir + "/.config/opera/"
vivaldiProfilePath = homeDir + "/.config/vivaldi/*/" vivaldiProfilePath = homeDir + "/.config/vivaldi/"
) )
const ( 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 // 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) { func aesGCMDecrypt(crypted, key, nounce []byte) ([]byte, error) {
block, err := aes.NewCipher(key) block, err := aes.NewCipher(key)

Loading…
Cancel
Save