add output to console Close #14

v0.2.0
ᴍᴏᴏɴD4ʀᴋ 4 years ago
parent 4869454a78
commit 2c0eca9d40
  1. 7
      README.md
  2. 8
      README_ZH.md
  3. 4
      cmd/cmd.go
  4. 24
      core/common/output.go
  5. 40
      core/common/parse.go

@ -66,11 +66,10 @@ USAGE:
GLOBAL OPTIONS: GLOBAL OPTIONS:
--verbose, --vv Verbose (default: false) --verbose, --vv Verbose (default: false)
--browser value, -b value Available browsers: all|chrome|edge|360|qq|firefox (default: "all") --browser value, -b value Available browsers: all|chrome|edge|firefox (default: "all")
--results-dir value, --dir value Export dir (default: "results") --results-dir value, --dir value Export dir (default: "results")
--format value, -f value Format, csv|json (default: "csv") --format value, -f value Format, csv|json|console (default: "json")
--export-data value, -e value all|bookmark|cookie|history|password (default: "all") --export-data value, -e value all|cookie|history|password|bookmark (default: "all")
--help, -h show help (default: false)
PS C:\test> .\hack-browser-data.exe -b all -f json -e all --dir results PS C:\test> .\hack-browser-data.exe -b all -f json -e all --dir results

@ -67,11 +67,11 @@ USAGE:
GLOBAL OPTIONS: GLOBAL OPTIONS:
--verbose, --vv Verbose (default: false) --verbose, --vv Verbose (default: false)
--browser value, -b value Available browsers: all|chrome|edge|360|qq|firefox (default: "all") --browser value, -b value Available browsers: all|chrome|edge|firefox (default: "all")
--results-dir value, --dir value Export dir (default: "results") --results-dir value, --dir value Export dir (default: "results")
--format value, -f value Format, csv|json (default: "csv") --format value, -f value Format, csv|json|console (default: "json")
--export-data value, -e value all|bookmark|cookie|history|password (default: "all") --export-data value, -e value all|cookie|history|password|bookmark (default: "all")
--help, -h show help (default: false)
PS C:\test> .\hack-browser-data.exe -b all -f json -e all --dir results PS C:\test> .\hack-browser-data.exe -b all -f json -e all --dir results

@ -23,12 +23,12 @@ 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 -e all]\n Get all data(password/cookie/history/bookmark) from chrome", UsageText: "[hack-browser-data -b chrome -f json -dir results -e all]\n Get all data(password/cookie/history/bookmark) from chrome",
Version: "0.1.9", Version: "0.2.0",
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.StringFlag{Name: "browser", Aliases: []string{"b"}, Destination: &browser, Value: "all", Usage: "Available browsers: all|" + strings.Join(core.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: "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: "format", Aliases: []string{"f"}, Destination: &outputFormat, Value: "json", Usage: "Format, csv|json|console"},
&cli.StringFlag{Name: "export-data", Aliases: []string{"e"}, Destination: &exportData, Value: "all", Usage: "all|" + strings.Join(core.ListItem(), "|")}, &cli.StringFlag{Name: "export-data", Aliases: []string{"e"}, Destination: &exportData, Value: "all", Usage: "all|" + strings.Join(core.ListItem(), "|")},
}, },
HideHelpCommand: true, HideHelpCommand: true,

@ -145,3 +145,27 @@ func writeToCsv(filename string, data interface{}) error {
} }
return nil return nil
} }
func (b *bookmarks) outPutConsole() {
for _, v := range b.bookmarks {
fmt.Printf("%+v\n", v)
}
}
func (c *cookies) outPutConsole() {
for host, value := range c.cookies {
fmt.Printf("%s\n%+v\n", host, value)
}
}
func (h *historyData) outPutConsole() {
for _, v := range h.history {
fmt.Printf("%+v\n", v)
}
}
func (p *passwords) outPutConsole() {
for _, v := range p.logins {
fmt.Printf("%+v\n", v)
}
}

@ -156,14 +156,16 @@ func (b *bookmarks) OutPut(format, browser, dir string) error {
return b.bookmarks[i].ID < b.bookmarks[j].ID return b.bookmarks[i].ID < b.bookmarks[j].ID
}) })
switch format { switch format {
case "json":
err := b.outPutJson(browser, dir)
return err
case "csv": case "csv":
err := b.outPutCsv(browser, dir) err := b.outPutCsv(browser, dir)
return err return err
} case "console":
b.outPutConsole()
return nil return nil
default:
err := b.outPutJson(browser, dir)
return err
}
} }
type cookies struct { type cookies struct {
@ -279,14 +281,16 @@ func (c *cookies) Release() error {
func (c *cookies) OutPut(format, browser, dir string) error { func (c *cookies) OutPut(format, browser, dir string) error {
switch format { switch format {
case "json":
err := c.outPutJson(browser, dir)
return err
case "csv": case "csv":
err := c.outPutCsv(browser, dir) err := c.outPutCsv(browser, dir)
return err return err
} case "console":
c.outPutConsole()
return nil return nil
default:
err := c.outPutJson(browser, dir)
return err
}
} }
type historyData struct { type historyData struct {
@ -400,14 +404,16 @@ func (h *historyData) OutPut(format, browser, dir string) error {
return h.history[i].VisitCount > h.history[j].VisitCount return h.history[i].VisitCount > h.history[j].VisitCount
}) })
switch format { switch format {
case "json":
err := h.outPutJson(browser, dir)
return err
case "csv": case "csv":
err := h.outPutCsv(browser, dir) err := h.outPutCsv(browser, dir)
return err return err
} case "console":
h.outPutConsole()
return nil return nil
default:
err := h.outPutJson(browser, dir)
return err
}
} }
type passwords struct { type passwords struct {
@ -566,14 +572,16 @@ func (p *passwords) Release() error {
func (p *passwords) OutPut(format, browser, dir string) error { func (p *passwords) OutPut(format, browser, dir string) error {
sort.Sort(p) sort.Sort(p)
switch format { switch format {
case "json":
err := p.outPutJson(browser, dir)
return err
case "csv": case "csv":
err := p.outPutCsv(browser, dir) err := p.outPutCsv(browser, dir)
return err return err
} case "console":
p.outPutConsole()
return nil return nil
default:
err := p.outPutJson(browser, dir)
return err
}
} }
func getDecryptKey() (item1, item2, a11, a102 []byte, err error) { func getDecryptKey() (item1, item2, a11, a102 []byte, err error) {

Loading…
Cancel
Save