mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-07-08 21:37:49 +02:00
refactor: add provider software folder and check linters
Merge pull request #172 from moonD4rk/fix/golangci-lint
This commit is contained in:
+3
-5
@@ -8,7 +8,6 @@ run:
|
|||||||
linters:
|
linters:
|
||||||
enable:
|
enable:
|
||||||
- 'asciicheck'
|
- 'asciicheck'
|
||||||
- 'deadcode'
|
|
||||||
- 'depguard'
|
- 'depguard'
|
||||||
- 'dogsled'
|
- 'dogsled'
|
||||||
- 'errorlint'
|
- 'errorlint'
|
||||||
@@ -29,7 +28,6 @@ linters:
|
|||||||
- 'revive'
|
- 'revive'
|
||||||
- 'typecheck'
|
- 'typecheck'
|
||||||
- 'unconvert'
|
- 'unconvert'
|
||||||
- 'varcheck'
|
|
||||||
- 'whitespace'
|
- 'whitespace'
|
||||||
disable:
|
disable:
|
||||||
# unsupported lint with golang 1.18+ ref: https://github.com/golangci/golangci-lint/issues/2649
|
# unsupported lint with golang 1.18+ ref: https://github.com/golangci/golangci-lint/issues/2649
|
||||||
@@ -42,6 +40,8 @@ linters:
|
|||||||
- 'stylecheck'
|
- 'stylecheck'
|
||||||
- 'unused'
|
- 'unused'
|
||||||
- 'errcheck'
|
- 'errcheck'
|
||||||
|
- 'deadcode'
|
||||||
|
- 'varcheck'
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
exclude-use-default: false
|
exclude-use-default: false
|
||||||
@@ -60,10 +60,8 @@ issues:
|
|||||||
- G502
|
- G502
|
||||||
- G505
|
- G505
|
||||||
exclude-rules:
|
exclude-rules:
|
||||||
- path: internal/browser/browser\.go
|
- path: internal/provider/provider\.go
|
||||||
linters:
|
linters:
|
||||||
- 'deadcode'
|
|
||||||
- 'varcheck'
|
|
||||||
- 'unused'
|
- 'unused'
|
||||||
max-issues-per-linter: 0
|
max-issues-per-linter: 0
|
||||||
max-same-issues: 0
|
max-same-issues: 0
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"hack-browser-data/internal/browser"
|
|
||||||
"hack-browser-data/internal/log"
|
"hack-browser-data/internal/log"
|
||||||
|
"hack-browser-data/internal/provider"
|
||||||
"hack-browser-data/internal/utils/fileutil"
|
"hack-browser-data/internal/utils/fileutil"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
@@ -29,11 +29,11 @@ func Execute() {
|
|||||||
Name: "hack-browser-data",
|
Name: "hack-browser-data",
|
||||||
Usage: "Export passwords/cookies/history/bookmarks from browser",
|
Usage: "Export passwords/cookies/history/bookmarks from browser",
|
||||||
UsageText: "[hack-browser-data -b chrome -f json -dir results -cc]\nExport all browingdata(password/cookie/history/bookmark) from browser\nGithub Link: https://github.com/moonD4rk/HackBrowserData",
|
UsageText: "[hack-browser-data -b chrome -f json -dir results -cc]\nExport all browingdata(password/cookie/history/bookmark) from browser\nGithub Link: https://github.com/moonD4rk/HackBrowserData",
|
||||||
Version: "0.4.3",
|
Version: "0.4.4",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.BoolFlag{Name: "verbose", Aliases: []string{"vv"}, Destination: &verbose, Value: false, Usage: "verbose"},
|
&cli.BoolFlag{Name: "verbose", Aliases: []string{"vv"}, Destination: &verbose, Value: false, Usage: "verbose"},
|
||||||
&cli.BoolFlag{Name: "compress", Aliases: []string{"zip"}, Destination: &compress, Value: false, Usage: "compress result to zip"},
|
&cli.BoolFlag{Name: "compress", Aliases: []string{"zip"}, Destination: &compress, Value: false, Usage: "compress result to zip"},
|
||||||
&cli.StringFlag{Name: "browser", Aliases: []string{"b"}, Destination: &browserName, Value: "all", Usage: "available browsers: all|" + strings.Join(browser.ListBrowser(), "|")},
|
&cli.StringFlag{Name: "browser", Aliases: []string{"b"}, Destination: &browserName, Value: "all", Usage: "available browsers: all|" + strings.Join(provider.ListBrowsers(), "|")},
|
||||||
&cli.StringFlag{Name: "results-dir", Aliases: []string{"dir"}, Destination: &outputDir, Value: "results", Usage: "export dir"},
|
&cli.StringFlag{Name: "results-dir", Aliases: []string{"dir"}, Destination: &outputDir, Value: "results", Usage: "export dir"},
|
||||||
&cli.StringFlag{Name: "format", Aliases: []string{"f"}, Destination: &outputFormat, Value: "csv", Usage: "file name csv|json"},
|
&cli.StringFlag{Name: "format", Aliases: []string{"f"}, Destination: &outputFormat, Value: "csv", Usage: "file name csv|json"},
|
||||||
&cli.StringFlag{Name: "profile-path", Aliases: []string{"p"}, Destination: &profilePath, Value: "", Usage: "custom profile dir path, get with chrome://version"},
|
&cli.StringFlag{Name: "profile-path", Aliases: []string{"p"}, Destination: &profilePath, Value: "", Usage: "custom profile dir path, get with chrome://version"},
|
||||||
@@ -45,11 +45,8 @@ func Execute() {
|
|||||||
} else {
|
} else {
|
||||||
log.Init("notice")
|
log.Init("notice")
|
||||||
}
|
}
|
||||||
var (
|
|
||||||
browsers []browser.Browser
|
browsers, err := provider.PickBrowsers(browserName, profilePath)
|
||||||
err error
|
|
||||||
)
|
|
||||||
browsers, err = browser.PickBrowser(browserName, profilePath)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,7 @@
|
|||||||
package browser
|
package browser
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"sort"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"hack-browser-data/internal/browingdata"
|
"hack-browser-data/internal/browingdata"
|
||||||
"hack-browser-data/internal/browser/chromium"
|
|
||||||
"hack-browser-data/internal/browser/firefox"
|
|
||||||
"hack-browser-data/internal/log"
|
|
||||||
"hack-browser-data/internal/utils/fileutil"
|
|
||||||
"hack-browser-data/internal/utils/typeutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Browser interface {
|
type Browser interface {
|
||||||
@@ -20,114 +10,3 @@ type Browser interface {
|
|||||||
// BrowsingData returns all browsing data in the browser.
|
// BrowsingData returns all browsing data in the browser.
|
||||||
BrowsingData() (*browingdata.Data, error)
|
BrowsingData() (*browingdata.Data, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func PickBrowser(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.FolderExists(filepath.Clean(v.profilePath)) {
|
|
||||||
log.Noticef("find browser %s failed, profile folder does not exist", v.name)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if multiChromium, err := chromium.New(v.name, v.storage, v.profilePath, v.items); err == nil {
|
|
||||||
log.Noticef("find browser %s success", v.name)
|
|
||||||
for _, b := range multiChromium {
|
|
||||||
log.Noticef("find browser %s success", b.Name())
|
|
||||||
browsers = append(browsers, b)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.Errorf("new chromium error: %s", err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if c, ok := chromiumList[name]; ok {
|
|
||||||
if profile == "" {
|
|
||||||
profile = c.profilePath
|
|
||||||
}
|
|
||||||
if !fileutil.FolderExists(filepath.Clean(profile)) {
|
|
||||||
log.Fatalf("find browser %s failed, profile folder does not exist", c.name)
|
|
||||||
}
|
|
||||||
chromiumList, err := chromium.New(c.name, c.storage, profile, c.items)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("new chromium error: %s", err)
|
|
||||||
}
|
|
||||||
for _, b := range chromiumList {
|
|
||||||
log.Noticef("find browser %s success", b.Name())
|
|
||||||
browsers = append(browsers, b)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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.FolderExists(filepath.Clean(profile)) {
|
|
||||||
log.Noticef("find browser firefox %s failed, profile folder does not exist", v.name)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if multiFirefox, err := firefox.New(v.name, v.storage, profile, v.items); err == nil {
|
|
||||||
for _, b := range multiFirefox {
|
|
||||||
log.Noticef("find browser firefox %s success", b.Name())
|
|
||||||
browsers = append(browsers, b)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.Error(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return browsers
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func ListBrowser() []string {
|
|
||||||
var l []string
|
|
||||||
l = append(l, typeutil.Keys(chromiumList)...)
|
|
||||||
l = append(l, typeutil.Keys(firefoxList)...)
|
|
||||||
sort.Strings(l)
|
|
||||||
return l
|
|
||||||
}
|
|
||||||
|
|
||||||
// home dir path for all platforms
|
|
||||||
var homeDir, _ = os.UserHomeDir()
|
|
||||||
|
|
||||||
const (
|
|
||||||
chromeName = "Chrome"
|
|
||||||
chromeBetaName = "Chrome Beta"
|
|
||||||
chromiumName = "Chromium"
|
|
||||||
edgeName = "Microsoft Edge"
|
|
||||||
braveName = "Brave"
|
|
||||||
operaName = "Opera"
|
|
||||||
operaGXName = "OperaGX"
|
|
||||||
vivaldiName = "Vivaldi"
|
|
||||||
coccocName = "CocCoc"
|
|
||||||
yandexName = "Yandex"
|
|
||||||
firefoxName = "Firefox"
|
|
||||||
speed360Name = "360speed"
|
|
||||||
qqBrowserName = "QQ"
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"hack-browser-data/internal/browingdata"
|
"hack-browser-data/internal/browingdata"
|
||||||
|
"hack-browser-data/internal/browser"
|
||||||
"hack-browser-data/internal/item"
|
"hack-browser-data/internal/item"
|
||||||
"hack-browser-data/internal/utils/fileutil"
|
"hack-browser-data/internal/utils/fileutil"
|
||||||
"hack-browser-data/internal/utils/typeutil"
|
"hack-browser-data/internal/utils/typeutil"
|
||||||
@@ -21,7 +22,7 @@ type chromium struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// New create instance of chromium browser, fill item's path if item is existed.
|
// New create instance of chromium browser, fill item's path if item is existed.
|
||||||
func New(name, storage, profilePath string, items []item.Item) ([]*chromium, error) {
|
func New(name, storage, profilePath string, items []item.Item) ([]browser.Browser, error) {
|
||||||
c := &chromium{
|
c := &chromium{
|
||||||
name: name,
|
name: name,
|
||||||
storage: storage,
|
storage: storage,
|
||||||
@@ -32,7 +33,7 @@ func New(name, storage, profilePath string, items []item.Item) ([]*chromium, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chromiumList := make([]*chromium, 0, len(multiItemPaths))
|
chromiumList := make([]browser.Browser, 0, len(multiItemPaths))
|
||||||
for user, itemPaths := range multiItemPaths {
|
for user, itemPaths := range multiItemPaths {
|
||||||
chromiumList = append(chromiumList, &chromium{
|
chromiumList = append(chromiumList, &chromium{
|
||||||
name: fileutil.BrowserName(name, user),
|
name: fileutil.BrowserName(name, user),
|
||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"hack-browser-data/internal/browingdata"
|
"hack-browser-data/internal/browingdata"
|
||||||
|
"hack-browser-data/internal/browser"
|
||||||
"hack-browser-data/internal/item"
|
"hack-browser-data/internal/item"
|
||||||
"hack-browser-data/internal/utils/fileutil"
|
"hack-browser-data/internal/utils/fileutil"
|
||||||
"hack-browser-data/internal/utils/typeutil"
|
"hack-browser-data/internal/utils/typeutil"
|
||||||
@@ -24,7 +25,7 @@ type firefox struct {
|
|||||||
var ErrProfilePathNotFound = errors.New("profile path not found")
|
var ErrProfilePathNotFound = errors.New("profile path not found")
|
||||||
|
|
||||||
// New returns a new firefox instance.
|
// New returns a new firefox instance.
|
||||||
func New(name, storage, profilePath string, items []item.Item) ([]*firefox, error) {
|
func New(name, storage, profilePath string, items []item.Item) ([]browser.Browser, error) {
|
||||||
f := &firefox{
|
f := &firefox{
|
||||||
name: name,
|
name: name,
|
||||||
storage: storage,
|
storage: storage,
|
||||||
@@ -36,7 +37,7 @@ func New(name, storage, profilePath string, items []item.Item) ([]*firefox, erro
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
firefoxList := make([]*firefox, 0, len(multiItemPaths))
|
firefoxList := make([]browser.Browser, 0, len(multiItemPaths))
|
||||||
for name, itemPaths := range multiItemPaths {
|
for name, itemPaths := range multiItemPaths {
|
||||||
firefoxList = append(firefoxList, &firefox{
|
firefoxList = append(firefoxList, &firefox{
|
||||||
name: fmt.Sprintf("firefox-%s", name),
|
name: fmt.Sprintf("firefox-%s", name),
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
package provider
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"hack-browser-data/internal/browser"
|
||||||
|
"hack-browser-data/internal/log"
|
||||||
|
"hack-browser-data/internal/provider/chromium"
|
||||||
|
"hack-browser-data/internal/provider/firefox"
|
||||||
|
"hack-browser-data/internal/utils/fileutil"
|
||||||
|
"hack-browser-data/internal/utils/typeutil"
|
||||||
|
)
|
||||||
|
|
||||||
|
func PickBrowsers(name, profile string) ([]browser.Browser, error) {
|
||||||
|
var browsers []browser.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.Browser {
|
||||||
|
var browsers []browser.Browser
|
||||||
|
name = strings.ToLower(name)
|
||||||
|
if name == "all" {
|
||||||
|
for _, v := range chromiumList {
|
||||||
|
if !fileutil.FolderExists(filepath.Clean(v.profilePath)) {
|
||||||
|
log.Noticef("find browser %s failed, profile folder does not exist", v.name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if multiChromium, err := chromium.New(v.name, v.storage, v.profilePath, v.items); err == nil {
|
||||||
|
log.Noticef("find browser %s success", v.name)
|
||||||
|
for _, b := range multiChromium {
|
||||||
|
log.Noticef("find browser %s success", b.Name())
|
||||||
|
browsers = append(browsers, b)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Errorf("new chromium error: %s", err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if c, ok := chromiumList[name]; ok {
|
||||||
|
if profile == "" {
|
||||||
|
profile = c.profilePath
|
||||||
|
}
|
||||||
|
if !fileutil.FolderExists(filepath.Clean(profile)) {
|
||||||
|
log.Fatalf("find browser %s failed, profile folder does not exist", c.name)
|
||||||
|
}
|
||||||
|
chromiumList, err := chromium.New(c.name, c.storage, profile, c.items)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("new chromium error: %s", err)
|
||||||
|
}
|
||||||
|
for _, b := range chromiumList {
|
||||||
|
log.Noticef("find browser %s success", b.Name())
|
||||||
|
browsers = append(browsers, b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return browsers
|
||||||
|
}
|
||||||
|
|
||||||
|
func pickFirefox(name, profile string) []browser.Browser {
|
||||||
|
var browsers []browser.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.FolderExists(filepath.Clean(profile)) {
|
||||||
|
log.Noticef("find browser firefox %s failed, profile folder does not exist", v.name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if multiFirefox, err := firefox.New(v.name, v.storage, profile, v.items); err == nil {
|
||||||
|
for _, b := range multiFirefox {
|
||||||
|
log.Noticef("find browser firefox %s success", b.Name())
|
||||||
|
browsers = append(browsers, b)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Error(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
|
||||||
|
}
|
||||||
|
|
||||||
|
// home dir path for all platforms
|
||||||
|
var homeDir, _ = os.UserHomeDir()
|
||||||
|
|
||||||
|
const (
|
||||||
|
chromeName = "Chrome"
|
||||||
|
chromeBetaName = "Chrome Beta"
|
||||||
|
chromiumName = "Chromium"
|
||||||
|
edgeName = "Microsoft Edge"
|
||||||
|
braveName = "Brave"
|
||||||
|
operaName = "Opera"
|
||||||
|
operaGXName = "OperaGX"
|
||||||
|
vivaldiName = "Vivaldi"
|
||||||
|
coccocName = "CocCoc"
|
||||||
|
yandexName = "Yandex"
|
||||||
|
firefoxName = "Firefox"
|
||||||
|
speed360Name = "360speed"
|
||||||
|
qqBrowserName = "QQ"
|
||||||
|
)
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
//go:build darwin
|
//go:build darwin
|
||||||
|
|
||||||
package browser
|
package provider
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"hack-browser-data/internal/item"
|
"hack-browser-data/internal/item"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
//go:build linux
|
//go:build linux
|
||||||
|
|
||||||
package browser
|
package provider
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"hack-browser-data/internal/item"
|
"hack-browser-data/internal/item"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
//go:build windows
|
//go:build windows
|
||||||
|
|
||||||
package browser
|
package provider
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"hack-browser-data/internal/item"
|
"hack-browser-data/internal/item"
|
||||||
Reference in New Issue
Block a user