feat(chromium): extract passwords from the account-synced store (#637)

Chromium keeps account-synced credentials in a separate "Login Data For Account" DB. Entries carry a Store field because the same credential can legitimately exist in both stores.
This commit is contained in:
slimwang authored and GitHub committed 2026-08-25 11:13:10 +08:00
1 parent 9624e50a4f
commit d2b2955d6c
12 files changed
+245 -16

No files matched your search

+19 -1
View File
@@ -9,6 +9,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/moond4rk/hackbrowserdata/masterkey"
"github.com/moond4rk/hackbrowserdata/types"
)
func setupLoginDB(t *testing.T) string {
@@ -22,7 +23,7 @@ func setupLoginDB(t *testing.T) string {
func TestExtractPasswords(t *testing.T) {
path := setupLoginDB(t)
got, err := extractPasswords(masterkey.MasterKeys{}, path)
got, err := extractPasswords(masterkey.MasterKeys{}, path, types.PasswordStoreLocal)
require.NoError(t, err)
require.Len(t, got, 2)
@@ -35,6 +36,23 @@ func TestExtractPasswords(t *testing.T) {
assert.False(t, got[0].CreatedAt.IsZero())
// Password is empty because masterKey is nil (decrypt returns empty)
assert.Empty(t, got[0].Password)
assert.Equal(t, types.PasswordStoreLocal, got[0].Store)
}
// A credential whose blob cannot be decrypted must still be reported, otherwise a missing
// master key would silently shrink the export instead of yielding empty passwords.
func TestExtractPasswords_UndecryptableBlobStillListed(t *testing.T) {
path := createTestDB(t, "Login Data", loginsSchema,
insertLogin("https://enc.com", "https://enc.com/login", "carol", "763130deadbeef", 13350000000000000),
)
got, err := extractPasswords(masterkey.MasterKeys{}, path, types.PasswordStoreAccount)
require.NoError(t, err)
require.Len(t, got, 1)
assert.Equal(t, "carol", got[0].Username)
assert.Empty(t, got[0].Password)
assert.Equal(t, types.PasswordStoreAccount, got[0].Store)
}
func TestCountPasswords(t *testing.T) {