mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-23 19:14:01 +02:00
fix: add cipher text length check in AES decryption, Close #87
This commit is contained in:
@@ -17,9 +17,9 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
errSecurityKeyIsEmpty = errors.New("input [security find-generic-password -wa 'Chrome'] in terminal")
|
errSecurityKeyIsEmpty = errors.New("input [security find-generic-password -wa 'Chrome'] in terminal")
|
||||||
errPasswordIsEmpty = errors.New("password is empty")
|
|
||||||
errDecryptFailed = errors.New("decrypt failed, password is empty")
|
errDecryptFailed = errors.New("decrypt failed, password is empty")
|
||||||
errDecodeASN1Failed = errors.New("decode ASN1 data failed")
|
errDecodeASN1Failed = errors.New("decode ASN1 data failed")
|
||||||
|
errEncryptedLength = errors.New("length of encrypted password less than block size")
|
||||||
)
|
)
|
||||||
|
|
||||||
type ASN1PBE interface {
|
type ASN1PBE interface {
|
||||||
@@ -163,7 +163,12 @@ func aes128CBCDecrypt(key, iv, encryptPass []byte) ([]byte, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
dst := make([]byte, len(encryptPass))
|
encryptLen := len(encryptPass)
|
||||||
|
if encryptLen < block.BlockSize() {
|
||||||
|
return nil, errEncryptedLength
|
||||||
|
}
|
||||||
|
|
||||||
|
dst := make([]byte, encryptLen)
|
||||||
mode := cipher.NewCBCDecrypter(block, iv)
|
mode := cipher.NewCBCDecrypter(block, iv)
|
||||||
mode.CryptBlocks(dst, encryptPass)
|
mode.CryptBlocks(dst, encryptPass)
|
||||||
dst = PKCS5UnPadding(dst)
|
dst = PKCS5UnPadding(dst)
|
||||||
|
|||||||
Reference in New Issue
Block a user