mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-19 18:58:03 +02:00
feat: decrypt chrome for linux password with dbus Close #4
This commit is contained in:
+54
-23
@@ -1,18 +1,17 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha1"
|
||||
"errors"
|
||||
"github.com/godbus/dbus/v5"
|
||||
keyring "github.com/ppacher/go-dbus-keyring"
|
||||
"hack-browser-data/log"
|
||||
"os/exec"
|
||||
|
||||
"golang.org/x/crypto/pbkdf2"
|
||||
)
|
||||
|
||||
const (
|
||||
fireFoxProfilePath = "/home/*/.mozilla/firefox/*.default-release/"
|
||||
fireFoxCommand = ""
|
||||
chromeProfilePath = "/home/*/.config/google-chrome/*/"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -24,35 +23,67 @@ var (
|
||||
}{
|
||||
"firefox": {
|
||||
ProfilePath: fireFoxProfilePath,
|
||||
Name: fireFoxCommand,
|
||||
Name: firefoxName,
|
||||
New: decryptFirefox,
|
||||
},
|
||||
"chrome": {
|
||||
ProfilePath: chromeProfilePath,
|
||||
Name: chromeName,
|
||||
New: decryptChromium,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
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()
|
||||
//what is d-bus @https://dbus.freedesktop.org/
|
||||
var chromeSecret []byte
|
||||
conn, err := dbus.SessionBus()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return err
|
||||
}
|
||||
if stderr.Len() > 0 {
|
||||
err = errors.New(stderr.String())
|
||||
log.Error(err)
|
||||
svc, err := keyring.GetSecretService(conn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
session, err := svc.OpenSession()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if err = session.Close(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}()
|
||||
collections, err := svc.GetAllCollections()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, col := range collections {
|
||||
items, err := col.GetAllItems()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, item := range items {
|
||||
i, err := item.GetLabel()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
continue
|
||||
}
|
||||
if i == "Chrome Safe Storage" {
|
||||
se, err := item.GetSecret(session.Path())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
chromeSecret = se.Value
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
if chromeSecret == nil {
|
||||
return ErrChromeSecretIsEmpty
|
||||
}
|
||||
// @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_linux.cc
|
||||
key := pbkdf2.Key(chromeSecret, chromeSalt, 1, 16, sha1.New)
|
||||
c.SecretKey = key
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user