mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-07-06 21:37:47 +02:00
refactor: naming cleanup and crypto package improvements (#551)
* refactor: naming cleanup across all packages
This commit is contained in:
@@ -69,7 +69,7 @@ type addressRange struct {
|
||||
// DecryptKeychain extracts the browser storage password from login.keychain-db
|
||||
// by dumping securityd memory and scanning for the keychain master key.
|
||||
// Requires root privileges.
|
||||
func DecryptKeychain(storagename string) (string, error) {
|
||||
func DecryptKeychain(storageName string) (string, error) {
|
||||
if os.Geteuid() != 0 {
|
||||
return "", errors.New("requires root privileges")
|
||||
}
|
||||
@@ -124,13 +124,13 @@ func DecryptKeychain(storagename string) (string, error) {
|
||||
continue
|
||||
}
|
||||
for _, rec := range records {
|
||||
if rec.Account == storagename {
|
||||
if rec.Account == storageName {
|
||||
return string(rec.Password), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("tried %d candidates, none matched storage %q", len(candidates), storagename)
|
||||
return "", fmt.Errorf("tried %d candidates, none matched storage %q", len(candidates), storageName)
|
||||
}
|
||||
|
||||
// scanMasterKeyCandidates scans the core dump for 24-byte master key candidates.
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
var darwinParams = pbkdf2Params{
|
||||
salt: []byte("saltysalt"),
|
||||
iterations: 1003,
|
||||
keyLen: 16,
|
||||
keySize: 16,
|
||||
hashFunc: sha1.New,
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
var linuxParams = pbkdf2Params{
|
||||
salt: []byte("saltysalt"),
|
||||
iterations: 1,
|
||||
keyLen: 16,
|
||||
keySize: 16,
|
||||
hashFunc: sha1.New,
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ func (r *DPAPIRetriever) RetrieveKey(_, localStatePath string) ([]byte, error) {
|
||||
return nil, fmt.Errorf("encrypted_key unexpected prefix: got %q, want %q", keyBytes[:len(dpapiPrefix)], dpapiPrefix)
|
||||
}
|
||||
|
||||
masterKey, err := crypto.DecryptWithDPAPI(keyBytes[len(dpapiPrefix):])
|
||||
masterKey, err := crypto.DecryptDPAPI(keyBytes[len(dpapiPrefix):])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("DPAPI decrypt: %w", err)
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@ import (
|
||||
type pbkdf2Params struct {
|
||||
salt []byte
|
||||
iterations int
|
||||
keyLen int
|
||||
keySize int
|
||||
hashFunc func() hash.Hash
|
||||
}
|
||||
|
||||
// deriveKey derives an encryption key from a secret using PBKDF2.
|
||||
func (p pbkdf2Params) deriveKey(secret []byte) []byte {
|
||||
return crypto.PBKDF2Key(secret, p.salt, p.iterations, p.keyLen, p.hashFunc)
|
||||
return crypto.PBKDF2Key(secret, p.salt, p.iterations, p.keySize, p.hashFunc)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user