mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-19 18:58:03 +02:00
docs: update readme to 0.1.0
This commit is contained in:
+38
-2
@@ -14,6 +14,9 @@ import (
|
||||
|
||||
var (
|
||||
passwordIsEmpty = errors.New("decrypt fail, password is empty")
|
||||
|
||||
errBrowserNotSupported = errors.New("browser not supported")
|
||||
VersionUnder80 bool
|
||||
)
|
||||
|
||||
type DecryptError struct {
|
||||
@@ -29,6 +32,11 @@ func (e *DecryptError) Unwrap() error {
|
||||
return e.err
|
||||
}
|
||||
|
||||
type Browser struct {
|
||||
Name string
|
||||
DataDir string
|
||||
}
|
||||
|
||||
const (
|
||||
LoginData = "Login Data"
|
||||
History = "History"
|
||||
@@ -36,6 +44,29 @@ const (
|
||||
Bookmarks = "Bookmarks"
|
||||
)
|
||||
|
||||
func ListBrowser() []string {
|
||||
var l []string
|
||||
for k := range browserList {
|
||||
l = append(l, k)
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
func GetDBPath(dir string, dbName ...string) (dbFile []string) {
|
||||
for _, v := range dbName {
|
||||
s, err := filepath.Glob(dir + v)
|
||||
if err != nil && len(s) == 0 {
|
||||
continue
|
||||
}
|
||||
if len(s) > 0 {
|
||||
log.Debugf("Find %s File Success", v)
|
||||
log.Debugf("%s file location is %s", v, s[0])
|
||||
dbFile = append(dbFile, s[0])
|
||||
}
|
||||
}
|
||||
return dbFile
|
||||
}
|
||||
|
||||
func CopyDB(src, dst string) error {
|
||||
locals, _ := filepath.Glob("*")
|
||||
for _, v := range locals {
|
||||
@@ -65,6 +96,11 @@ func IntToBool(a int) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func TimeStampFormat(stamp int64) time.Time {
|
||||
s1 := time.Unix(stamp, 0)
|
||||
return s1
|
||||
}
|
||||
|
||||
func TimeEpochFormat(epoch int64) time.Time {
|
||||
maxTime := int64(99633311740000000)
|
||||
if epoch > maxTime {
|
||||
@@ -101,9 +137,9 @@ func WriteFile(filename string, data []byte) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func FormatFileName(dir, filename, format string) string {
|
||||
func FormatFileName(dir, browser, filename, format string) string {
|
||||
r := strings.TrimSpace(strings.ToLower(filename))
|
||||
p := path.Join(dir, fmt.Sprintf("%s.%s", r, format))
|
||||
p := path.Join(dir, fmt.Sprintf("%s_%s.%s", r, browser, format))
|
||||
return p
|
||||
}
|
||||
|
||||
|
||||
+55
-22
@@ -8,28 +8,61 @@ import (
|
||||
"errors"
|
||||
"hack-browser-data/log"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/crypto/pbkdf2"
|
||||
)
|
||||
|
||||
const (
|
||||
macChromeDir = "/Users/*/Library/Application Support/Google/Chrome/*/"
|
||||
chromeDir = "/Users/*/Library/Application Support/Google/Chrome/*/"
|
||||
edgeDir = "/Users/*/Library/Application Support/Microsoft Edge/*/"
|
||||
mac360Secure = "/Users/*/Library/Application Support/360Chrome/*/"
|
||||
)
|
||||
|
||||
const (
|
||||
Chrome = "Chrome"
|
||||
Edge = "Microsoft Edge"
|
||||
SecureBrowser = "Chromium"
|
||||
)
|
||||
|
||||
var (
|
||||
iv = []byte{32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32}
|
||||
command = []string{"security", "find-generic-password", "-wa", "Chrome"}
|
||||
chromeSalt = []byte("saltysalt")
|
||||
chromeKey []byte
|
||||
iv = []byte{32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32}
|
||||
command = []string{"security", "find-generic-password", "-wa"}
|
||||
chromeSalt = []byte("saltysalt")
|
||||
chromeKey []byte
|
||||
browserList = map[string]struct {
|
||||
Dir string
|
||||
Command string
|
||||
}{
|
||||
"chrome": {
|
||||
chromeDir,
|
||||
Chrome,
|
||||
},
|
||||
"edge": {
|
||||
edgeDir,
|
||||
Edge,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func InitChromeKey() error {
|
||||
func DecryptStringWithDPAPI(data []byte) (string, error) {
|
||||
return string(data), nil
|
||||
}
|
||||
|
||||
func PickBrowser(name string) (browserDir, command string, err error) {
|
||||
name = strings.ToLower(name)
|
||||
if choice, ok := browserList[name]; ok {
|
||||
return choice.Dir, choice.Command, err
|
||||
}
|
||||
return "", "", errBrowserNotSupported
|
||||
}
|
||||
|
||||
func InitKey(key string) error {
|
||||
var (
|
||||
cmd *exec.Cmd
|
||||
stdout, stderr bytes.Buffer
|
||||
)
|
||||
cmd = exec.Command(command[0], command[1], command[2], command[3])
|
||||
cmd = exec.Command(command[0], command[1], command[2], key)
|
||||
cmd.Stdout = &stdout
|
||||
cmd.Stderr = &stderr
|
||||
err := cmd.Run()
|
||||
@@ -47,20 +80,20 @@ func InitChromeKey() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func GetDBPath(dbName ...string) (dbFile []string) {
|
||||
for _, v := range dbName {
|
||||
s, err := filepath.Glob(macChromeDir + v)
|
||||
if err != nil && len(s) == 0 {
|
||||
continue
|
||||
}
|
||||
if len(s) > 0 {
|
||||
log.Debugf("Find %s File Success", v)
|
||||
log.Debugf("%s file location is %s", v, s[0])
|
||||
dbFile = append(dbFile, s[0])
|
||||
}
|
||||
}
|
||||
return dbFile
|
||||
}
|
||||
//func GetDBPath(dir string, dbName ...string) (dbFile []string) {
|
||||
// for _, v := range dbName {
|
||||
// s, err := filepath.Glob(dir + v)
|
||||
// if err != nil && len(s) == 0 {
|
||||
// continue
|
||||
// }
|
||||
// if len(s) > 0 {
|
||||
// log.Debugf("Find %s File Success", v)
|
||||
// log.Debugf("%s file location is %s", v, s[0])
|
||||
// dbFile = append(dbFile, s[0])
|
||||
// }
|
||||
// }
|
||||
// return dbFile
|
||||
//}
|
||||
|
||||
func decryptChromeKey(chromePass []byte) {
|
||||
chromeKey = pbkdf2.Key(chromePass, chromeSalt, 1003, 16, sha1.New)
|
||||
|
||||
+94
-34
@@ -4,9 +4,9 @@ import (
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"encoding/base64"
|
||||
"hack-browser-data/log"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
@@ -14,50 +14,96 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
winChromeKeyDir = "/AppData/Local/Google/Chrome/User Data/Local State"
|
||||
winChromeDir = "/AppData/Local/Google/Chrome/User Data/*/"
|
||||
chromeDir = "/AppData/Local/Google/Chrome/User Data/*/"
|
||||
chromeKeyFile = "/AppData/Local/Google/Chrome/User Data/Local State"
|
||||
secure360Dir = "/AppData/Local/360chrome/Chrome/User Data/*/"
|
||||
secure360KeyFile = ""
|
||||
edgeDir = "/AppData/Local/Microsoft/Edge/User Data/*/"
|
||||
edgeKeyFile = "/AppData/Local/Microsoft/Edge/User Data/Local State"
|
||||
)
|
||||
|
||||
var (
|
||||
chromeKey []byte
|
||||
|
||||
browserList = map[string]struct {
|
||||
Dir string
|
||||
Key string
|
||||
}{
|
||||
"chrome": {
|
||||
chromeDir,
|
||||
chromeKeyFile,
|
||||
},
|
||||
"edge": {
|
||||
edgeDir,
|
||||
edgeKeyFile,
|
||||
},
|
||||
"360secure": {
|
||||
secure360Dir,
|
||||
secure360KeyFile,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func InitChromeKey() error {
|
||||
chromeKeyPath := os.Getenv("USERPROFILE") + winChromeKeyDir
|
||||
keyFile, err := ReadFile(chromeKeyPath)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return err
|
||||
|
||||
func PickBrowser(name string) (browserDir, key string, err error) {
|
||||
name = strings.ToLower(name)
|
||||
if choice, ok := browserList[name]; ok {
|
||||
if choice.Key != "" {
|
||||
return os.Getenv("USERPROFILE") + choice.Dir, os.Getenv("USERPROFILE") + choice.Key, nil
|
||||
} else {
|
||||
return os.Getenv("USERPROFILE") + choice.Dir, "", nil
|
||||
}
|
||||
}
|
||||
s := gjson.Get(keyFile, "os_crypt.encrypted_key").String()
|
||||
masterKey, err := base64.StdEncoding.DecodeString(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
chromeKey, err = DecryptStringWithDPAPI(masterKey[5:])
|
||||
return err
|
||||
return "", "", errBrowserNotSupported
|
||||
}
|
||||
|
||||
func GetDBPath(dbName ...string) (dbFile []string) {
|
||||
var dbPath []string
|
||||
chromeDBPath := os.Getenv("USERPROFILE") + winChromeDir
|
||||
for _, v := range dbName {
|
||||
dbPath = append(dbPath, chromeDBPath+v)
|
||||
var (
|
||||
errBase64DecodeFailed = errors.New("decode base64 failed")
|
||||
)
|
||||
|
||||
func InitKey(key string) error {
|
||||
if key == "" {
|
||||
VersionUnder80 = true
|
||||
return nil
|
||||
}
|
||||
for _, v := range dbPath {
|
||||
s, err := filepath.Glob(v)
|
||||
if err != nil && len(s) == 0 {
|
||||
continue
|
||||
}
|
||||
if len(s) > 0 {
|
||||
log.Debugf("Find %s File Success", v)
|
||||
log.Debugf("%s file location is %s", v, s[0])
|
||||
dbFile = append(dbFile, s[0])
|
||||
}
|
||||
keyFile, err := ReadFile(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
encryptedKey := gjson.Get(keyFile, "os_crypt.encrypted_key")
|
||||
if encryptedKey.Exists() {
|
||||
pureKey, err := base64.StdEncoding.DecodeString(encryptedKey.String())
|
||||
if err != nil {
|
||||
return errBase64DecodeFailed
|
||||
}
|
||||
chromeKey, err = decryptStringWithDPAPI(pureKey[5:])
|
||||
return nil
|
||||
} else {
|
||||
VersionUnder80 = true
|
||||
return nil
|
||||
}
|
||||
return dbFile
|
||||
}
|
||||
|
||||
//func GetDBPath(dir string, dbName ...string) (dbFile []string) {
|
||||
// var dbPath []string
|
||||
// chromeDBPath := os.Getenv("USERPROFILE") + dir
|
||||
// for _, v := range dbName {
|
||||
// dbPath = append(dbPath, chromeDBPath+v)
|
||||
// }
|
||||
// for _, v := range dbPath {
|
||||
// s, err := filepath.Glob(v)
|
||||
// if err != nil && len(s) == 0 {
|
||||
// continue
|
||||
// }
|
||||
// if len(s) > 0 {
|
||||
// log.Debugf("Find %s File Success", v)
|
||||
// log.Debugf("%s file location is %s", v, s[0])
|
||||
// dbFile = append(dbFile, s[0])
|
||||
// }
|
||||
// }
|
||||
// return dbFile
|
||||
//}
|
||||
|
||||
func DecryptChromePass(encryptPass []byte) (string, error) {
|
||||
if len(encryptPass) > 15 {
|
||||
// remove prefix 'v10'
|
||||
@@ -103,7 +149,7 @@ func (b *DataBlob) ToByteArray() []byte {
|
||||
}
|
||||
|
||||
// chrome < 80 https://chromium.googlesource.com/chromium/src/+/76f496a7235c3432983421402951d73905c8be96/components/os_crypt/os_crypt_win.cc#82
|
||||
func DecryptStringWithDPAPI(data []byte) ([]byte, error) {
|
||||
func decryptStringWithDPAPI(data []byte) ([]byte, error) {
|
||||
dllCrypt := syscall.NewLazyDLL("Crypt32.dll")
|
||||
dllKernel := syscall.NewLazyDLL("Kernel32.dll")
|
||||
procDecryptData := dllCrypt.NewProc("CryptUnprotectData")
|
||||
@@ -116,3 +162,17 @@ func DecryptStringWithDPAPI(data []byte) ([]byte, error) {
|
||||
defer procLocalFree.Call(uintptr(unsafe.Pointer(outBlob.pbData)))
|
||||
return outBlob.ToByteArray(), nil
|
||||
}
|
||||
|
||||
func DecryptStringWithDPAPI(data []byte) (string, error) {
|
||||
dllCrypt := syscall.NewLazyDLL("Crypt32.dll")
|
||||
dllKernel := syscall.NewLazyDLL("Kernel32.dll")
|
||||
procDecryptData := dllCrypt.NewProc("CryptUnprotectData")
|
||||
procLocalFree := dllKernel.NewProc("LocalFree")
|
||||
var outBlob DataBlob
|
||||
r, _, err := procDecryptData.Call(uintptr(unsafe.Pointer(NewBlob(data))), 0, 0, 0, 0, 0, uintptr(unsafe.Pointer(&outBlob)))
|
||||
if r == 0 {
|
||||
return "", err
|
||||
}
|
||||
defer procLocalFree.Call(uintptr(unsafe.Pointer(outBlob.pbData)))
|
||||
return string(outBlob.ToByteArray()), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user