feat: csv separator replace to comma

pull/83/head
ᴍᴏᴏɴD4ʀᴋ 4 years ago
parent 8e043d0d4c
commit 107e9aaca0
  1. 2
      cmd/cmd.go
  2. 45
      core/output.go
  3. 2
      go.sum

@ -22,7 +22,7 @@ var (
func Execute() {
app := &cli.App{
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",
Version: "0.1.0",
Flags: []cli.Flag{

@ -2,7 +2,6 @@ package core
import (
"bytes"
"encoding/csv"
"encoding/json"
"fmt"
"hack-browser-data/log"
@ -24,15 +23,8 @@ func (b BrowserData) OutPutCsv(dir, browser, format string) error {
log.Errorf("create file %s fail %s", filename, err)
}
file.Write(utf8Bom)
w := csv.NewWriter(file)
w.Comma = ';'
enc := csvutil.NewEncoder(w)
for _, u := range b.BookmarkSlice {
if err := enc.Encode(u); err != nil {
log.Error(err)
}
}
w.Flush()
data, err := csvutil.Marshal(b.BookmarkSlice)
file.Write(data)
fmt.Printf("%s Get %d bookmarks, filename is %s \n", log.Prefix, len(b.BookmarkSlice), filename)
fallthrough
case len(b.LoginDataSlice) != 0:
@ -43,15 +35,8 @@ func (b BrowserData) OutPutCsv(dir, browser, format string) error {
log.Errorf("create file %s fail", filename)
}
file.Write(utf8Bom)
w := csv.NewWriter(file)
w.Comma = ';'
enc := csvutil.NewEncoder(w)
for _, u := range b.LoginDataSlice {
if err := enc.Encode(u); err != nil {
log.Error(err)
}
}
w.Flush()
data, err := csvutil.Marshal(b.LoginDataSlice)
file.Write(data)
fmt.Printf("%s Get %d login data, filename is %s \n", log.Prefix, len(b.LoginDataSlice), filename)
fallthrough
case len(b.CookieMap) != 0:
@ -66,15 +51,8 @@ func (b BrowserData) OutPutCsv(dir, browser, format string) error {
tempSlice = append(tempSlice, v...)
}
file.Write(utf8Bom)
w := csv.NewWriter(file)
w.Comma = ';'
enc := csvutil.NewEncoder(w)
for _, u := range tempSlice {
if err := enc.Encode(u); err != nil {
log.Error(err)
}
}
w.Flush()
data, err := csvutil.Marshal(tempSlice)
file.Write(data)
fmt.Printf("%s Get %d cookies, filename is %s \n", log.Prefix, len(b.CookieMap), filename)
fallthrough
case len(b.HistorySlice) != 0:
@ -85,15 +63,8 @@ func (b BrowserData) OutPutCsv(dir, browser, format string) error {
log.Errorf("create file %s fail", filename)
}
file.Write(utf8Bom)
w := csv.NewWriter(file)
w.Comma = ';'
enc := csvutil.NewEncoder(w)
for _, u := range b.HistorySlice {
if err := enc.Encode(u); err != nil {
log.Error(err)
}
}
w.Flush()
data, err := csvutil.Marshal(b.HistorySlice)
file.Write(data)
fmt.Printf("%s Get %d login data, filename is %s \n", log.Prefix, len(b.HistorySlice), filename)
}
return nil

@ -10,6 +10,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/gocarina/gocsv v0.0.0-20200330101823-46266ca37bd3 h1:B7k6N+JlLM/u1xrIkpifUfE7GRJsZIYHoHbiAa5cSP4=
github.com/gocarina/gocsv v0.0.0-20200330101823-46266ca37bd3/go.mod h1:5YoVOkjYAQumqlV356Hj3xeYh4BdZuLE0/nRkf2NKkI=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/jszwec/csvutil v1.3.0 h1:d0zzXKQYvc22b4La5Wcp97CDgQ7JDLGJLm2NWqJGEYg=
github.com/jszwec/csvutil v1.3.0/go.mod h1:Rpu7Uu9giO9subDyMCIQfHVDuLrcaC36UA4YcJjGBkg=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=

Loading…
Cancel
Save