HackBrowserData/browser/chromium/chromium_windows.go

44 lines
1.0 KiB
Go
Raw Normal View History

//go:build windows
package chromium
import (
"encoding/base64"
"errors"
2022-04-13 07:30:30 +00:00
"os"
"github.com/tidwall/gjson"
2022-04-11 07:53:19 +00:00
"github.com/moond4rk/hackbrowserdata/crypto"
chore: downgrade golang version to 1.20, support Windows 7. (#435) * chore: downgrade golang version to 1.20, support windows 7 * chore: Update dependencies for Go project. - Update dependencies in go.sum - Improvements and optimizations in various files - Bug fixes and error handling enhancements * chore: Update modernc.org/sqlite library versions in go.mod and go.sum files - Update version of `modernc.org/sqlite` to `v1.31.1` in `go.mod` and `go.sum` files - Update module hash in `go.sum` file for `modernc.org/sqlite` - Ensure consistency between `go.mod` and `go.sum` files in relation to `modernc.org/sqlite` version * chore: replace log/slog with standard logger (#436) * chore: replace log/slog with standard logger * chore: Update Go dependencies and versions - Update Go version from `1.22.5` to `1.20` and other dependencies - Update critical dependencies to latest versions - Ensure compatibility with new versions of dependencies * chore: Optimize dependency management in workflows - Update build and lint workflows to use `go mod tidy` for getting dependencies - Change modules download mode to `'mod'` in linters configuration - Add step to get dependencies in lint workflow * refactor: Update dependencies and refactor Chromium key deletion logic - Update `modernc.org/sqlite` to `v1.31.1` in `go.mod` and `go.sum` - Increase version number to `0.5.0` in `cmd/hack-browser-data/main.go` - Refactor and update logic for filtering and copying items in `browser/chromium/chromium.go` * Improve logging functionality and data type conversion - Add `String()` method to `DataType` enum in types.go - Update log level to Debug in logger_test.go - Set log level to Debug in `TestLoggerDebug` and `TestLoggerDebugf` functions
2024-10-22 03:13:06 +00:00
"github.com/moond4rk/hackbrowserdata/log"
"github.com/moond4rk/hackbrowserdata/types"
"github.com/moond4rk/hackbrowserdata/utils/fileutil"
)
var errDecodeMasterKeyFailed = errors.New("decode master key failed")
2023-03-10 06:52:26 +00:00
func (c *Chromium) GetMasterKey() ([]byte, error) {
b, err := fileutil.ReadFile(types.ChromiumKey.TempFilename())
if err != nil {
return nil, err
}
defer os.Remove(types.ChromiumKey.TempFilename())
encryptedKey := gjson.Get(b, "os_crypt.encrypted_key")
2022-08-14 13:22:34 +00:00
if !encryptedKey.Exists() {
return nil, nil
}
key, err := base64.StdEncoding.DecodeString(encryptedKey.String())
2022-08-14 13:22:34 +00:00
if err != nil {
return nil, errDecodeMasterKeyFailed
}
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
2024-01-27 14:30:28 +00:00
c.masterKey, err = crypto.DecryptWithDPAPI(key[5:])
if err != nil {
chore: downgrade golang version to 1.20, support Windows 7. (#435) * chore: downgrade golang version to 1.20, support windows 7 * chore: Update dependencies for Go project. - Update dependencies in go.sum - Improvements and optimizations in various files - Bug fixes and error handling enhancements * chore: Update modernc.org/sqlite library versions in go.mod and go.sum files - Update version of `modernc.org/sqlite` to `v1.31.1` in `go.mod` and `go.sum` files - Update module hash in `go.sum` file for `modernc.org/sqlite` - Ensure consistency between `go.mod` and `go.sum` files in relation to `modernc.org/sqlite` version * chore: replace log/slog with standard logger (#436) * chore: replace log/slog with standard logger * chore: Update Go dependencies and versions - Update Go version from `1.22.5` to `1.20` and other dependencies - Update critical dependencies to latest versions - Ensure compatibility with new versions of dependencies * chore: Optimize dependency management in workflows - Update build and lint workflows to use `go mod tidy` for getting dependencies - Change modules download mode to `'mod'` in linters configuration - Add step to get dependencies in lint workflow * refactor: Update dependencies and refactor Chromium key deletion logic - Update `modernc.org/sqlite` to `v1.31.1` in `go.mod` and `go.sum` - Increase version number to `0.5.0` in `cmd/hack-browser-data/main.go` - Refactor and update logic for filtering and copying items in `browser/chromium/chromium.go` * Improve logging functionality and data type conversion - Add `String()` method to `DataType` enum in types.go - Update log level to Debug in logger_test.go - Set log level to Debug in `TestLoggerDebug` and `TestLoggerDebugf` functions
2024-10-22 03:13:06 +00:00
log.Errorf("decrypt master key failed, err %v", err)
return nil, err
}
chore: downgrade golang version to 1.20, support Windows 7. (#435) * chore: downgrade golang version to 1.20, support windows 7 * chore: Update dependencies for Go project. - Update dependencies in go.sum - Improvements and optimizations in various files - Bug fixes and error handling enhancements * chore: Update modernc.org/sqlite library versions in go.mod and go.sum files - Update version of `modernc.org/sqlite` to `v1.31.1` in `go.mod` and `go.sum` files - Update module hash in `go.sum` file for `modernc.org/sqlite` - Ensure consistency between `go.mod` and `go.sum` files in relation to `modernc.org/sqlite` version * chore: replace log/slog with standard logger (#436) * chore: replace log/slog with standard logger * chore: Update Go dependencies and versions - Update Go version from `1.22.5` to `1.20` and other dependencies - Update critical dependencies to latest versions - Ensure compatibility with new versions of dependencies * chore: Optimize dependency management in workflows - Update build and lint workflows to use `go mod tidy` for getting dependencies - Change modules download mode to `'mod'` in linters configuration - Add step to get dependencies in lint workflow * refactor: Update dependencies and refactor Chromium key deletion logic - Update `modernc.org/sqlite` to `v1.31.1` in `go.mod` and `go.sum` - Increase version number to `0.5.0` in `cmd/hack-browser-data/main.go` - Refactor and update logic for filtering and copying items in `browser/chromium/chromium.go` * Improve logging functionality and data type conversion - Add `String()` method to `DataType` enum in types.go - Update log level to Debug in logger_test.go - Set log level to Debug in `TestLoggerDebug` and `TestLoggerDebugf` functions
2024-10-22 03:13:06 +00:00
log.Debugf("get master key success, browser %s", c.name)
return c.masterKey, nil
}