HackBrowserData/types/types.go

171 lines
4.5 KiB
Go
Raw Normal View History

package types
2022-04-02 06:47:12 +00:00
dev: refactor items and update repo deploy (#278) * refactor: Refactor file paths and use map to store item names - Refactored file paths for various browsing data types to use a consistent method of generating temporary file names - Modified parsing functions in many browsing data types to use the new temporary file naming scheme - Renamed `FileName` to `Filename` for consistency in the `item` package - Removed unnecessary code and comments throughout various files - Made minor improvements to some Item methods such as `TempFilename` and `FileName` * ci: Optimize GitHub actions and update Go versions. (#274) * ci: Optimize GitHub actions and update Go versions. - Add GitHub actions for unit testing, linting, building, and releasing - Use a matrix strategy to test on different versions and platforms - Update setup-go and go-version options for compatibility - Format code and build zip files for different operating systems - Upload releases to GitHub with specific asset names and types * fix: Refactor item file naming convention - Update `filename()` function to return `UnsupportedItem` in specific cases - Replace `UnknownItem` with `UnsupportedItem` in `Filename` method of `Item` struct - Refactor code for clarity and consistency * ci: Update GitHub workflow with latest setup-go version - Update setup-go action to v3 in lint.yml GitHub workflow - Omits some big changes in file diff summary - Improve overall workflow reliability and efficiency * ci: Improve GitHub actions across platforms - Improve Windows compatibility in build workflow - Optimize unit testing for pull requests - Upgrade Coveralls GitHub action to v2 for improved coverage tracking * build: Optimize build process for consistency and efficiency - Ensure consistency of line endings by disabling Git's automatic conversion - Add format check for Windows systems - Update Go version in strategy matrix to `1.21.x` - Remove unused dependencies from build process - Include all packages in repository in build command * ci: Refactor GitHub workflow configuration - Remove unnecessary checks for `windows-latest` in github workflow - Change `gofmt` check to `diff` for formatting - Remove unneeded Git configuration for encoding of line endings - Close #273 * ci: Update default branch references in GitHub Actions workflows (#277) - Update Github Actions workflows to use `main` branch instead of `master`. - Rename `master` branch to `main` in `lint.yml` and `build.yml` files. - Change default branch to `main` in `contributors.yml` workflow file.
2024-01-13 07:58:53 +00:00
import (
"fmt"
"os"
"path/filepath"
)
type DataType int
2022-04-02 08:59:34 +00:00
const (
ChromiumKey DataType = iota
2022-04-02 08:59:34 +00:00
ChromiumPassword
ChromiumCookie
ChromiumBookmark
ChromiumHistory
ChromiumDownload
ChromiumCreditCard
ChromiumLocalStorage
ChromiumSessionStorage
2022-04-02 08:59:34 +00:00
ChromiumExtension
YandexPassword
YandexCreditCard
FirefoxKey4
FirefoxPassword
FirefoxCookie
FirefoxBookmark
FirefoxHistory
FirefoxDownload
FirefoxCreditCard
FirefoxLocalStorage
FirefoxSessionStorage
2022-04-02 08:59:34 +00:00
FirefoxExtension
)
var itemFileNames = map[DataType]string{
dev: refactor items and update repo deploy (#278) * refactor: Refactor file paths and use map to store item names - Refactored file paths for various browsing data types to use a consistent method of generating temporary file names - Modified parsing functions in many browsing data types to use the new temporary file naming scheme - Renamed `FileName` to `Filename` for consistency in the `item` package - Removed unnecessary code and comments throughout various files - Made minor improvements to some Item methods such as `TempFilename` and `FileName` * ci: Optimize GitHub actions and update Go versions. (#274) * ci: Optimize GitHub actions and update Go versions. - Add GitHub actions for unit testing, linting, building, and releasing - Use a matrix strategy to test on different versions and platforms - Update setup-go and go-version options for compatibility - Format code and build zip files for different operating systems - Upload releases to GitHub with specific asset names and types * fix: Refactor item file naming convention - Update `filename()` function to return `UnsupportedItem` in specific cases - Replace `UnknownItem` with `UnsupportedItem` in `Filename` method of `Item` struct - Refactor code for clarity and consistency * ci: Update GitHub workflow with latest setup-go version - Update setup-go action to v3 in lint.yml GitHub workflow - Omits some big changes in file diff summary - Improve overall workflow reliability and efficiency * ci: Improve GitHub actions across platforms - Improve Windows compatibility in build workflow - Optimize unit testing for pull requests - Upgrade Coveralls GitHub action to v2 for improved coverage tracking * build: Optimize build process for consistency and efficiency - Ensure consistency of line endings by disabling Git's automatic conversion - Add format check for Windows systems - Update Go version in strategy matrix to `1.21.x` - Remove unused dependencies from build process - Include all packages in repository in build command * ci: Refactor GitHub workflow configuration - Remove unnecessary checks for `windows-latest` in github workflow - Change `gofmt` check to `diff` for formatting - Remove unneeded Git configuration for encoding of line endings - Close #273 * ci: Update default branch references in GitHub Actions workflows (#277) - Update Github Actions workflows to use `main` branch instead of `master`. - Rename `master` branch to `main` in `lint.yml` and `build.yml` files. - Change default branch to `main` in `contributors.yml` workflow file.
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
}
// 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 {
dev: refactor items and update repo deploy (#278) * refactor: Refactor file paths and use map to store item names - Refactored file paths for various browsing data types to use a consistent method of generating temporary file names - Modified parsing functions in many browsing data types to use the new temporary file naming scheme - Renamed `FileName` to `Filename` for consistency in the `item` package - Removed unnecessary code and comments throughout various files - Made minor improvements to some Item methods such as `TempFilename` and `FileName` * ci: Optimize GitHub actions and update Go versions. (#274) * ci: Optimize GitHub actions and update Go versions. - Add GitHub actions for unit testing, linting, building, and releasing - Use a matrix strategy to test on different versions and platforms - Update setup-go and go-version options for compatibility - Format code and build zip files for different operating systems - Upload releases to GitHub with specific asset names and types * fix: Refactor item file naming convention - Update `filename()` function to return `UnsupportedItem` in specific cases - Replace `UnknownItem` with `UnsupportedItem` in `Filename` method of `Item` struct - Refactor code for clarity and consistency * ci: Update GitHub workflow with latest setup-go version - Update setup-go action to v3 in lint.yml GitHub workflow - Omits some big changes in file diff summary - Improve overall workflow reliability and efficiency * ci: Improve GitHub actions across platforms - Improve Windows compatibility in build workflow - Optimize unit testing for pull requests - Upgrade Coveralls GitHub action to v2 for improved coverage tracking * build: Optimize build process for consistency and efficiency - Ensure consistency of line endings by disabling Git's automatic conversion - Add format check for Windows systems - Update Go version in strategy matrix to `1.21.x` - Remove unused dependencies from build process - Include all packages in repository in build command * ci: Refactor GitHub workflow configuration - Remove unnecessary checks for `windows-latest` in github workflow - Change `gofmt` check to `diff` for formatting - Remove unneeded Git configuration for encoding of line endings - Close #273 * ci: Update default branch references in GitHub Actions workflows (#277) - Update Github Actions workflows to use `main` branch instead of `master`. - Rename `master` branch to `main` in `lint.yml` and `build.yml` files. - Change default branch to `main` in `contributors.yml` workflow file.
2024-01-13 07:58:53 +00:00
if fileName, ok := itemFileNames[i]; ok {
return fileName
2022-04-02 06:47:12 +00:00
}
dev: refactor items and update repo deploy (#278) * refactor: Refactor file paths and use map to store item names - Refactored file paths for various browsing data types to use a consistent method of generating temporary file names - Modified parsing functions in many browsing data types to use the new temporary file naming scheme - Renamed `FileName` to `Filename` for consistency in the `item` package - Removed unnecessary code and comments throughout various files - Made minor improvements to some Item methods such as `TempFilename` and `FileName` * ci: Optimize GitHub actions and update Go versions. (#274) * ci: Optimize GitHub actions and update Go versions. - Add GitHub actions for unit testing, linting, building, and releasing - Use a matrix strategy to test on different versions and platforms - Update setup-go and go-version options for compatibility - Format code and build zip files for different operating systems - Upload releases to GitHub with specific asset names and types * fix: Refactor item file naming convention - Update `filename()` function to return `UnsupportedItem` in specific cases - Replace `UnknownItem` with `UnsupportedItem` in `Filename` method of `Item` struct - Refactor code for clarity and consistency * ci: Update GitHub workflow with latest setup-go version - Update setup-go action to v3 in lint.yml GitHub workflow - Omits some big changes in file diff summary - Improve overall workflow reliability and efficiency * ci: Improve GitHub actions across platforms - Improve Windows compatibility in build workflow - Optimize unit testing for pull requests - Upgrade Coveralls GitHub action to v2 for improved coverage tracking * build: Optimize build process for consistency and efficiency - Ensure consistency of line endings by disabling Git's automatic conversion - Add format check for Windows systems - Update Go version in strategy matrix to `1.21.x` - Remove unused dependencies from build process - Include all packages in repository in build command * ci: Refactor GitHub workflow configuration - Remove unnecessary checks for `windows-latest` in github workflow - Change `gofmt` check to `diff` for formatting - Remove unneeded Git configuration for encoding of line endings - Close #273 * ci: Update default branch references in GitHub Actions workflows (#277) - Update Github Actions workflows to use `main` branch instead of `master`. - Rename `master` branch to `main` in `lint.yml` and `build.yml` files. - Change default branch to `main` in `contributors.yml` workflow file.
2024-01-13 07:58:53 +00:00
return UnsupportedItem
}
// TempFilename returns the temp filename for the item with suffix
// eg: chromiumKey_0.temp
func (i DataType) TempFilename() string {
const tempSuffix = "temp"
dev: refactor items and update repo deploy (#278) * refactor: Refactor file paths and use map to store item names - Refactored file paths for various browsing data types to use a consistent method of generating temporary file names - Modified parsing functions in many browsing data types to use the new temporary file naming scheme - Renamed `FileName` to `Filename` for consistency in the `item` package - Removed unnecessary code and comments throughout various files - Made minor improvements to some Item methods such as `TempFilename` and `FileName` * ci: Optimize GitHub actions and update Go versions. (#274) * ci: Optimize GitHub actions and update Go versions. - Add GitHub actions for unit testing, linting, building, and releasing - Use a matrix strategy to test on different versions and platforms - Update setup-go and go-version options for compatibility - Format code and build zip files for different operating systems - Upload releases to GitHub with specific asset names and types * fix: Refactor item file naming convention - Update `filename()` function to return `UnsupportedItem` in specific cases - Replace `UnknownItem` with `UnsupportedItem` in `Filename` method of `Item` struct - Refactor code for clarity and consistency * ci: Update GitHub workflow with latest setup-go version - Update setup-go action to v3 in lint.yml GitHub workflow - Omits some big changes in file diff summary - Improve overall workflow reliability and efficiency * ci: Improve GitHub actions across platforms - Improve Windows compatibility in build workflow - Optimize unit testing for pull requests - Upgrade Coveralls GitHub action to v2 for improved coverage tracking * build: Optimize build process for consistency and efficiency - Ensure consistency of line endings by disabling Git's automatic conversion - Add format check for Windows systems - Update Go version in strategy matrix to `1.21.x` - Remove unused dependencies from build process - Include all packages in repository in build command * ci: Refactor GitHub workflow configuration - Remove unnecessary checks for `windows-latest` in github workflow - Change `gofmt` check to `diff` for formatting - Remove unneeded Git configuration for encoding of line endings - Close #273 * ci: Update default branch references in GitHub Actions workflows (#277) - Update Github Actions workflows to use `main` branch instead of `master`. - Rename `master` branch to `main` in `lint.yml` and `build.yml` files. - Change default branch to `main` in `contributors.yml` workflow file.
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
}
// IsSensitive returns whether the item is sensitive data
// password, cookie, credit card, master key is unlimited
func (i DataType) IsSensitive() bool {
switch i {
case ChromiumKey, ChromiumCookie, ChromiumPassword, ChromiumCreditCard,
FirefoxKey4, FirefoxPassword, FirefoxCookie, FirefoxCreditCard,
YandexPassword, YandexCreditCard:
return true
default:
return false
}
}
// FilterSensitiveItems returns the sensitive items
func FilterSensitiveItems(items []DataType) []DataType {
var filtered []DataType
for _, item := range items {
if item.IsSensitive() {
filtered = append(filtered, item)
}
}
return filtered
}
// 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,
FirefoxSessionStorage,
2022-04-11 07:53:19 +00:00
FirefoxExtension,
}
// 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,
ChromiumSessionStorage,
2022-04-11 07:53:19 +00:00
YandexCreditCard,
}
// 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,
ChromiumSessionStorage,
2022-04-11 07:53:19 +00:00
ChromiumExtension,
2022-04-02 06:47:12 +00:00
}
dev: refactor items and update repo deploy (#278) * refactor: Refactor file paths and use map to store item names - Refactored file paths for various browsing data types to use a consistent method of generating temporary file names - Modified parsing functions in many browsing data types to use the new temporary file naming scheme - Renamed `FileName` to `Filename` for consistency in the `item` package - Removed unnecessary code and comments throughout various files - Made minor improvements to some Item methods such as `TempFilename` and `FileName` * ci: Optimize GitHub actions and update Go versions. (#274) * ci: Optimize GitHub actions and update Go versions. - Add GitHub actions for unit testing, linting, building, and releasing - Use a matrix strategy to test on different versions and platforms - Update setup-go and go-version options for compatibility - Format code and build zip files for different operating systems - Upload releases to GitHub with specific asset names and types * fix: Refactor item file naming convention - Update `filename()` function to return `UnsupportedItem` in specific cases - Replace `UnknownItem` with `UnsupportedItem` in `Filename` method of `Item` struct - Refactor code for clarity and consistency * ci: Update GitHub workflow with latest setup-go version - Update setup-go action to v3 in lint.yml GitHub workflow - Omits some big changes in file diff summary - Improve overall workflow reliability and efficiency * ci: Improve GitHub actions across platforms - Improve Windows compatibility in build workflow - Optimize unit testing for pull requests - Upgrade Coveralls GitHub action to v2 for improved coverage tracking * build: Optimize build process for consistency and efficiency - Ensure consistency of line endings by disabling Git's automatic conversion - Add format check for Windows systems - Update Go version in strategy matrix to `1.21.x` - Remove unused dependencies from build process - Include all packages in repository in build command * ci: Refactor GitHub workflow configuration - Remove unnecessary checks for `windows-latest` in github workflow - Change `gofmt` check to `diff` for formatting - Remove unneeded Git configuration for encoding of line endings - Close #273 * ci: Update default branch references in GitHub Actions workflows (#277) - Update Github Actions workflows to use `main` branch instead of `master`. - Rename `master` branch to `main` in `lint.yml` and `build.yml` files. - Change default branch to `main` in `contributors.yml` workflow file.
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"
)