format code

ᴍᴏᴏɴD4ʀᴋ 4 years ago
parent 59f4c67f41
commit 436e74f0df
  1. 13
      core/browser.go
  2. 2
      core/browser_darwin.go
  3. 6
      core/browser_linux.go
  4. 1
      core/common/parse.go
  5. 2
      core/decrypt/decrypt.go

@ -57,9 +57,10 @@ const (
) )
var ( var (
ErrDataNotSupported = errors.New(`not supported, default is "all", choose from history|password|bookmark|cookie`) errDataNotSupported = errors.New(`not supported, default is "all", choose from history|password|bookmark|cookie`)
ErrBrowserNotSupported = errors.New("browser not supported") errBrowserNotSupported = errors.New("browser not supported")
ErrChromeSecretIsEmpty = errors.New("chrome secret is empty") errChromeSecretIsEmpty = errors.New("chrome secret is empty")
errDbusSecretIsEmpty = errors.New("dbus secret key is empty")
chromiumParseList = map[string]FileList{ chromiumParseList = map[string]FileList{
cookie: { cookie: {
name: cookie, name: cookie,
@ -129,7 +130,7 @@ func (c *chromium) GetProfilePath(filename string) (err error) {
c.FileLists = append(c.FileLists, v) c.FileLists = append(c.FileLists, v)
} }
} else { } else {
return ErrDataNotSupported return errDataNotSupported
} }
return nil return nil
} }
@ -315,7 +316,7 @@ func (f *firefox) GetProfilePath(filename string) (err error) {
f.FileLists = append(f.FileLists, v) f.FileLists = append(f.FileLists, v)
} }
} else { } else {
return ErrDataNotSupported return errDataNotSupported
} }
return nil return nil
} }
@ -393,7 +394,7 @@ func PickBrowsers(name string) ([]Browser, error) {
browsers = append(browsers, b) browsers = append(browsers, b)
return browsers, err return browsers, err
} }
return nil, ErrBrowserNotSupported return nil, errBrowserNotSupported
} }
func chromeParse(key []byte, f common.Formatter) error { func chromeParse(key []byte, f common.Formatter) error {

@ -62,7 +62,7 @@ func (c *chromium) InitSecretKey() error {
temp := stdout.Bytes() temp := stdout.Bytes()
chromeSecret := temp[:len(temp)-1] chromeSecret := temp[:len(temp)-1]
if chromeSecret == nil { if chromeSecret == nil {
return ErrChromeSecretIsEmpty return errChromeSecretIsEmpty
} }
var chromeSalt = []byte("saltysalt") var 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

@ -2,10 +2,10 @@ package core
import ( import (
"crypto/sha1" "crypto/sha1"
"github.com/godbus/dbus/v5"
keyring "github.com/ppacher/go-dbus-keyring"
"hack-browser-data/log" "hack-browser-data/log"
"github.com/godbus/dbus/v5"
keyring "github.com/ppacher/go-dbus-keyring"
"golang.org/x/crypto/pbkdf2" "golang.org/x/crypto/pbkdf2"
) )
@ -80,7 +80,7 @@ func (c *chromium) InitSecretKey() error {
} }
var chromeSalt = []byte("saltysalt") var chromeSalt = []byte("saltysalt")
if chromeSecret == nil { if chromeSecret == nil {
return ErrChromeSecretIsEmpty return errDbusSecretIsEmpty
} }
// @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_linux.cc // @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_linux.cc
key := pbkdf2.Key(chromeSecret, chromeSalt, 1, 16, sha1.New) key := pbkdf2.Key(chromeSecret, chromeSalt, 1, 16, sha1.New)

@ -380,6 +380,7 @@ func (b *Bookmarks) FirefoxParse() error {
func (b *Bookmarks) Release(filename string) error { func (b *Bookmarks) Release(filename string) error {
return os.Remove(filename) return os.Remove(filename)
} }
func (c *Cookies) Release(filename string) error { func (c *Cookies) Release(filename string) error {
return os.Remove(filename) return os.Remove(filename)
} }

@ -13,7 +13,6 @@ var (
errSecurityKeyIsEmpty = errors.New("input [security find-generic-password -wa 'Chrome'] in terminal") errSecurityKeyIsEmpty = errors.New("input [security find-generic-password -wa 'Chrome'] in terminal")
errPasswordIsEmpty = errors.New("password is empty") errPasswordIsEmpty = errors.New("password is empty")
errDecryptFailed = errors.New("decrypt failed, password is empty") errDecryptFailed = errors.New("decrypt failed, password is empty")
errDbusSecretIsEmpty = errors.New("dbus secret key is empty")
) )
func aes128CBCDecrypt(key, iv, encryptPass []byte) ([]byte, error) { func aes128CBCDecrypt(key, iv, encryptPass []byte) ([]byte, error) {
@ -33,6 +32,7 @@ func PKCS5UnPadding(src []byte) []byte {
unpad := int(src[length-1]) unpad := int(src[length-1])
return src[:(length - unpad)] return src[:(length - unpad)]
} }
func Des3Decrypt(key, iv []byte, src []byte) ([]byte, error) { func Des3Decrypt(key, iv []byte, src []byte) ([]byte, error) {
block, err := des.NewTripleDESCipher(key) block, err := des.NewTripleDESCipher(key)
if err != nil { if err != nil {

Loading…
Cancel
Save