|
|
@ -34,13 +34,14 @@ const ( |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func (c *ChromiumPassword) Parse(masterKey []byte) error { |
|
|
|
func (c *ChromiumPassword) Parse(masterKey []byte) error { |
|
|
|
loginDB, err := sql.Open("sqlite3", item.TempChromiumPassword) |
|
|
|
db, err := sql.Open("sqlite3", item.TempChromiumPassword) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
defer os.Remove(item.TempChromiumPassword) |
|
|
|
defer os.Remove(item.TempChromiumPassword) |
|
|
|
defer loginDB.Close() |
|
|
|
defer db.Close() |
|
|
|
rows, err := loginDB.Query(queryChromiumLogin) |
|
|
|
|
|
|
|
|
|
|
|
rows, err := db.Query(queryChromiumLogin) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
@ -61,11 +62,10 @@ func (c *ChromiumPassword) Parse(masterKey []byte) error { |
|
|
|
LoginURL: url, |
|
|
|
LoginURL: url, |
|
|
|
} |
|
|
|
} |
|
|
|
if len(pwd) > 0 { |
|
|
|
if len(pwd) > 0 { |
|
|
|
var err error |
|
|
|
if len(masterKey) == 0 { |
|
|
|
if masterKey == nil { |
|
|
|
|
|
|
|
password, err = crypto.DPAPI(pwd) |
|
|
|
password, err = crypto.DPAPI(pwd) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
password, err = crypto.Chromium(masterKey, pwd) |
|
|
|
password, err = crypto.DecryptPass(masterKey, pwd) |
|
|
|
} |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Error(err) |
|
|
|
log.Error(err) |
|
|
@ -90,7 +90,7 @@ func (c *ChromiumPassword) Name() string { |
|
|
|
return "password" |
|
|
|
return "password" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (c *ChromiumPassword) Length() int { |
|
|
|
func (c *ChromiumPassword) Len() int { |
|
|
|
return len(*c) |
|
|
|
return len(*c) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -101,13 +101,14 @@ const ( |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func (c *YandexPassword) Parse(masterKey []byte) error { |
|
|
|
func (c *YandexPassword) Parse(masterKey []byte) error { |
|
|
|
loginDB, err := sql.Open("sqlite3", item.TempYandexPassword) |
|
|
|
db, err := sql.Open("sqlite3", item.TempYandexPassword) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
defer os.Remove(item.TempYandexPassword) |
|
|
|
defer os.Remove(item.TempYandexPassword) |
|
|
|
defer loginDB.Close() |
|
|
|
defer db.Close() |
|
|
|
rows, err := loginDB.Query(queryYandexLogin) |
|
|
|
|
|
|
|
|
|
|
|
rows, err := db.Query(queryYandexLogin) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
@ -129,11 +130,10 @@ func (c *YandexPassword) Parse(masterKey []byte) error { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if len(pwd) > 0 { |
|
|
|
if len(pwd) > 0 { |
|
|
|
var err error |
|
|
|
if len(masterKey) == 0 { |
|
|
|
if masterKey == nil { |
|
|
|
|
|
|
|
password, err = crypto.DPAPI(pwd) |
|
|
|
password, err = crypto.DPAPI(pwd) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
password, err = crypto.Chromium(masterKey, pwd) |
|
|
|
password, err = crypto.DecryptPass(masterKey, pwd) |
|
|
|
} |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Errorf("decrypt yandex password error %s", err) |
|
|
|
log.Errorf("decrypt yandex password error %s", err) |
|
|
@ -158,7 +158,7 @@ func (c *YandexPassword) Name() string { |
|
|
|
return "password" |
|
|
|
return "password" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (c *YandexPassword) Length() int { |
|
|
|
func (c *YandexPassword) Len() int { |
|
|
|
return len(*c) |
|
|
|
return len(*c) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -183,24 +183,25 @@ func (f *FirefoxPassword) Parse(masterKey []byte) error { |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
keyLin := []byte{248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1} |
|
|
|
|
|
|
|
if bytes.Contains(k, []byte("password-check")) { |
|
|
|
if bytes.Contains(k, []byte("password-check")) { |
|
|
|
m := bytes.Compare(nssA102, keyLin) |
|
|
|
keyLin := []byte{248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1} |
|
|
|
if m == 0 { |
|
|
|
if bytes.Compare(nssA102, keyLin) == 0 { |
|
|
|
nssPBE, err := crypto.NewASN1PBE(nssA11) |
|
|
|
nssPBE, err := crypto.NewASN1PBE(nssA11) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
finallyKey, err := nssPBE.Decrypt(globalSalt, masterKey) |
|
|
|
finallyKey, err := nssPBE.Decrypt(globalSalt, masterKey) |
|
|
|
finallyKey = finallyKey[:24] |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
allLogin, err := getFirefoxLoginData() |
|
|
|
|
|
|
|
|
|
|
|
finallyKey = finallyKey[:24] |
|
|
|
|
|
|
|
logins, err := getFirefoxLoginData() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
for _, v := range allLogin { |
|
|
|
|
|
|
|
|
|
|
|
for _, v := range logins { |
|
|
|
userPBE, err := crypto.NewASN1PBE(v.encryptUser) |
|
|
|
userPBE, err := crypto.NewASN1PBE(v.encryptUser) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
@ -233,8 +234,7 @@ func (f *FirefoxPassword) Parse(masterKey []byte) error { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func getFirefoxDecryptKey(key4file string) (item1, item2, a11, a102 []byte, err error) { |
|
|
|
func getFirefoxDecryptKey(key4file string) (item1, item2, a11, a102 []byte, err error) { |
|
|
|
var keyDB *sql.DB |
|
|
|
keyDB, err := sql.Open("sqlite3", key4file) |
|
|
|
keyDB, err = sql.Open("sqlite3", key4file) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, nil, nil, nil, err |
|
|
|
return nil, nil, nil, nil, err |
|
|
|
} |
|
|
|
} |
|
|
@ -251,15 +251,16 @@ func getFirefoxDecryptKey(key4file string) (item1, item2, a11, a102 []byte, err |
|
|
|
return item1, item2, a11, a102, nil |
|
|
|
return item1, item2, a11, a102, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func getFirefoxLoginData() (l []loginData, err error) { |
|
|
|
func getFirefoxLoginData() ([]loginData, error) { |
|
|
|
s, err := os.ReadFile(item.TempFirefoxPassword) |
|
|
|
s, err := os.ReadFile(item.TempFirefoxPassword) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
defer os.Remove(item.TempFirefoxPassword) |
|
|
|
defer os.Remove(item.TempFirefoxPassword) |
|
|
|
h := gjson.GetBytes(s, "logins") |
|
|
|
loginsJSON := gjson.GetBytes(s, "logins") |
|
|
|
if h.Exists() { |
|
|
|
var logins []loginData |
|
|
|
for _, v := range h.Array() { |
|
|
|
if loginsJSON.Exists() { |
|
|
|
|
|
|
|
for _, v := range loginsJSON.Array() { |
|
|
|
var ( |
|
|
|
var ( |
|
|
|
m loginData |
|
|
|
m loginData |
|
|
|
user []byte |
|
|
|
user []byte |
|
|
@ -277,16 +278,16 @@ func getFirefoxLoginData() (l []loginData, err error) { |
|
|
|
m.encryptUser = user |
|
|
|
m.encryptUser = user |
|
|
|
m.encryptPass = pass |
|
|
|
m.encryptPass = pass |
|
|
|
m.CreateDate = typeutil.TimeStamp(v.Get("timeCreated").Int() / 1000) |
|
|
|
m.CreateDate = typeutil.TimeStamp(v.Get("timeCreated").Int() / 1000) |
|
|
|
l = append(l, m) |
|
|
|
logins = append(logins, m) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return l, nil |
|
|
|
return logins, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (f *FirefoxPassword) Name() string { |
|
|
|
func (f *FirefoxPassword) Name() string { |
|
|
|
return "password" |
|
|
|
return "password" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (f *FirefoxPassword) Length() int { |
|
|
|
func (f *FirefoxPassword) Len() int { |
|
|
|
return len(*f) |
|
|
|
return len(*f) |
|
|
|
} |
|
|
|
} |
|
|
|