mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-10-13 03:37:12 +02:00
fix: per-tier master-key retrievers for mixed-cipher profiles (#579)
* fix: per-tier master-key retrievers for mixed-cipher profiles
This commit is contained in:
1 parent
e50c623db0
commit
7b9a973c9c
29 files changed
+699
-227
No files matched your search
@@ -4,7 +4,7 @@ import (
|
||||
"database/sql"
|
||||
"sort"
|
||||
|
||||
"github.com/moond4rk/hackbrowserdata/log"
|
||||
"github.com/moond4rk/hackbrowserdata/crypto/keyretriever"
|
||||
"github.com/moond4rk/hackbrowserdata/types"
|
||||
"github.com/moond4rk/hackbrowserdata/utils/sqliteutil"
|
||||
)
|
||||
@@ -14,13 +14,11 @@ const (
|
||||
countLoginQuery = `SELECT COUNT(*) FROM logins`
|
||||
)
|
||||
|
||||
func extractPasswords(masterKey []byte, path string) ([]types.LoginEntry, error) {
|
||||
return extractPasswordsWithQuery(masterKey, path, defaultLoginQuery)
|
||||
func extractPasswords(keys keyretriever.MasterKeys, path string) ([]types.LoginEntry, error) {
|
||||
return extractPasswordsWithQuery(keys, path, defaultLoginQuery)
|
||||
}
|
||||
|
||||
func extractPasswordsWithQuery(masterKey []byte, path, query string) ([]types.LoginEntry, error) {
|
||||
var decryptFails int
|
||||
var lastErr error
|
||||
func extractPasswordsWithQuery(keys keyretriever.MasterKeys, path, query string) ([]types.LoginEntry, error) {
|
||||
logins, err := sqliteutil.QueryRows(path, false, query,
|
||||
func(rows *sql.Rows) (types.LoginEntry, error) {
|
||||
var url, username string
|
||||
@@ -29,11 +27,7 @@ func extractPasswordsWithQuery(masterKey []byte, path, query string) ([]types.Lo
|
||||
if err := rows.Scan(&url, &username, &pwd, &created); err != nil {
|
||||
return types.LoginEntry{}, err
|
||||
}
|
||||
password, err := decryptValue(masterKey, pwd)
|
||||
if err != nil {
|
||||
decryptFails++
|
||||
lastErr = err
|
||||
}
|
||||
password, _ := decryptValue(keys, pwd)
|
||||
return types.LoginEntry{
|
||||
URL: url,
|
||||
Username: username,
|
||||
@@ -44,9 +38,6 @@ func extractPasswordsWithQuery(masterKey []byte, path, query string) ([]types.Lo
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if decryptFails > 0 {
|
||||
log.Warnf("passwords: total=%d decrypt_failed=%d last_err=%v", len(logins), decryptFails, lastErr)
|
||||
}
|
||||
|
||||
sort.Slice(logins, func(i, j int) bool {
|
||||
return logins[i].CreatedAt.After(logins[j].CreatedAt)
|
||||
@@ -56,9 +47,9 @@ func extractPasswordsWithQuery(masterKey []byte, path, query string) ([]types.Lo
|
||||
|
||||
// extractYandexPasswords extracts passwords from Yandex's Ya Passman Data, which stores the URL in
|
||||
// action_url instead of origin_url.
|
||||
func extractYandexPasswords(masterKey []byte, path string) ([]types.LoginEntry, error) {
|
||||
func extractYandexPasswords(keys keyretriever.MasterKeys, path string) ([]types.LoginEntry, error) {
|
||||
const yandexLoginQuery = `SELECT action_url, username_value, password_value, date_created FROM logins`
|
||||
return extractPasswordsWithQuery(masterKey, path, yandexLoginQuery)
|
||||
return extractPasswordsWithQuery(keys, path, yandexLoginQuery)
|
||||
}
|
||||
|
||||
func countPasswords(path string) (int, error) {
|
||||
|
||||
Reference in new issue
Block a user