mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-19 18:58:03 +02:00
feat: add firefox for windows decrypt Closes #11
This commit is contained in:
@@ -3,14 +3,20 @@ package utils
|
||||
import (
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"crypto/sha1"
|
||||
"crypto/sha256"
|
||||
"encoding/asn1"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"hack-browser-data/log"
|
||||
"os"
|
||||
"strings"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/tidwall/gjson"
|
||||
"golang.org/x/crypto/pbkdf2"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -22,6 +28,8 @@ const (
|
||||
speed360KeyPath = ""
|
||||
qqBrowserProfilePath = "/AppData/Local/Tencent/QQBrowser/User Data/*/"
|
||||
qqBrowserKeyPath = ""
|
||||
firefoxProfilePath = "/AppData/Roaming/Mozilla/Firefox/Profiles/*.default-release/"
|
||||
firefoxKeyPath = ""
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -47,6 +55,10 @@ var (
|
||||
qqBrowserProfilePath,
|
||||
qqBrowserKeyPath,
|
||||
},
|
||||
"firefox": {
|
||||
firefoxProfilePath,
|
||||
"",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -161,3 +173,66 @@ func DecryptStringWithDPAPI(data []byte) (string, error) {
|
||||
defer procLocalFree.Call(uintptr(unsafe.Pointer(outBlob.pbData)))
|
||||
return string(outBlob.ToByteArray()), nil
|
||||
}
|
||||
|
||||
type MetaPBE struct {
|
||||
SequenceA
|
||||
CipherText []byte
|
||||
}
|
||||
type SequenceA struct {
|
||||
PKCS5PBES2 asn1.ObjectIdentifier
|
||||
SequenceB
|
||||
}
|
||||
type SequenceB struct {
|
||||
SequenceC
|
||||
SequenceD
|
||||
}
|
||||
|
||||
type SequenceC struct {
|
||||
PKCS5PBKDF2 asn1.ObjectIdentifier
|
||||
SequenceE
|
||||
}
|
||||
|
||||
type SequenceD struct {
|
||||
AES256CBC asn1.ObjectIdentifier
|
||||
IV []byte
|
||||
}
|
||||
|
||||
type SequenceE struct {
|
||||
EntrySalt []byte
|
||||
IterationCount int
|
||||
KeySize int
|
||||
SequenceF
|
||||
}
|
||||
|
||||
type SequenceF struct {
|
||||
HMACWithSHA256 asn1.ObjectIdentifier
|
||||
}
|
||||
|
||||
func CheckPassword(globalSalt, masterPwd []byte, pbe MetaPBE) ([]byte, error) {
|
||||
sha1.New()
|
||||
k := sha1.Sum(globalSalt)
|
||||
|
||||
log.Println(hex.EncodeToString(k[:]))
|
||||
key := pbkdf2.Key(k[:], pbe.EntrySalt, pbe.IterationCount, pbe.KeySize, sha256.New)
|
||||
log.Println(hex.EncodeToString(key))
|
||||
i, err := hex.DecodeString("040e")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
// @https://hg.mozilla.org/projects/nss/rev/fc636973ad06392d11597620b602779b4af312f6#l6.49
|
||||
iv := append(i, pbe.IV...)
|
||||
dst, err := aes128CBCDecrypt(key, iv, pbe.CipherText)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
return dst, err
|
||||
}
|
||||
|
||||
func DecodeMeta(decodeItem []byte) (pbe MetaPBE, err error) {
|
||||
_, err = asn1.Unmarshal(decodeItem, &pbe)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user