mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-04 05:43:27 +01:00
* refactor: stream records through sqlitex and the collector A row that failed to scan was logged at debug and dropped, so it never counted toward partial; it now reaches Collector.Fail. Every SQLite open goes through sqlitex with options instead of a bool, and extractors add records as they read them. * refactor: read SQLite rows with plain loops EachRow hid each extractor's loop and its skip rule behind two callbacks; every extractor now opens, queries, and walks its own rows, so the control flow reads top to bottom. * refactor(browser): drop the memoizing key closures Firefox derives its key once before the login loop, and Yandex loads its data key at the first row, so the state sits in plain variables where the loop uses it instead of inside a closure. * fix(safari): report unreadable localStorage origins A broken origin, database or row was only logged at debug level, so it never counted toward a partial result.
57 lines
1.4 KiB
Go
57 lines
1.4 KiB
Go
package firefox
|
|
|
|
import (
|
|
"github.com/moond4rk/hackbrowserdata/internal/browser"
|
|
"github.com/moond4rk/hackbrowserdata/internal/record"
|
|
"github.com/moond4rk/hackbrowserdata/internal/sqlitex"
|
|
"github.com/moond4rk/hackbrowserdata/internal/timeconv"
|
|
)
|
|
|
|
// bookmarkQuery keeps only bookmarks, as folders and separators have no place; the parent join names the folder.
|
|
const bookmarkQuery = `SELECT b.id, p.url, b.type, b.dateAdded, COALESCE(b.title, ''), COALESCE(f.title, '')
|
|
FROM moz_bookmarks b
|
|
INNER JOIN moz_places p ON b.fk = p.id
|
|
LEFT JOIN moz_bookmarks f ON b.parent = f.id`
|
|
|
|
func extractBookmarks(path string, out browser.Collector) error {
|
|
database, err := sqlitex.Open(path, sqlitex.JournalOff)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer database.Close()
|
|
|
|
rows, err := database.Query(bookmarkQuery)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer rows.Close()
|
|
|
|
for rows.Next() {
|
|
var id, dateAdded int64
|
|
var url, title, folder string
|
|
var typeCode int64
|
|
if err := rows.Scan(&id, &url, &typeCode, &dateAdded, &title, &folder); err != nil {
|
|
out.Fail(err)
|
|
continue
|
|
}
|
|
out.Add(&record.Bookmark{
|
|
ID: id,
|
|
Name: title,
|
|
Type: bookmarkType(typeCode),
|
|
URL: url,
|
|
Folder: folder,
|
|
CreatedAt: timeconv.UnixMicro(dateAdded),
|
|
})
|
|
}
|
|
return rows.Err()
|
|
}
|
|
|
|
func bookmarkType(typeCode int64) string {
|
|
switch typeCode {
|
|
case 1:
|
|
return "url"
|
|
default:
|
|
return "folder"
|
|
}
|
|
}
|