mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-04 05:43:27 +01:00
fix(chromium): export Yandex rows without the data key (#666)
Without the data key the Yandex stores exported nothing, unlike every other store, so a key failure or a master password lost the rows and list --detail, which reads no key, counted 0.
This commit is contained in:
1 parent
1636091b3f
commit
cebfa97ed6
8 files changed
+54
-19
No files matched your search
@@ -65,10 +65,7 @@ func extractCreditCards(masterKeys masterkey.Set, path string, out browser.Colle
|
||||
|
||||
// extractYandexCreditCards reads the records table (not Chromium's credit_cards). AAD = guid.
|
||||
func extractYandexCreditCards(masterKeys masterkey.Set, path string, out browser.Collector) error {
|
||||
dataKey, err := loadYandexDataKey(path, masterKeys[masterkey.V10])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dataKey, keyErr := loadYandexDataKey(path, masterKeys[masterkey.V10])
|
||||
|
||||
cards, err := sqlitex.QueryRows(path, false, yandexCreditCardQuery,
|
||||
func(rows *sql.Rows) (record.CreditCard, error) {
|
||||
@@ -91,6 +88,10 @@ func extractYandexCreditCards(masterKeys masterkey.Set, path string, out browser
|
||||
ExpYear: public.ExpireDateYear,
|
||||
NickName: public.CardTitle,
|
||||
}
|
||||
if dataKey == nil {
|
||||
out.Fail(fmt.Errorf("yandex: card %s: %w", guid, keyErr))
|
||||
return entry, nil
|
||||
}
|
||||
|
||||
plaintext, err := crypto.AESGCMDecryptBlob(dataKey, privateData, yandexCardAAD(guid, nil))
|
||||
if err != nil {
|
||||
|
||||
@@ -103,8 +103,13 @@ func TestExtractYandexCreditCards_WrongMasterKey(t *testing.T) {
|
||||
yandexCreditCard{GUID: "g1", FullCardNumber: "4111"},
|
||||
)
|
||||
|
||||
err := extractYandexCreditCards(masterkey.Set{masterkey.V10: wrongKey}, path, &testCollector{})
|
||||
require.Error(t, err)
|
||||
var out testCollector
|
||||
require.NoError(t, extractYandexCreditCards(masterkey.Set{masterkey.V10: wrongKey}, path, &out))
|
||||
cards := collected[record.CreditCard](t, &out)
|
||||
require.Len(t, cards, 1, "the card exports without its number")
|
||||
assert.Equal(t, "g1", cards[0].GUID)
|
||||
assert.Empty(t, cards[0].Number)
|
||||
assert.Len(t, out.fails, 1)
|
||||
}
|
||||
|
||||
func TestYandexCardAAD(t *testing.T) {
|
||||
|
||||
@@ -54,10 +54,7 @@ func extractPasswordsWithQuery(masterKeys masterkey.Set, path string, store reco
|
||||
// extractYandexPasswords walks Ya Passman Data.
|
||||
// Note: URL column is origin_url — it's what the per-row AAD is computed over (not action_url).
|
||||
func extractYandexPasswords(masterKeys masterkey.Set, path string, out browser.Collector) error {
|
||||
dataKey, err := loadYandexDataKey(path, masterKeys[masterkey.V10])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dataKey, keyErr := loadYandexDataKey(path, masterKeys[masterkey.V10])
|
||||
|
||||
logins, err := sqlitex.QueryRows(path, false, yandexLoginQuery,
|
||||
func(rows *sql.Rows) (record.Login, error) {
|
||||
@@ -73,6 +70,10 @@ func extractYandexPasswords(masterKeys masterkey.Set, path string, out browser.C
|
||||
CreatedAt: timeconv.Chromium(created),
|
||||
Store: record.StoreLocal,
|
||||
}
|
||||
if dataKey == nil {
|
||||
out.Fail(fmt.Errorf("yandex: password for %s: %w", originURL, keyErr))
|
||||
return entry, nil
|
||||
}
|
||||
aad := yandexLoginAAD(originURL, usernameElem, usernameVal, passwordElem, signonRealm, nil)
|
||||
plaintext, err := crypto.AESGCMDecryptBlob(dataKey, passwordValue, aad)
|
||||
if err != nil {
|
||||
|
||||
@@ -90,7 +90,7 @@ func TestExtractYandexPasswords(t *testing.T) {
|
||||
assert.Equal(t, "hunter2", got[0].Password)
|
||||
}
|
||||
|
||||
func TestExtractYandexPasswords_MasterPasswordSkipped(t *testing.T) {
|
||||
func TestExtractYandexPasswords_MasterPasswordKeepsTheLogins(t *testing.T) {
|
||||
masterKey := bytes.Repeat([]byte{0x11}, 32)
|
||||
dataKey := bytes.Repeat([]byte{0x22}, 32)
|
||||
|
||||
@@ -103,9 +103,31 @@ func TestExtractYandexPasswords_MasterPasswordSkipped(t *testing.T) {
|
||||
)
|
||||
|
||||
var out testCollector
|
||||
err := extractYandexPasswords(masterkey.Set{masterkey.V10: masterKey}, path, &out)
|
||||
require.ErrorIs(t, err, errYandexMasterPasswordSet)
|
||||
assert.Empty(t, out.records, "a master-password profile yields no logins")
|
||||
require.NoError(t, extractYandexPasswords(masterkey.Set{masterkey.V10: masterKey}, path, &out))
|
||||
logins := collected[record.Login](t, &out)
|
||||
require.Len(t, logins, 1)
|
||||
assert.Equal(t, "alice", logins[0].Username)
|
||||
assert.Empty(t, logins[0].Password)
|
||||
require.Len(t, out.fails, 1)
|
||||
assert.ErrorIs(t, out.fails[0], errYandexMasterPasswordSet)
|
||||
}
|
||||
|
||||
func TestExtractYandexPasswords_WithoutAKeyKeepsTheLogins(t *testing.T) {
|
||||
masterKey := bytes.Repeat([]byte{0x11}, 32)
|
||||
dataKey := bytes.Repeat([]byte{0x22}, 32)
|
||||
path := setupYandexPasswordDB(t, masterKey, dataKey, false,
|
||||
yandexPassword{OriginURL: "https://a.yandex.ru", UsernameVal: "alice", Password: "hunter2"},
|
||||
yandexPassword{OriginURL: "https://b.yandex.ru", UsernameVal: "bob", Password: "hunter3"},
|
||||
)
|
||||
|
||||
var out testCollector
|
||||
require.NoError(t, extractYandexPasswords(nil, path, &out))
|
||||
logins := collected[record.Login](t, &out)
|
||||
require.Len(t, logins, 2)
|
||||
for _, l := range logins {
|
||||
assert.Empty(t, l.Password)
|
||||
}
|
||||
assert.Len(t, out.fails, 2, "each login without its password is a record-level problem")
|
||||
}
|
||||
|
||||
func TestExtractYandexPasswords_WrongMasterKey(t *testing.T) {
|
||||
@@ -120,10 +142,13 @@ func TestExtractYandexPasswords_WrongMasterKey(t *testing.T) {
|
||||
},
|
||||
)
|
||||
|
||||
// A wrong master key fails at the intermediate step, surfacing as an error
|
||||
// from the extractor.
|
||||
err := extractYandexPasswords(masterkey.Set{masterkey.V10: wrongKey}, path, &testCollector{})
|
||||
require.Error(t, err)
|
||||
// A wrong master key fails at the intermediate step, so the login exports without its password.
|
||||
var out testCollector
|
||||
require.NoError(t, extractYandexPasswords(masterkey.Set{masterkey.V10: wrongKey}, path, &out))
|
||||
logins := collected[record.Login](t, &out)
|
||||
require.Len(t, logins, 1)
|
||||
assert.Empty(t, logins[0].Password)
|
||||
assert.Len(t, out.fails, 1)
|
||||
}
|
||||
|
||||
func TestYandexLoginAAD_NoMasterPassword(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user