add bom for csv. Closes #7

ᴍᴏᴏɴD4ʀᴋ 4 years ago
parent e183a81079
commit 1634d2d696
  1. 10
      .github/workflows/release.yml
  2. 73
      README.md
  3. 12
      core/common.go
  4. 54
      core/output.go
  5. 2
      go.mod

@ -75,17 +75,7 @@ jobs:
cp $BINARY .;
zip -r releases/$(basename $RELEASE_DIR).zip \
$(basename ${BINARY}) \
static/js/dist \
static/js/src/vendor/ckeditor \
static/css/dist \
static/images \
static/font \
static/db \
db \
templates \
README.md \
VERSION \
LICENSE \
config.json;
rm $BINARY;
done

@ -1,14 +1,30 @@
# HackBrowserData
一款支持全平台(Windows | MacOS | Linux)的浏览器数据(Password | History | Bookmark | Cookie)导出工具
hack-browser-data is an open-source tool that could help you export data from browser. It supports the most popular browsers on the market and runs on W indows and macOS.
### Supported Browser
### 安装编译
你可以选择下载编译好的[二进制文件](https://github.com/moonD4rk/HackBrowserData/releases)
也可以通过源码手动编译
| Browser | Password | Cookie | Bookmark | History |
| :---------------------------------- | :------: | :----: | :------: | :-----: |
| Chrome <= 80 [Windows] | ✅ | ✅ | ✅ | ✅ |
| Chrome > 80 [Windows] | ✅ | ✅ | ✅ | ✅ |
| Chrome [MacOS]<br />(require password) | ✅ | ✅ | ✅ | ✅ |
| Edge [Windows] | ✅ | ✅ | ✅ | ✅ |
| Edge [MacOS]<br />(require password) | ✅ | ✅ | ✅ | ✅ |
| 360 Speed Browser [Windows] | ✅ | ✅ | ✅ | ✅ |
| QQ Browser [Windows] | ✅ | ✅ | ✅ | ✅ |
| FireFox [Windows] | ❌ | ❌ | ❌ | ❌ |
| FireFox [MacOS] | ❌ | ❌ | ❌ | ❌ |
| Safari [MacOS] | ❌ | ❌ | ❌ | ❌ |
| Internet Explorer [Windows] | ❌ | ❌ | ❌ | ❌ |
| 360 Secure Browser [Windows] | ❌ | ❌ | ❌ | ❌ |
| Chrome [Linux] | ❌ | ❌ | ❌ | ❌ |
### Install
Installation of hack-browser-data is dead-simple, just download [the release for your system](https://github.com/moonD4rk/HackBrowserData/releases) and run the binary.
#### Building from source
```bash
git clone https://github.com/moonD4rk/HackBrowserData
@ -18,12 +34,12 @@ cd HackBrowserData && go mod tidy
go build
```
### 运行
#### Run
```shell
./hack-browser-data -h
✗ .\hack-browser-data.exe -h
NAME:
hack-browser-data - Get passwords/cookies/history/bookmarks from browser
hack-browser-data - Export passwords/cookies/history/bookmarks from browser
USAGE:
[hack-browser-data -b chrome -f json -dir results -e all]
@ -31,44 +47,27 @@ USAGE:
GLOBAL OPTIONS:
--verbose, --vv verbose (default: false)
--browser value, -b value available browsers: edge|chrome (default: "chrome")
--results-dir value, --dir value export dir (default: "results")
--browser value, -b value available browsers: chrome|edge|360speed|qq (default: "chrome")
--results-dir value, --dir value Export dir (default: "results")
--format value, -f value result format, csv|json (default: "csv")
--export-data value, -e value all|password|cookie|history|bookmark (default: "all")
--help, -h show help (default: false)
```
```shell
✗ ./hack-browser-data -b chrome -f json -dir results -e all
✗ ./hack-browser-data.exe -b chrome -f json -dir results -e all
[x]: Get 538 bookmarks, filename is results/bookmarks_chrome.json
[x]: Get 1415 cookies, filename is results/cookies_chrome.json
[x]: Get 34050 history, filename is results/history_chrome.json
[x]: Get 357 login data, filename is results/login_data_chrome.json
[x]: Get 1610 cookies, filename is results/cookies_chrome.json
[x]: Get 44050 history, filename is results/history_chrome.json
[x]: Get 457 login data, filename is results/login_data_chrome.json
```
### 目前支持平台
| Browser | Password | Cookie | Bookmark | History |
| :---------------------------------- | :------: | :----: | :------: | :-----: |
| Chrome version <= 80 [Windows] | ✔ | ✔ | ✔ | ✔ |
| Chrome version > 80 [Windows] | ✔ | ✔ | ✔ | ✔ |
| Chrome [MacOS]<br />(require password) | ✔ | ✔ | ✔ | ✔ |
| Edge [Windows] | ✔ | ✔ | ✔ | ✔ |
| Edge [MacOS]<br />(require password) | ✔ | ✔ | ✔ | ✔ |
| 360 Speed Browser [Windows] | ✔ | ✔ | ✔ | ✔ |
| QQ Browser [Windows] | ✔ | ✔ | ✔ | ✔ |
| FireFox [Windows] | ✖ | ✖ | ✖ | ✖ |
| FireFox [MacOS] | ✖ | ✖ | ✖ | ✖ |
| Safari [MacOS] | ✖ | ✖ | ✖ | ✖ |
| Internet Explorer [Windows] | ✖ | ✖ | ✖ | ✖ |
| 360 Secure Browser [Windows] | ✖ | ✖ | ✖ | ✖ |
| Chrome [Linux] | ✖ | ✖ | ✖ | ✖ |
### Todo List
### TODO
[Desktop Browser Market Share Worldwide](https://gs.statcounter.com/browser-market-share/desktop/worldwide)
@ -82,7 +81,7 @@ GLOBAL OPTIONS:
| :----- | :------: | :-----: | :--------: | :---: | :------------: |
| 39.85% | 22.26% | 9.28% | 6.5% | 5.65% | 4.74% |
Based on those two lists, I would support those browsers in the future
- [x] Chrome
- [x] QQ browser

@ -22,13 +22,11 @@ const (
)
var (
FullDataSlice []*BrowserData
FullData = new(BrowserData)
)
type (
BrowserData struct {
BrowserName string
LoginDataSlice
BookmarkSlice
CookieMap
@ -47,17 +45,17 @@ type (
}
bookmarks struct {
ID int64
DateAdded time.Time
URL string
Name string
Type string
URL string
DateAdded time.Time
}
cookies struct {
Host string
Path string
KeyName string
encryptValue []byte
Value string
Host string
Path string
IsSecure bool
IsHTTPOnly bool
HasExpire bool
@ -66,8 +64,8 @@ type (
ExpireDate time.Time
}
history struct {
Url string
Title string
Url string
VisitCount int
LastVisitTime time.Time
}

@ -7,12 +7,13 @@ import (
"fmt"
"hack-browser-data/log"
"hack-browser-data/utils"
"io"
"os"
"github.com/gocarina/gocsv"
"github.com/jszwec/csvutil"
)
var utf8Bom = []byte{239, 187, 191}
func (b BrowserData) OutPutCsv(dir, browser, format string) error {
switch {
case len(b.BookmarkSlice) != 0:
@ -20,17 +21,18 @@ func (b BrowserData) OutPutCsv(dir, browser, format string) error {
file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0644)
defer file.Close()
if err != nil {
log.Errorf("create file %s fail", filename)
}
gocsv.SetCSVWriter(func(out io.Writer) *gocsv.SafeCSVWriter {
writer := csv.NewWriter(out)
writer.Comma = ' '
return gocsv.NewSafeCSVWriter(writer)
})
err = gocsv.MarshalFile(b.BookmarkSlice, file)
if err != nil {
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()
fmt.Printf("%s Get %d bookmarks, filename is %s \n", log.Prefix, len(b.BookmarkSlice), filename)
fallthrough
case len(b.LoginDataSlice) != 0:
@ -40,10 +42,16 @@ func (b BrowserData) OutPutCsv(dir, browser, format string) error {
if err != nil {
log.Errorf("create file %s fail", filename)
}
err = gocsv.MarshalFile(b.LoginDataSlice, file)
if err != nil {
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()
fmt.Printf("%s Get %d login data, filename is %s \n", log.Prefix, len(b.LoginDataSlice), filename)
fallthrough
case len(b.CookieMap) != 0:
@ -57,10 +65,16 @@ func (b BrowserData) OutPutCsv(dir, browser, format string) error {
for _, v := range b.CookieMap {
tempSlice = append(tempSlice, v...)
}
err = gocsv.MarshalFile(tempSlice, file)
if err != nil {
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()
fmt.Printf("%s Get %d cookies, filename is %s \n", log.Prefix, len(b.CookieMap), filename)
fallthrough
case len(b.HistorySlice) != 0:
@ -70,10 +84,16 @@ func (b BrowserData) OutPutCsv(dir, browser, format string) error {
if err != nil {
log.Errorf("create file %s fail", filename)
}
err = gocsv.MarshalFile(b.HistorySlice, file)
if err != nil {
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()
fmt.Printf("%s Get %d login data, filename is %s \n", log.Prefix, len(b.HistorySlice), filename)
}
return nil

@ -3,7 +3,7 @@ module hack-browser-data
go 1.14
require (
github.com/gocarina/gocsv v0.0.0-20200330101823-46266ca37bd3
github.com/jszwec/csvutil v1.3.0
github.com/mattn/go-sqlite3 v1.14.0
github.com/tidwall/gjson v1.6.0
github.com/urfave/cli/v2 v2.2.0

Loading…
Cancel
Save