feat: support custom browser profile path

This commit is contained in:
moond4rk
2020-12-20 15:18:19 +08:00
committed by ᴍᴏᴏɴD4ʀᴋ
parent 138c33dade
commit 3fa262f66c
3 changed files with 111 additions and 21 deletions
+30 -15
View File
@@ -11,11 +11,13 @@ import (
)
var (
browser string
exportDir string
outputFormat string
verbose bool
compress bool
browserName string
exportDir string
outputFormat string
verbose bool
compress bool
customProfilePath string
customKeyPath string
)
func Execute() {
@@ -23,25 +25,38 @@ func Execute() {
Name: "hack-browser-data",
Usage: "Export passwords/cookies/history/bookmarks from browser",
UsageText: "[hack-browser-data -b chrome -f json -dir results -cc]\n Get all data(password/cookie/history/bookmark) from chrome",
Version: "0.3.0",
Version: "0.3.1",
Flags: []cli.Flag{
&cli.BoolFlag{Name: "verbose", Aliases: []string{"vv"}, Destination: &verbose, Value: false, Usage: "Verbose"},
&cli.BoolFlag{Name: "compress", Aliases: []string{"cc"}, Destination: &compress, Value: false, Usage: "Compress result to zip"},
&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|console"},
&cli.BoolFlag{Name: "verbose", Aliases: []string{"vv"}, Destination: &verbose, Value: false, Usage: "verbose"},
&cli.BoolFlag{Name: "compress", Aliases: []string{"cc"}, 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(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|console"},
&cli.StringFlag{Name: "profile-dir-path", Aliases: []string{"p"}, Destination: &customProfilePath, Value: "", Usage: "custom profile dir path, get with chrome://version"},
&cli.StringFlag{Name: "key-file-path", Aliases: []string{"k"}, Destination: &customKeyPath, Value: "", Usage: "custom key file path"},
},
HideHelpCommand: true,
Action: func(c *cli.Context) error {
var (
browsers []core.Browser
err error
)
if verbose {
log.InitLog("debug")
} else {
log.InitLog("error")
}
// default select all browsers
browsers, err := core.PickBrowser(browser)
if err != nil {
log.Error(err)
if customProfilePath != "" {
browsers, err = core.PickCustomBrowser(browserName, customProfilePath, customKeyPath)
if err != nil {
log.Error(err)
}
} else {
// default select all browsers
browsers, err = core.PickBrowser(browserName)
if err != nil {
log.Error(err)
}
}
err = utils.MakeDir(exportDir)
if err != nil {