mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-19 18:58:03 +02:00
1ec2781131
* feat: add Firefox extract methods and complete data model fields Firefox extract methods: - extractPasswords: JSON + ASN1PBE decryption via decryptPBE helper - extractCookies: SQLite, plaintext (no encryption), journalOff - extractHistories: SQLite, visit count ASC sort (matches old behavior) - extractDownloads: SQLite, moz_annos JOIN with JSON content parsing - extractBookmarks: SQLite, moz_bookmarks JOIN moz_places - extractExtensions: JSON, filter by location=app-profile - extractLocalStorage: SQLite webappsstore2, reversed originKey parsing Complete data model fields (union of Chromium and Firefox): - CookieEntry: add HasExpire, IsPersistent - DownloadEntry: add MimeType - CreditCardEntry: add NickName, Address - ExtensionEntry: add HomepageURL, Enabled Update Chromium extractors to populate new fields: - extract_cookie.go: fill HasExpire, IsPersistent - extract_download.go: SELECT and fill mime_type - extract_creditcard.go: SELECT nickname, billing_address_id - extract_extension.go: fill HomepageURL, Enabled (state==1) Tests: - Full test coverage for all 7 Firefox extract functions - Password test uses known ASN1PBE test vectors from crypto package - Table-driven tests for parseOriginKey - Updated Chromium tests for new fields * fix: add COALESCE for nullable bookmark title in Firefox query Firefox moz_bookmarks.title can be NULL (PR #500 fixed this in old code). Add COALESCE to handle NULL gracefully in SQL instead of relying on driver-specific NULL→string conversion behavior. * fix: enable journalOff for all Firefox SQLite extractors and populate cookie flags - Set journalOff=true for extract_history, extract_download, extract_bookmark (Firefox databases require PRAGMA journal_mode=off to avoid lock errors) - Populate HasExpire and IsPersistent for Firefox cookies (derived from expiry>0) - Add test assertions for HasExpire/IsPersistent in both Chromium and Firefox
66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
package firefox
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestExtractLocalStorage(t *testing.T) {
|
|
path := createTestDB(t, "webappsstore.sqlite", []string{webappsstore2Schema},
|
|
insertWebappsstore("moc.buhtig.:https:443", "theme", "dark"),
|
|
insertWebappsstore("moc.buhtig.:https:443", "lang", "en"),
|
|
insertWebappsstore("moc.elpmaxe.:http:8080", "token", "abc123"),
|
|
)
|
|
|
|
got, err := extractLocalStorage(path)
|
|
require.NoError(t, err)
|
|
require.Len(t, got, 3)
|
|
|
|
// Verify field mapping by collecting into lookup
|
|
byKey := map[string]string{}
|
|
for _, entry := range got {
|
|
byKey[entry.URL+"/"+entry.Key] = entry.Value
|
|
}
|
|
assert.Equal(t, "dark", byKey["https://github.com:443/theme"])
|
|
assert.Equal(t, "en", byKey["https://github.com:443/lang"])
|
|
assert.Equal(t, "abc123", byKey["http://example.com:8080/token"])
|
|
}
|
|
|
|
func TestParseOriginKey(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
originKey string
|
|
want string
|
|
}{
|
|
{
|
|
name: "https with port",
|
|
originKey: "moc.buhtig.:https:443",
|
|
want: "https://github.com:443",
|
|
},
|
|
{
|
|
name: "http with non-standard port",
|
|
originKey: "moc.elpmaxe.:http:8080",
|
|
want: "http://example.com:8080",
|
|
},
|
|
{
|
|
name: "no port",
|
|
originKey: "moc.elpmaxe.:https",
|
|
want: "https://example.com",
|
|
},
|
|
{
|
|
name: "invalid format",
|
|
originKey: "something",
|
|
want: "something",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := parseOriginKey(tt.originKey)
|
|
assert.Equal(t, tt.want, got)
|
|
})
|
|
}
|
|
}
|