mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-19 18:58:03 +02:00
feat: Refactor crypto decryption functions for consistency and error handling (#302)
* feat: Refactor crypto decryption functions for consistency and error handling - Close #301 - Refactored and renamed decryption functions across multiple files for consistency - Updated cookie sorting method to sort in descending order - Added new encryption functions for AES in CBC and GCM modes and DES in CBC mode - Added error handling to decryption functions and created new error variables for invalid ciphertext length and decode failures - Test cases added for encryption and decryption functions - Removed unused code and imports. * chore: Add new words to .typos.toml dictionary - Add new terms to `.typos.toml` dictionary - Improve code formatting and readability - Refactor functions for better performance - Update comments and documentation - Resolve minor bugs and errors * refactor: Refactor crypto package for better structure and readability - Refactored and cleaned up crypto package code for better readability - Renamed `ToByteArray` method to `bytes` for consistency - Modified `DecryptWithDPAPI` method to use `outBlob.bytes()` for efficiency - Added comments and removed unused methods in `loginPBE` - Refactored `nssPBE` and `metaPBE` Decrypt methods to use `deriveKeyAndIV` helper method - Improved overall maintainability and organization of codebase * refactor: Refactor firefox password encryption and decryption. - Implement ASN1PBE interface with various PBE struct types and encryption/decryption methods - Fix naming and remove unused variables in browsingdata and crypto files - Add tests for ASN1PBE implementation using external assertion package - Refactor and improve error handling in firefox file functions related to master key retrieval - Add input validation and AES-GCM encryption function to crypto file
This commit is contained in:
@@ -61,9 +61,9 @@ func (c *ChromiumPassword) Parse(masterKey []byte) error {
|
||||
}
|
||||
if len(pwd) > 0 {
|
||||
if len(masterKey) == 0 {
|
||||
password, err = crypto.DPAPI(pwd)
|
||||
password, err = crypto.DecryptWithDPAPI(pwd)
|
||||
} else {
|
||||
password, err = crypto.DecryptPass(masterKey, pwd)
|
||||
password, err = crypto.DecryptWithChromium(masterKey, pwd)
|
||||
}
|
||||
if err != nil {
|
||||
slog.Error("decrypt chromium password error", "err", err)
|
||||
@@ -129,9 +129,9 @@ func (c *YandexPassword) Parse(masterKey []byte) error {
|
||||
|
||||
if len(pwd) > 0 {
|
||||
if len(masterKey) == 0 {
|
||||
password, err = crypto.DPAPI(pwd)
|
||||
password, err = crypto.DecryptWithDPAPI(pwd)
|
||||
} else {
|
||||
password, err = crypto.DecryptPass(masterKey, pwd)
|
||||
password, err = crypto.DecryptWithChromium(masterKey, pwd)
|
||||
}
|
||||
if err != nil {
|
||||
slog.Error("decrypt yandex password error", "err", err)
|
||||
@@ -162,12 +162,7 @@ func (c *YandexPassword) Len() int {
|
||||
|
||||
type FirefoxPassword []loginData
|
||||
|
||||
const (
|
||||
queryMetaData = `SELECT item1, item2 FROM metaData WHERE id = 'password'`
|
||||
queryNssPrivate = `SELECT a11, a102 from nssPrivate`
|
||||
)
|
||||
|
||||
func (f *FirefoxPassword) Parse(masterKey []byte) error {
|
||||
func (f *FirefoxPassword) Parse(globalSalt []byte) error {
|
||||
logins, err := getFirefoxLoginData()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -182,11 +177,11 @@ func (f *FirefoxPassword) Parse(masterKey []byte) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
user, err := userPBE.Decrypt(masterKey)
|
||||
user, err := userPBE.Decrypt(globalSalt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pwd, err := pwdPBE.Decrypt(masterKey)
|
||||
pwd, err := pwdPBE.Decrypt(globalSalt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user