Skip to content

Commit 0f0db46

Browse files
authored
fix: filter result if item is empty and add utf8 encoder to csv
Merge pull request #144 from moonD4rk/fix/bug
2 parents 645e260 + 6de08b6 commit 0f0db46

File tree

14 files changed

+93
-14
lines changed

14 files changed

+93
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ USAGE:
134134
Github Link: https://github.com/moonD4rk/HackBrowserData
135135
136136
VERSION:
137-
0.4.2
137+
0.4.3
138138
139139
GLOBAL OPTIONS:
140140
--verbose, --vv verbose (default: false)

README_ZH.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ USAGE:
129129
Github Link: https://github.com/moonD4rk/HackBrowserData
130130
131131
VERSION:
132-
0.4.2
132+
0.4.3
133133
134134
GLOBAL OPTIONS:
135135
--verbose, --vv verbose (default: false)

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ require (
1616
github.com/urfave/cli/v2 v2.4.0
1717
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3
1818
golang.org/x/exp v0.0.0-20220414153411-bcd21879b8fd
19+
golang.org/x/text v0.3.6
1920
)
2021

2122
require (

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBc
9090
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
9191
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
9292
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
93+
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
94+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
9395
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
9496
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
9597
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=

internal/browingdata/bookmark/bookmark.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,23 @@ func getBookmarkChildren(value gjson.Result, w *ChromiumBookmark) (children gjso
7676
return children
7777
}
7878

79+
func bookmarkType(a int64) string {
80+
switch a {
81+
case 1:
82+
return "url"
83+
default:
84+
return "folder"
85+
}
86+
}
87+
7988
func (c *ChromiumBookmark) Name() string {
8089
return "bookmark"
8190
}
8291

92+
func (c *ChromiumBookmark) Length() int {
93+
return len(*c)
94+
}
95+
8396
type FirefoxBookmark []bookmark
8497

8598
const (
@@ -134,11 +147,6 @@ func (f *FirefoxBookmark) Name() string {
134147
return "bookmark"
135148
}
136149

137-
func bookmarkType(a int64) string {
138-
switch a {
139-
case 1:
140-
return "url"
141-
default:
142-
return "folder"
143-
}
150+
func (f *FirefoxBookmark) Length() int {
151+
return len(*f)
144152
}

internal/browingdata/browsingdata.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ type Source interface {
2424
Parse(masterKey []byte) error
2525

2626
Name() string
27+
28+
Length() int
2729
}
2830

2931
func New(sources []item.Item) *Data {
@@ -47,6 +49,10 @@ func (d *Data) Output(dir, browserName, flag string) {
4749
output := NewOutPutter(flag)
4850

4951
for _, source := range d.sources {
52+
if source.Length() == 0 {
53+
// if the length of the export data is 0, then it is not necessary to output
54+
continue
55+
}
5056
filename := fileutil.Filename(browserName, source.Name(), output.Ext())
5157

5258
f, err := output.CreateFile(dir, filename)

internal/browingdata/cookie/cookie.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ func (c *ChromiumCookie) Name() string {
9393
return "cookie"
9494
}
9595

96+
func (c *ChromiumCookie) Length() int {
97+
return len(*c)
98+
}
99+
96100
type FirefoxCookie []cookie
97101

98102
const (
@@ -137,3 +141,7 @@ func (f *FirefoxCookie) Parse(masterKey []byte) error {
137141
func (f *FirefoxCookie) Name() string {
138142
return "cookie"
139143
}
144+
145+
func (f *FirefoxCookie) Length() int {
146+
return len(*f)
147+
}

internal/browingdata/creditcard/creditcard.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ func (c *ChromiumCreditCard) Name() string {
7676
return "creditcard"
7777
}
7878

79+
func (c *ChromiumCreditCard) Length() int {
80+
return len(*c)
81+
}
82+
7983
type YandexCreditCard []card
8084

8185
func (c *YandexCreditCard) Parse(masterKey []byte) error {
@@ -127,3 +131,7 @@ func (c *YandexCreditCard) Parse(masterKey []byte) error {
127131
func (c *YandexCreditCard) Name() string {
128132
return "creditcard"
129133
}
134+
135+
func (c *YandexCreditCard) Length() int {
136+
return len(*c)
137+
}

internal/browingdata/download/download.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ func (c *ChromiumDownload) Name() string {
7070
return "download"
7171
}
7272

73+
func (c *ChromiumDownload) Length() int {
74+
return len(*c)
75+
}
76+
7377
type FirefoxDownload []download
7478

7579
const (
@@ -131,3 +135,7 @@ func (f *FirefoxDownload) Parse(masterKey []byte) error {
131135
func (f *FirefoxDownload) Name() string {
132136
return "download"
133137
}
138+
139+
func (f *FirefoxDownload) Length() int {
140+
return len(*f)
141+
}

internal/browingdata/extension/extension.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ func (c *ChromiumExtension) Name() string {
5050
return "extension"
5151
}
5252

53+
func (c *ChromiumExtension) Length() int {
54+
return len(*c)
55+
}
56+
5357
type FirefoxExtension []*extension
5458

5559
func (f *FirefoxExtension) Parse(masterKey []byte) error {
@@ -73,3 +77,7 @@ func (f *FirefoxExtension) Parse(masterKey []byte) error {
7377
func (f *FirefoxExtension) Name() string {
7478
return "extension"
7579
}
80+
81+
func (f *FirefoxExtension) Length() int {
82+
return len(*f)
83+
}

0 commit comments

Comments
 (0)