From 83102c042ec0180a37ac476845115a1c853dd017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=8D=E1=B4=8F=E1=B4=8F=C9=B4D4=CA=80=E1=B4=8B?= Date: Tue, 12 Apr 2022 11:29:01 +0800 Subject: [PATCH] feat: add log --- internal/browingdata/bookmark.go | 4 ++-- internal/browingdata/browsingdata.go | 3 ++- internal/browingdata/cookie.go | 14 +++++--------- internal/browingdata/creditcard.go | 4 ++-- internal/browingdata/download.go | 3 ++- internal/browingdata/history.go | 6 +++--- internal/browingdata/password.go | 12 ++++-------- 7 files changed, 20 insertions(+), 26 deletions(-) diff --git a/internal/browingdata/bookmark.go b/internal/browingdata/bookmark.go index 2fe2a95..94afb7f 100644 --- a/internal/browingdata/bookmark.go +++ b/internal/browingdata/bookmark.go @@ -2,7 +2,6 @@ package browingdata import ( "database/sql" - "fmt" "os" "sort" "time" @@ -10,6 +9,7 @@ import ( "github.com/tidwall/gjson" "hack-browser-data/internal/item" + "hack-browser-data/internal/log" "hack-browser-data/internal/utils" "hack-browser-data/internal/utils/fileutil" @@ -107,7 +107,7 @@ func (f *FirefoxBookmark) Parse(masterKey []byte) error { title, url string ) if err = bookmarkRows.Scan(&id, &url, &bType, &dateAdded, &title); err != nil { - fmt.Println(err) + log.Warn(err) } *f = append(*f, bookmark{ ID: id, diff --git a/internal/browingdata/browsingdata.go b/internal/browingdata/browsingdata.go index 7b2a9d1..6c14dea 100644 --- a/internal/browingdata/browsingdata.go +++ b/internal/browingdata/browsingdata.go @@ -4,6 +4,7 @@ import ( "time" "hack-browser-data/internal/item" + "hack-browser-data/internal/log" ) type Data struct { @@ -28,7 +29,7 @@ func (d *Data) Recovery(masterKey []byte) error { for _, source := range d.Sources { if err := source.Parse(masterKey); err != nil { - panic(err) + log.Error(err) } } return nil diff --git a/internal/browingdata/cookie.go b/internal/browingdata/cookie.go index 96f04e5..082382f 100644 --- a/internal/browingdata/cookie.go +++ b/internal/browingdata/cookie.go @@ -2,7 +2,6 @@ package browingdata import ( "database/sql" - "fmt" "os" "sort" @@ -10,6 +9,7 @@ import ( "hack-browser-data/internal/decrypter" "hack-browser-data/internal/item" + "hack-browser-data/internal/log" "hack-browser-data/internal/utils" ) @@ -35,7 +35,7 @@ func (c *ChromiumCookie) Parse(masterKey []byte) error { value, encryptValue []byte ) if err = rows.Scan(&key, &encryptValue, &host, &path, &createDate, &expireDate, &isSecure, &isHTTPOnly, &hasExpire, &isPersistent); err != nil { - fmt.Println(err) + log.Warn(err) } cookie := cookie{ @@ -52,17 +52,13 @@ func (c *ChromiumCookie) Parse(masterKey []byte) error { } // TODO: replace DPAPI if len(encryptValue) > 0 { + var err error if masterKey == nil { value, err = decrypter.DPApi(encryptValue) - if err != nil { - fmt.Println(err) - } } else { value, err = decrypter.ChromePass(masterKey, encryptValue) - if err != nil { - fmt.Println(err) - } } + log.Error(err) } cookie.Value = string(value) *c = append(*c, cookie) @@ -98,7 +94,7 @@ func (f *FirefoxCookie) Parse(masterKey []byte) error { creationTime, expiry int64 ) if err = rows.Scan(&name, &value, &host, &path, &creationTime, &expiry, &isSecure, &isHttpOnly); err != nil { - fmt.Println(err) + log.Warn(err) } *f = append(*f, cookie{ KeyName: name, diff --git a/internal/browingdata/creditcard.go b/internal/browingdata/creditcard.go index 4c0c9b8..bd89c8d 100644 --- a/internal/browingdata/creditcard.go +++ b/internal/browingdata/creditcard.go @@ -2,13 +2,13 @@ package browingdata import ( "database/sql" - "fmt" "os" _ "github.com/mattn/go-sqlite3" "hack-browser-data/internal/decrypter" "hack-browser-data/internal/item" + "hack-browser-data/internal/log" ) type ChromiumCreditCard []card @@ -31,7 +31,7 @@ func (c *ChromiumCreditCard) Parse(masterKey []byte) error { value, encryptValue []byte ) if err := rows.Scan(&guid, &name, &month, &year, &encryptValue); err != nil { - fmt.Println(err) + log.Warn(err) } creditCardInfo := card{ GUID: guid, diff --git a/internal/browingdata/download.go b/internal/browingdata/download.go index 50ab81b..d9294d9 100644 --- a/internal/browingdata/download.go +++ b/internal/browingdata/download.go @@ -8,6 +8,7 @@ import ( "strings" "hack-browser-data/internal/item" + "hack-browser-data/internal/log" "hack-browser-data/internal/utils" _ "github.com/mattn/go-sqlite3" @@ -86,7 +87,7 @@ func (f *FirefoxDownload) Parse(masterKey []byte) error { placeID, dateAdded int64 ) if err = downloadRows.Scan(&placeID, &content, &url, &dateAdded); err != nil { - fmt.Println(err) + log.Warn(err) } contentList := strings.Split(content, ",{") if len(contentList) > 1 { diff --git a/internal/browingdata/history.go b/internal/browingdata/history.go index e6f3bb8..e9dfdab 100644 --- a/internal/browingdata/history.go +++ b/internal/browingdata/history.go @@ -2,13 +2,13 @@ package browingdata import ( "database/sql" - "fmt" "os" "sort" _ "github.com/mattn/go-sqlite3" "hack-browser-data/internal/item" + "hack-browser-data/internal/log" "hack-browser-data/internal/utils" ) @@ -34,7 +34,7 @@ func (c *ChromiumHistory) Parse(masterKey []byte) error { ) // TODO: handle rows error if err := rows.Scan(&url, &title, &visitCount, &lastVisitTime); err != nil { - fmt.Println(err) + log.Warn(err) } data := history{ Url: url, @@ -85,7 +85,7 @@ func (f *FirefoxHistory) Parse(masterKey []byte) error { visitCount int ) if err = historyRows.Scan(&id, &url, &visitDate, &title, &visitCount); err != nil { - fmt.Println(err) + log.Warn(err) } *f = append(*f, history{ Title: title, diff --git a/internal/browingdata/password.go b/internal/browingdata/password.go index 51bbb45..79b5577 100644 --- a/internal/browingdata/password.go +++ b/internal/browingdata/password.go @@ -4,7 +4,6 @@ import ( "bytes" "database/sql" "encoding/base64" - "fmt" "io/ioutil" "os" "sort" @@ -15,6 +14,7 @@ import ( "hack-browser-data/internal/decrypter" "hack-browser-data/internal/item" + "hack-browser-data/internal/log" "hack-browser-data/internal/utils" ) @@ -40,7 +40,7 @@ func (c *ChromiumPassword) Parse(masterKey []byte) error { create int64 ) if err := rows.Scan(&url, &username, &pwd, &create); err != nil { - fmt.Println(err) + log.Warn(err) } login := loginData{ UserName: username, @@ -48,17 +48,13 @@ func (c *ChromiumPassword) Parse(masterKey []byte) error { LoginUrl: url, } if len(pwd) > 0 { + var err error if masterKey == nil { password, err = decrypter.DPApi(pwd) - if err != nil { - fmt.Println(err) - } } else { password, err = decrypter.ChromePass(masterKey, pwd) - if err != nil { - fmt.Println(err) - } } + log.Error(err) } if create > time.Now().Unix() { login.CreateDate = utils.TimeEpochFormat(create)