mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-19 18:58:03 +02:00
refactor code Closes #13
This commit is contained in:
+8
-45
@@ -5,7 +5,6 @@ import (
|
||||
"hack-browser-data/log"
|
||||
"hack-browser-data/utils"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
@@ -27,7 +26,7 @@ func Execute() {
|
||||
Version: "0.1.0",
|
||||
Flags: []cli.Flag{
|
||||
&cli.BoolFlag{Name: "verbose", Aliases: []string{"vv"}, Destination: &verbose, Value: false, Usage: "Verbose"},
|
||||
&cli.StringFlag{Name: "browser", Aliases: []string{"b"}, Destination: &browser, Value: "chrome", Usage: "Available browsers: " + strings.Join(utils.ListBrowser(), "|")},
|
||||
&cli.StringFlag{Name: "browser", Aliases: []string{"b"}, Destination: &browser, Value: "all", Usage: "Available browsers: all|" + strings.Join(core.ListBrowser(), "|")},
|
||||
&cli.StringFlag{Name: "results-dir", Aliases: []string{"dir"}, Destination: &exportDir, Value: "results", Usage: "Export dir"},
|
||||
&cli.StringFlag{Name: "format", Aliases: []string{"f"}, Destination: &outputFormat, Value: "csv", Usage: "Format, csv|json"},
|
||||
&cli.StringFlag{Name: "export-data", Aliases: []string{"e"}, Destination: &exportData, Value: "all", Usage: "all|password|cookie|history|bookmark"},
|
||||
@@ -40,58 +39,22 @@ func Execute() {
|
||||
} else {
|
||||
log.InitLog("error")
|
||||
}
|
||||
browserDir, key, err := utils.PickBrowser(browser)
|
||||
browsers, err := core.PickBrowsers(browser)
|
||||
if err != nil {
|
||||
log.Fatal(err, " Available browsers: "+strings.Join(utils.ListBrowser(), "|"))
|
||||
log.Error(err)
|
||||
}
|
||||
if browser != "firefox" {
|
||||
err = utils.InitKey(key)
|
||||
if err != nil {
|
||||
log.Fatal(err, "Please Open an issue on GitHub")
|
||||
}
|
||||
var fileList []string
|
||||
switch exportData {
|
||||
case "all":
|
||||
fileList = utils.GetDBPath(browserDir, utils.LoginData, utils.History, utils.Bookmarks, utils.Cookies)
|
||||
case "password", "cookie", "history", "bookmark":
|
||||
fileList = utils.GetDBPath(browserDir, exportData)
|
||||
default:
|
||||
log.Fatal("Choose one from all|password|cookie|history|bookmark")
|
||||
}
|
||||
for _, v := range fileList {
|
||||
dst := filepath.Base(v)
|
||||
err := utils.CopyDB(v, dst)
|
||||
if err != nil {
|
||||
log.Debug(err)
|
||||
continue
|
||||
}
|
||||
core.ParseResult(dst)
|
||||
}
|
||||
} else {
|
||||
fileList := utils.GetDBPath(browserDir, utils.FirefoxLoginData, utils.FirefoxKey4DB, utils.FirefoxCookie, utils.FirefoxData)
|
||||
log.Error("fileList", fileList)
|
||||
for _, v := range fileList {
|
||||
dst := filepath.Base(v)
|
||||
err := utils.CopyDB(v, dst)
|
||||
if err != nil {
|
||||
log.Debug(err)
|
||||
continue
|
||||
}
|
||||
core.ParseResult(dst)
|
||||
}
|
||||
}
|
||||
core.FullData.Sorted()
|
||||
utils.MakeDir(exportDir)
|
||||
if outputFormat == "json" {
|
||||
err := core.FullData.OutPutJson(exportDir, browser, outputFormat)
|
||||
for _, v := range browsers {
|
||||
err := v.InitSecretKey()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
} else {
|
||||
err := core.FullData.OutPutCsv(exportDir, browser, outputFormat)
|
||||
err = v.GetProfilePath(exportData)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
v.ParseDB()
|
||||
v.OutPut(exportDir, outputFormat)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user