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.
66 lines
1.6 KiB
Go
66 lines
1.6 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"
|
|
)
|
|
|
|
const cookieQuery = `SELECT name, value, host, path,
|
|
creationTime, expiry, isSecure, isHttpOnly, sameSite FROM moz_cookies`
|
|
|
|
func extractCookies(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(cookieQuery)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer rows.Close()
|
|
|
|
for rows.Next() {
|
|
var (
|
|
name, value, host, cookiePath string
|
|
isSecure, isHTTPOnly int
|
|
createdAt, expiry int64
|
|
sameSite int
|
|
)
|
|
if err := rows.Scan(&name, &value, &host, &cookiePath,
|
|
&createdAt, &expiry, &isSecure, &isHTTPOnly, &sameSite); err != nil {
|
|
out.Fail(err)
|
|
continue
|
|
}
|
|
hasExpire := expiry > 0
|
|
sameSiteStr := "unspecified"
|
|
switch sameSite {
|
|
case 0:
|
|
sameSiteStr = "none"
|
|
case 1:
|
|
sameSiteStr = "lax"
|
|
case 2:
|
|
sameSiteStr = "strict"
|
|
case 256:
|
|
// not specified by Set-Cookie
|
|
}
|
|
out.Add(&record.Cookie{
|
|
Name: name,
|
|
Host: host,
|
|
Path: cookiePath,
|
|
Value: value, // Firefox cookies are not encrypted
|
|
IsSecure: isSecure != 0,
|
|
IsHTTPOnly: isHTTPOnly != 0,
|
|
HasExpire: hasExpire,
|
|
IsPersistent: hasExpire,
|
|
ExpireAt: timeconv.Unix(expiry),
|
|
CreatedAt: timeconv.UnixMicro(createdAt),
|
|
SameSite: sameSiteStr,
|
|
})
|
|
}
|
|
return rows.Err()
|
|
}
|