mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-19 18:58:03 +02:00
refactor: replace util with go generics
This commit is contained in:
@@ -10,8 +10,8 @@ import (
|
||||
|
||||
"hack-browser-data/internal/item"
|
||||
"hack-browser-data/internal/log"
|
||||
"hack-browser-data/internal/utils"
|
||||
"hack-browser-data/internal/utils/fileutil"
|
||||
"hack-browser-data/internal/utils/typeutil"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
@@ -61,7 +61,7 @@ func getBookmarkChildren(value gjson.Result, w *ChromiumBookmark) (children gjso
|
||||
ID: value.Get(bookmarkID).Int(),
|
||||
Name: value.Get(bookmarkName).String(),
|
||||
URL: value.Get(bookmarkUrl).String(),
|
||||
DateAdded: utils.TimeEpochFormat(value.Get(bookmarkAdded).Int()),
|
||||
DateAdded: typeutil.TimeEpoch(value.Get(bookmarkAdded).Int()),
|
||||
}
|
||||
children = value.Get(bookmarkChildren)
|
||||
if nodeType.Exists() {
|
||||
@@ -114,9 +114,9 @@ func (f *FirefoxBookmark) Parse(masterKey []byte) error {
|
||||
*f = append(*f, bookmark{
|
||||
ID: id,
|
||||
Name: title,
|
||||
Type: utils.BookmarkType(bType),
|
||||
Type: bookmarkType(bType),
|
||||
URL: url,
|
||||
DateAdded: utils.TimeStampFormat(dateAdded / 1000000),
|
||||
DateAdded: typeutil.TimeStamp(dateAdded / 1000000),
|
||||
})
|
||||
}
|
||||
sort.Slice(*f, func(i, j int) bool {
|
||||
@@ -128,3 +128,12 @@ func (f *FirefoxBookmark) Parse(masterKey []byte) error {
|
||||
func (f *FirefoxBookmark) Name() string {
|
||||
return "bookmark"
|
||||
}
|
||||
|
||||
func bookmarkType(a int64) string {
|
||||
switch a {
|
||||
case 1:
|
||||
return "url"
|
||||
default:
|
||||
return "folder"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"hack-browser-data/internal/decrypter"
|
||||
"hack-browser-data/internal/item"
|
||||
"hack-browser-data/internal/log"
|
||||
"hack-browser-data/internal/utils"
|
||||
"hack-browser-data/internal/utils/typeutil"
|
||||
)
|
||||
|
||||
type ChromiumCookie []cookie
|
||||
@@ -43,12 +43,12 @@ func (c *ChromiumCookie) Parse(masterKey []byte) error {
|
||||
Host: host,
|
||||
Path: path,
|
||||
encryptValue: encryptValue,
|
||||
IsSecure: utils.IntToBool(isSecure),
|
||||
IsHTTPOnly: utils.IntToBool(isHTTPOnly),
|
||||
HasExpire: utils.IntToBool(hasExpire),
|
||||
IsPersistent: utils.IntToBool(isPersistent),
|
||||
CreateDate: utils.TimeEpochFormat(createDate),
|
||||
ExpireDate: utils.TimeEpochFormat(expireDate),
|
||||
IsSecure: typeutil.IntToBool(isSecure),
|
||||
IsHTTPOnly: typeutil.IntToBool(isHTTPOnly),
|
||||
HasExpire: typeutil.IntToBool(hasExpire),
|
||||
IsPersistent: typeutil.IntToBool(isPersistent),
|
||||
CreateDate: typeutil.TimeEpoch(createDate),
|
||||
ExpireDate: typeutil.TimeEpoch(expireDate),
|
||||
}
|
||||
// TODO: replace DPAPI
|
||||
if len(encryptValue) > 0 {
|
||||
@@ -102,10 +102,10 @@ func (f *FirefoxCookie) Parse(masterKey []byte) error {
|
||||
KeyName: name,
|
||||
Host: host,
|
||||
Path: path,
|
||||
IsSecure: utils.IntToBool(isSecure),
|
||||
IsHTTPOnly: utils.IntToBool(isHttpOnly),
|
||||
CreateDate: utils.TimeStampFormat(creationTime / 1000000),
|
||||
ExpireDate: utils.TimeStampFormat(expiry),
|
||||
IsSecure: typeutil.IntToBool(isSecure),
|
||||
IsHTTPOnly: typeutil.IntToBool(isHttpOnly),
|
||||
CreateDate: typeutil.TimeStamp(creationTime / 1000000),
|
||||
ExpireDate: typeutil.TimeStamp(expiry),
|
||||
Value: value,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"hack-browser-data/internal/item"
|
||||
"hack-browser-data/internal/log"
|
||||
"hack-browser-data/internal/utils"
|
||||
"hack-browser-data/internal/utils/typeutil"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"github.com/tidwall/gjson"
|
||||
@@ -40,8 +40,8 @@ func (c *ChromiumDownload) Parse(masterKey []byte) error {
|
||||
TargetPath: targetPath,
|
||||
Url: tabUrl,
|
||||
TotalBytes: totalBytes,
|
||||
StartTime: utils.TimeEpochFormat(startTime),
|
||||
EndTime: utils.TimeEpochFormat(endTime),
|
||||
StartTime: typeutil.TimeEpoch(startTime),
|
||||
EndTime: typeutil.TimeEpoch(endTime),
|
||||
MimeType: mimeType,
|
||||
}
|
||||
*c = append(*c, data)
|
||||
@@ -98,8 +98,8 @@ func (f *FirefoxDownload) Parse(masterKey []byte) error {
|
||||
TargetPath: path,
|
||||
Url: url,
|
||||
TotalBytes: fileSize.Int(),
|
||||
StartTime: utils.TimeStampFormat(dateAdded / 1000000),
|
||||
EndTime: utils.TimeStampFormat(endTime.Int() / 1000),
|
||||
StartTime: typeutil.TimeStamp(dateAdded / 1000000),
|
||||
EndTime: typeutil.TimeStamp(endTime.Int() / 1000),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
"hack-browser-data/internal/item"
|
||||
"hack-browser-data/internal/log"
|
||||
"hack-browser-data/internal/utils"
|
||||
"hack-browser-data/internal/utils/typeutil"
|
||||
)
|
||||
|
||||
type ChromiumHistory []history
|
||||
@@ -40,7 +40,7 @@ func (c *ChromiumHistory) Parse(masterKey []byte) error {
|
||||
Url: url,
|
||||
Title: title,
|
||||
VisitCount: visitCount,
|
||||
LastVisitTime: utils.TimeEpochFormat(lastVisitTime),
|
||||
LastVisitTime: typeutil.TimeEpoch(lastVisitTime),
|
||||
}
|
||||
*c = append(*c, data)
|
||||
}
|
||||
@@ -91,7 +91,7 @@ func (f *FirefoxHistory) Parse(masterKey []byte) error {
|
||||
Title: title,
|
||||
Url: url,
|
||||
VisitCount: visitCount,
|
||||
LastVisitTime: utils.TimeStampFormat(visitDate / 1000000),
|
||||
LastVisitTime: typeutil.TimeStamp(visitDate / 1000000),
|
||||
})
|
||||
}
|
||||
sort.Slice(*f, func(i, j int) bool {
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"hack-browser-data/internal/decrypter"
|
||||
"hack-browser-data/internal/item"
|
||||
"hack-browser-data/internal/log"
|
||||
"hack-browser-data/internal/utils"
|
||||
"hack-browser-data/internal/utils/typeutil"
|
||||
)
|
||||
|
||||
type ChromiumPassword []loginData
|
||||
@@ -59,9 +59,9 @@ func (c *ChromiumPassword) Parse(masterKey []byte) error {
|
||||
}
|
||||
}
|
||||
if create > time.Now().Unix() {
|
||||
login.CreateDate = utils.TimeEpochFormat(create)
|
||||
login.CreateDate = typeutil.TimeEpoch(create)
|
||||
} else {
|
||||
login.CreateDate = utils.TimeStampFormat(create)
|
||||
login.CreateDate = typeutil.TimeStamp(create)
|
||||
}
|
||||
login.Password = string(password)
|
||||
*c = append(*c, login)
|
||||
@@ -119,9 +119,9 @@ func (c *YandexPassword) Parse(masterKey []byte) error {
|
||||
}
|
||||
}
|
||||
if create > time.Now().Unix() {
|
||||
login.CreateDate = utils.TimeEpochFormat(create)
|
||||
login.CreateDate = typeutil.TimeEpoch(create)
|
||||
} else {
|
||||
login.CreateDate = utils.TimeStampFormat(create)
|
||||
login.CreateDate = typeutil.TimeStamp(create)
|
||||
}
|
||||
login.Password = string(password)
|
||||
*c = append(*c, login)
|
||||
@@ -252,7 +252,7 @@ func getFirefoxLoginData(loginJson string) (l []loginData, err error) {
|
||||
}
|
||||
m.encryptUser = user
|
||||
m.encryptPass = pass
|
||||
m.CreateDate = utils.TimeStampFormat(v.Get("timeCreated").Int() / 1000)
|
||||
m.CreateDate = typeutil.TimeStamp(v.Get("timeCreated").Int() / 1000)
|
||||
l = append(l, m)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user