Skip to content

Commit

Permalink
add output to console Close #14
Browse files Browse the repository at this point in the history
  • Loading branch information
moonD4rk committed Aug 1, 2020
1 parent 4869454 commit 2c0eca9
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 26 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ USAGE:

GLOBAL OPTIONS:
--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")
--format value, -f value Format, csv|json (default: "csv")
--export-data value, -e value all|bookmark|cookie|history|password (default: "all")
--help, -h show help (default: false)
--format value, -f value Format, csv|json|console (default: "json")
--export-data value, -e value all|cookie|history|password|bookmark (default: "all")


PS C:\test> .\hack-browser-data.exe -b all -f json -e all --dir results
Expand Down
8 changes: 4 additions & 4 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ USAGE:

GLOBAL OPTIONS:
--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")
--format value, -f value Format, csv|json (default: "csv")
--export-data value, -e value all|bookmark|cookie|history|password (default: "all")
--help, -h show help (default: false)
--format value, -f value Format, csv|json|console (default: "json")
--export-data value, -e value all|cookie|history|password|bookmark (default: "all")



PS C:\test> .\hack-browser-data.exe -b all -f json -e all --dir results
Expand Down
4 changes: 2 additions & 2 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ func Execute() {
Name: "hack-browser-data",
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",
Version: "0.1.9",
Version: "0.2.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: "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: "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(), "|")},
},
HideHelpCommand: true,
Expand Down
24 changes: 24 additions & 0 deletions core/common/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,27 @@ func writeToCsv(filename string, data interface{}) error {
}
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)
}
}
40 changes: 24 additions & 16 deletions core/common/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,16 @@ func (b *bookmarks) OutPut(format, browser, dir string) error {
return b.bookmarks[i].ID < b.bookmarks[j].ID
})
switch format {
case "json":
err := b.outPutJson(browser, dir)
return err
case "csv":
err := b.outPutCsv(browser, dir)
return err
case "console":
b.outPutConsole()
return nil
default:
err := b.outPutJson(browser, dir)
return err
}
return nil
}

type cookies struct {
Expand Down Expand Up @@ -279,14 +281,16 @@ func (c *cookies) Release() error {

func (c *cookies) OutPut(format, browser, dir string) error {
switch format {
case "json":
err := c.outPutJson(browser, dir)
return err
case "csv":
err := c.outPutCsv(browser, dir)
return err
case "console":
c.outPutConsole()
return nil
default:
err := c.outPutJson(browser, dir)
return err
}
return nil
}

type historyData struct {
Expand Down Expand Up @@ -400,14 +404,16 @@ func (h *historyData) OutPut(format, browser, dir string) error {
return h.history[i].VisitCount > h.history[j].VisitCount
})
switch format {
case "json":
err := h.outPutJson(browser, dir)
return err
case "csv":
err := h.outPutCsv(browser, dir)
return err
case "console":
h.outPutConsole()
return nil
default:
err := h.outPutJson(browser, dir)
return err
}
return nil
}

type passwords struct {
Expand Down Expand Up @@ -566,14 +572,16 @@ func (p *passwords) Release() error {
func (p *passwords) OutPut(format, browser, dir string) error {
sort.Sort(p)
switch format {
case "json":
err := p.outPutJson(browser, dir)
return err
case "csv":
err := p.outPutCsv(browser, dir)
return err
case "console":
p.outPutConsole()
return nil
default:
err := p.outPutJson(browser, dir)
return err
}
return nil
}

func getDecryptKey() (item1, item2, a11, a102 []byte, err error) {
Expand Down

0 comments on commit 2c0eca9

Please sign in to comment.