mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-19 18:58:03 +02:00
refactor code Closes #13
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha1"
|
||||
"errors"
|
||||
"hack-browser-data/log"
|
||||
"os/exec"
|
||||
|
||||
"golang.org/x/crypto/pbkdf2"
|
||||
)
|
||||
|
||||
const (
|
||||
chromeProfilePath = "/Users/*/Library/Application Support/Google/Chrome/*/"
|
||||
edgeProfilePath = "/Users/*/Library/Application Support/Microsoft Edge/*/"
|
||||
fireFoxProfilePath = "/Users/*/Library/Application Support/Firefox/Profiles/*.default-release/"
|
||||
)
|
||||
|
||||
var (
|
||||
browserList = map[string]struct {
|
||||
ProfilePath string
|
||||
Name string
|
||||
KeyPath string
|
||||
New func(profile, key, name string) (Browser, error)
|
||||
}{
|
||||
"chrome": {
|
||||
ProfilePath: chromeProfilePath,
|
||||
Name: chromeName,
|
||||
New: decryptChromium,
|
||||
},
|
||||
"edge": {
|
||||
ProfilePath: edgeProfilePath,
|
||||
Name: edgeName,
|
||||
New: decryptChromium,
|
||||
},
|
||||
"firefox": {
|
||||
ProfilePath: fireFoxProfilePath,
|
||||
Name: firefoxName,
|
||||
New: decryptFirefox,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func (c *chromium) InitSecretKey() error {
|
||||
var (
|
||||
cmd *exec.Cmd
|
||||
stdout, stderr bytes.Buffer
|
||||
)
|
||||
//➜ security find-generic-password -wa 'Chrome'
|
||||
cmd = exec.Command("security", "find-generic-password", "-wa", c.Name)
|
||||
cmd.Stdout = &stdout
|
||||
cmd.Stderr = &stderr
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return err
|
||||
}
|
||||
if stderr.Len() > 0 {
|
||||
err = errors.New(stderr.String())
|
||||
log.Error(err)
|
||||
}
|
||||
temp := stdout.Bytes()
|
||||
chromePass := temp[:len(temp)-1]
|
||||
var chromeSalt = []byte("saltysalt")
|
||||
// @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_mac.mm;l=157
|
||||
key := pbkdf2.Key(chromePass, chromeSalt, 1003, 16, sha1.New)
|
||||
c.SecretKey = key
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user