mirror of
https://github.com/moonD4rk/HackBrowserData
synced 2025-04-26 04:58:03 +00:00
* chore: downgrade golang version to 1.20, support windows 7 * chore: Update dependencies for Go project. - Update dependencies in go.sum - Improvements and optimizations in various files - Bug fixes and error handling enhancements * chore: Update modernc.org/sqlite library versions in go.mod and go.sum files - Update version of `modernc.org/sqlite` to `v1.31.1` in `go.mod` and `go.sum` files - Update module hash in `go.sum` file for `modernc.org/sqlite` - Ensure consistency between `go.mod` and `go.sum` files in relation to `modernc.org/sqlite` version * chore: replace log/slog with standard logger (#436) * chore: replace log/slog with standard logger * chore: Update Go dependencies and versions - Update Go version from `1.22.5` to `1.20` and other dependencies - Update critical dependencies to latest versions - Ensure compatibility with new versions of dependencies * chore: Optimize dependency management in workflows - Update build and lint workflows to use `go mod tidy` for getting dependencies - Change modules download mode to `'mod'` in linters configuration - Add step to get dependencies in lint workflow * refactor: Update dependencies and refactor Chromium key deletion logic - Update `modernc.org/sqlite` to `v1.31.1` in `go.mod` and `go.sum` - Increase version number to `0.5.0` in `cmd/hack-browser-data/main.go` - Refactor and update logic for filtering and copying items in `browser/chromium/chromium.go` * Improve logging functionality and data type conversion - Add `String()` method to `DataType` enum in types.go - Update log level to Debug in logger_test.go - Set log level to Debug in `TestLoggerDebug` and `TestLoggerDebugf` functions
123 lines
3.1 KiB
Go
123 lines
3.1 KiB
Go
package browser
|
|
|
|
import (
|
|
"path/filepath"
|
|
"sort"
|
|
"strings"
|
|
|
|
"github.com/moond4rk/hackbrowserdata/browser/chromium"
|
|
"github.com/moond4rk/hackbrowserdata/browser/firefox"
|
|
"github.com/moond4rk/hackbrowserdata/browserdata"
|
|
"github.com/moond4rk/hackbrowserdata/log"
|
|
"github.com/moond4rk/hackbrowserdata/utils/fileutil"
|
|
"github.com/moond4rk/hackbrowserdata/utils/typeutil"
|
|
)
|
|
|
|
type Browser interface {
|
|
// Name is browser's name
|
|
Name() string
|
|
// BrowsingData returns all browsing data in the browser.
|
|
BrowsingData(isFullExport bool) (*browserdata.BrowserData, error)
|
|
}
|
|
|
|
// PickBrowsers returns a list of browsers that match the name and profile.
|
|
func PickBrowsers(name, profile string) ([]Browser, error) {
|
|
var browsers []Browser
|
|
clist := pickChromium(name, profile)
|
|
for _, b := range clist {
|
|
if b != nil {
|
|
browsers = append(browsers, b)
|
|
}
|
|
}
|
|
flist := pickFirefox(name, profile)
|
|
for _, b := range flist {
|
|
if b != nil {
|
|
browsers = append(browsers, b)
|
|
}
|
|
}
|
|
return browsers, nil
|
|
}
|
|
|
|
func pickChromium(name, profile string) []Browser {
|
|
var browsers []Browser
|
|
name = strings.ToLower(name)
|
|
if name == "all" {
|
|
for _, v := range chromiumList {
|
|
if !fileutil.IsDirExists(filepath.Clean(v.profilePath)) {
|
|
log.Warnf("find browser failed, profile folder does not exist, browser %s", v.name)
|
|
continue
|
|
}
|
|
multiChromium, err := chromium.New(v.name, v.storage, v.profilePath, v.dataTypes)
|
|
if err != nil {
|
|
log.Errorf("new chromium error %v", err)
|
|
continue
|
|
}
|
|
for _, b := range multiChromium {
|
|
log.Warnf("find browser success, browser %s", b.Name())
|
|
browsers = append(browsers, b)
|
|
}
|
|
}
|
|
}
|
|
if c, ok := chromiumList[name]; ok {
|
|
if profile == "" {
|
|
profile = c.profilePath
|
|
}
|
|
if !fileutil.IsDirExists(filepath.Clean(profile)) {
|
|
log.Errorf("find browser failed, profile folder does not exist, browser %s", c.name)
|
|
}
|
|
chromes, err := chromium.New(c.name, c.storage, profile, c.dataTypes)
|
|
if err != nil {
|
|
log.Errorf("new chromium error %v", err)
|
|
}
|
|
for _, chrome := range chromes {
|
|
log.Warnf("find browser success, browser %s", chrome.Name())
|
|
browsers = append(browsers, chrome)
|
|
}
|
|
}
|
|
return browsers
|
|
}
|
|
|
|
func pickFirefox(name, profile string) []Browser {
|
|
var browsers []Browser
|
|
name = strings.ToLower(name)
|
|
if name == "all" || name == "firefox" {
|
|
for _, v := range firefoxList {
|
|
if profile == "" {
|
|
profile = v.profilePath
|
|
} else {
|
|
profile = fileutil.ParentDir(profile)
|
|
}
|
|
|
|
if !fileutil.IsDirExists(filepath.Clean(profile)) {
|
|
log.Warnf("find browser failed, profile folder does not exist, browser %s", v.name)
|
|
continue
|
|
}
|
|
|
|
if multiFirefox, err := firefox.New(profile, v.dataTypes); err == nil {
|
|
for _, b := range multiFirefox {
|
|
log.Warnf("find browser success, browser %s", b.Name())
|
|
browsers = append(browsers, b)
|
|
}
|
|
} else {
|
|
log.Errorf("new firefox error %v", err)
|
|
}
|
|
}
|
|
|
|
return browsers
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func ListBrowsers() []string {
|
|
var l []string
|
|
l = append(l, typeutil.Keys(chromiumList)...)
|
|
l = append(l, typeutil.Keys(firefoxList)...)
|
|
sort.Strings(l)
|
|
return l
|
|
}
|
|
|
|
func Names() string {
|
|
return strings.Join(ListBrowsers(), "|")
|
|
}
|