mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-07-06 21:37:47 +02:00
feat: add CountEntries to skip decryption for list --detail (#562)
* feat: add CountEntries to skip decryption for list --detail (#549) * test: add CountEntries and countCategory tests at browser level * fix: address review feedback on CountRows and countLocalStorage * test: add CountRows unit tests
This commit is contained in:
@@ -238,6 +238,53 @@ func extractNamespaceOrigin(key string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func countLocalStorage(path string) (int, error) {
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
db, err := leveldb.OpenFile(path, nil)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
var count int
|
||||
iter := db.NewIterator(nil, nil)
|
||||
defer iter.Release()
|
||||
|
||||
for iter.Next() {
|
||||
if _, ok := parseLocalStorageEntry(iter.Key(), iter.Value()); ok {
|
||||
count++
|
||||
}
|
||||
}
|
||||
return count, iter.Error()
|
||||
}
|
||||
|
||||
func countSessionStorage(path string) (int, error) {
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
db, err := leveldb.OpenFile(path, nil)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
var count int
|
||||
iter := db.NewIterator(nil, nil)
|
||||
defer iter.Release()
|
||||
|
||||
mapPrefix := []byte("map-")
|
||||
for iter.Next() {
|
||||
if bytes.HasPrefix(iter.Key(), mapPrefix) {
|
||||
if sep := bytes.IndexByte(iter.Key()[len(mapPrefix):], '-'); sep >= 0 {
|
||||
count++
|
||||
}
|
||||
}
|
||||
}
|
||||
return count, iter.Error()
|
||||
}
|
||||
|
||||
// decodeSessionStorageValue decodes a session storage value.
|
||||
// Values are raw UTF-16 LE (no format byte prefix, unlike localStorage).
|
||||
func decodeSessionStorageValue(value []byte) string {
|
||||
|
||||
Reference in New Issue
Block a user