2024-04-12 11:10:41 +00:00
|
|
|
package types
|
2022-04-02 06:47:12 +00:00
|
|
|
|
2024-01-13 07:58:53 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
2024-04-12 11:10:41 +00:00
|
|
|
type DataType int
|
2022-04-02 08:59:34 +00:00
|
|
|
|
|
|
|
const (
|
2024-04-12 11:10:41 +00:00
|
|
|
ChromiumKey DataType = iota
|
2022-04-02 08:59:34 +00:00
|
|
|
ChromiumPassword
|
|
|
|
ChromiumCookie
|
|
|
|
ChromiumBookmark
|
|
|
|
ChromiumHistory
|
|
|
|
ChromiumDownload
|
|
|
|
ChromiumCreditCard
|
|
|
|
ChromiumLocalStorage
|
2023-04-18 19:00:37 +00:00
|
|
|
ChromiumSessionStorage
|
2022-04-02 08:59:34 +00:00
|
|
|
ChromiumExtension
|
|
|
|
|
|
|
|
YandexPassword
|
|
|
|
YandexCreditCard
|
|
|
|
|
|
|
|
FirefoxKey4
|
|
|
|
FirefoxPassword
|
|
|
|
FirefoxCookie
|
|
|
|
FirefoxBookmark
|
|
|
|
FirefoxHistory
|
|
|
|
FirefoxDownload
|
|
|
|
FirefoxCreditCard
|
|
|
|
FirefoxLocalStorage
|
2023-04-18 19:00:37 +00:00
|
|
|
FirefoxSessionStorage
|
2022-04-02 08:59:34 +00:00
|
|
|
FirefoxExtension
|
|
|
|
)
|
|
|
|
|
2024-04-12 11:10:41 +00:00
|
|
|
var itemFileNames = map[DataType]string{
|
2024-01-13 07:58:53 +00:00
|
|
|
ChromiumKey: fileChromiumKey,
|
|
|
|
ChromiumPassword: fileChromiumPassword,
|
|
|
|
ChromiumCookie: fileChromiumCookie,
|
|
|
|
ChromiumBookmark: fileChromiumBookmark,
|
|
|
|
ChromiumDownload: fileChromiumDownload,
|
|
|
|
ChromiumLocalStorage: fileChromiumLocalStorage,
|
|
|
|
ChromiumSessionStorage: fileChromiumSessionStorage,
|
|
|
|
ChromiumCreditCard: fileChromiumCredit,
|
|
|
|
ChromiumExtension: fileChromiumExtension,
|
|
|
|
ChromiumHistory: fileChromiumHistory,
|
|
|
|
YandexPassword: fileYandexPassword,
|
|
|
|
YandexCreditCard: fileYandexCredit,
|
|
|
|
FirefoxKey4: fileFirefoxKey4,
|
|
|
|
FirefoxPassword: fileFirefoxPassword,
|
|
|
|
FirefoxCookie: fileFirefoxCookie,
|
|
|
|
FirefoxBookmark: fileFirefoxData,
|
|
|
|
FirefoxDownload: fileFirefoxData,
|
|
|
|
FirefoxLocalStorage: fileFirefoxLocalStorage,
|
|
|
|
FirefoxHistory: fileFirefoxData,
|
|
|
|
FirefoxExtension: fileFirefoxExtension,
|
|
|
|
FirefoxSessionStorage: UnsupportedItem,
|
|
|
|
FirefoxCreditCard: UnsupportedItem,
|
2022-04-02 06:47:12 +00:00
|
|
|
}
|
|
|
|
|
2024-04-12 11:10:41 +00:00
|
|
|
// Filename returns the filename for the item, defined by browser
|
|
|
|
// chromium local storage is a folder, so it returns the file name of the folder
|
|
|
|
func (i DataType) Filename() string {
|
2024-01-13 07:58:53 +00:00
|
|
|
if fileName, ok := itemFileNames[i]; ok {
|
|
|
|
return fileName
|
2022-04-02 06:47:12 +00:00
|
|
|
}
|
2024-01-13 07:58:53 +00:00
|
|
|
return UnsupportedItem
|
|
|
|
}
|
|
|
|
|
|
|
|
// TempFilename returns the temp filename for the item with suffix
|
|
|
|
// eg: chromiumKey_0.temp
|
2024-04-12 11:10:41 +00:00
|
|
|
func (i DataType) TempFilename() string {
|
|
|
|
const tempSuffix = "temp"
|
2024-01-13 07:58:53 +00:00
|
|
|
tempFile := fmt.Sprintf("%s_%d.%s", i.Filename(), i, tempSuffix)
|
|
|
|
return filepath.Join(os.TempDir(), tempFile)
|
2022-04-02 06:47:12 +00:00
|
|
|
}
|
|
|
|
|
2023-03-11 12:09:10 +00:00
|
|
|
// IsSensitive returns whether the item is sensitive data
|
|
|
|
// password, cookie, credit card, master key is unlimited
|
2024-04-12 11:10:41 +00:00
|
|
|
func (i DataType) IsSensitive() bool {
|
2023-03-11 12:09:10 +00:00
|
|
|
switch i {
|
|
|
|
case ChromiumKey, ChromiumCookie, ChromiumPassword, ChromiumCreditCard,
|
|
|
|
FirefoxKey4, FirefoxPassword, FirefoxCookie, FirefoxCreditCard,
|
|
|
|
YandexPassword, YandexCreditCard:
|
|
|
|
return true
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FilterSensitiveItems returns the sensitive items
|
2024-04-12 11:10:41 +00:00
|
|
|
func FilterSensitiveItems(items []DataType) []DataType {
|
|
|
|
var filtered []DataType
|
2023-03-11 12:09:10 +00:00
|
|
|
for _, item := range items {
|
|
|
|
if item.IsSensitive() {
|
|
|
|
filtered = append(filtered, item)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return filtered
|
|
|
|
}
|
|
|
|
|
2024-04-12 11:10:41 +00:00
|
|
|
// DefaultFirefoxTypes returns the default items for the firefox browser
|
|
|
|
var DefaultFirefoxTypes = []DataType{
|
2022-04-11 07:53:19 +00:00
|
|
|
FirefoxKey4,
|
|
|
|
FirefoxPassword,
|
|
|
|
FirefoxCookie,
|
|
|
|
FirefoxBookmark,
|
|
|
|
FirefoxHistory,
|
|
|
|
FirefoxDownload,
|
|
|
|
FirefoxCreditCard,
|
|
|
|
FirefoxLocalStorage,
|
2023-04-18 19:00:37 +00:00
|
|
|
FirefoxSessionStorage,
|
2022-04-11 07:53:19 +00:00
|
|
|
FirefoxExtension,
|
|
|
|
}
|
|
|
|
|
2024-04-12 11:10:41 +00:00
|
|
|
// DefaultYandexTypes returns the default items for the yandex browser
|
|
|
|
var DefaultYandexTypes = []DataType{
|
2022-04-11 07:53:19 +00:00
|
|
|
ChromiumKey,
|
|
|
|
ChromiumCookie,
|
|
|
|
ChromiumBookmark,
|
|
|
|
ChromiumHistory,
|
|
|
|
ChromiumDownload,
|
|
|
|
ChromiumExtension,
|
|
|
|
YandexPassword,
|
2022-04-19 13:28:43 +00:00
|
|
|
ChromiumLocalStorage,
|
2023-04-18 19:00:37 +00:00
|
|
|
ChromiumSessionStorage,
|
2022-04-11 07:53:19 +00:00
|
|
|
YandexCreditCard,
|
|
|
|
}
|
|
|
|
|
2024-04-12 11:10:41 +00:00
|
|
|
// DefaultChromiumTypes returns the default items for the chromium browser
|
|
|
|
var DefaultChromiumTypes = []DataType{
|
2022-04-11 07:53:19 +00:00
|
|
|
ChromiumKey,
|
|
|
|
ChromiumPassword,
|
|
|
|
ChromiumCookie,
|
|
|
|
ChromiumBookmark,
|
|
|
|
ChromiumHistory,
|
|
|
|
ChromiumDownload,
|
|
|
|
ChromiumCreditCard,
|
|
|
|
ChromiumLocalStorage,
|
2023-04-18 19:00:37 +00:00
|
|
|
ChromiumSessionStorage,
|
2022-04-11 07:53:19 +00:00
|
|
|
ChromiumExtension,
|
2022-04-02 06:47:12 +00:00
|
|
|
}
|
2024-01-13 07:58:53 +00:00
|
|
|
|
|
|
|
// item's default filename
|
|
|
|
const (
|
|
|
|
fileChromiumKey = "Local State"
|
|
|
|
fileChromiumCredit = "Web Data"
|
|
|
|
fileChromiumPassword = "Login Data"
|
|
|
|
fileChromiumHistory = "History"
|
|
|
|
fileChromiumDownload = "History"
|
|
|
|
fileChromiumCookie = "Cookies"
|
|
|
|
fileChromiumBookmark = "Bookmarks"
|
|
|
|
fileChromiumLocalStorage = "Local Storage/leveldb"
|
|
|
|
fileChromiumSessionStorage = "Session Storage"
|
|
|
|
fileChromiumExtension = "Secure Preferences" // TODO: add more extension files and folders, eg: Preferences
|
|
|
|
|
|
|
|
fileYandexPassword = "Ya Passman Data"
|
|
|
|
fileYandexCredit = "Ya Credit Cards"
|
|
|
|
|
|
|
|
fileFirefoxKey4 = "key4.db"
|
|
|
|
fileFirefoxCookie = "cookies.sqlite"
|
|
|
|
fileFirefoxPassword = "logins.json"
|
|
|
|
fileFirefoxData = "places.sqlite"
|
|
|
|
fileFirefoxLocalStorage = "webappsstore.sqlite"
|
|
|
|
fileFirefoxExtension = "extensions.json"
|
|
|
|
|
|
|
|
UnsupportedItem = "unsupported item"
|
|
|
|
)
|