|
|
@ -2,21 +2,24 @@ package chromium |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"crypto/sha1" |
|
|
|
"crypto/sha1" |
|
|
|
|
|
|
|
"os" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/godbus/dbus/v5" |
|
|
|
"github.com/godbus/dbus/v5" |
|
|
|
keyring "github.com/ppacher/go-dbus-keyring" |
|
|
|
keyring "github.com/ppacher/go-dbus-keyring" |
|
|
|
"golang.org/x/crypto/pbkdf2" |
|
|
|
"golang.org/x/crypto/pbkdf2" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"hack-browser-data/internal/item" |
|
|
|
"hack-browser-data/internal/log" |
|
|
|
"hack-browser-data/internal/log" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func (c *chromium) GetMasterKey() ([]byte, error) { |
|
|
|
func (c *chromium) GetMasterKey() ([]byte, error) { |
|
|
|
// what is d-bus @https://dbus.freedesktop.org/
|
|
|
|
// what is d-bus @https://dbus.freedesktop.org/
|
|
|
|
var chromeSecret []byte |
|
|
|
var chromiumSecret []byte |
|
|
|
conn, err := dbus.SessionBus() |
|
|
|
conn, err := dbus.SessionBus() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
defer os.Remove(item.TempChromiumKey) |
|
|
|
svc, err := keyring.GetSecretService(conn) |
|
|
|
svc, err := keyring.GetSecretService(conn) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
@ -37,29 +40,29 @@ func (c *chromium) GetMasterKey() ([]byte, error) { |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
for _, item := range items { |
|
|
|
for _, i := range items { |
|
|
|
label, err := item.GetLabel() |
|
|
|
label, err := i.GetLabel() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Error(err) |
|
|
|
log.Error(err) |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
if label == c.storage { |
|
|
|
if label == c.storage { |
|
|
|
se, err := item.GetSecret(session.Path()) |
|
|
|
se, err := i.GetSecret(session.Path()) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Error(err) |
|
|
|
log.Error(err) |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
chromeSecret = se.Value |
|
|
|
chromiumSecret = se.Value |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// TODO: handle error if no secret found
|
|
|
|
if chromiumSecret == nil { |
|
|
|
if chromeSecret == nil { |
|
|
|
// @https://source.chromium.org/chromium/chromium/src/+/main:components/os_crypt/os_crypt_linux.cc;l=100
|
|
|
|
return nil, err |
|
|
|
chromiumSecret = []byte("peanuts") |
|
|
|
} |
|
|
|
} |
|
|
|
var chromeSalt = []byte("saltysalt") |
|
|
|
var chromiumSalt = []byte("saltysalt") |
|
|
|
// @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_linux.cc
|
|
|
|
// @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_linux.cc
|
|
|
|
key := pbkdf2.Key(chromeSecret, chromeSalt, 1, 16, sha1.New) |
|
|
|
key := pbkdf2.Key(chromiumSecret, chromiumSalt, 1, 16, sha1.New) |
|
|
|
c.masterKey = key |
|
|
|
c.masterKey = key |
|
|
|
return key, nil |
|
|
|
return key, nil |
|
|
|
} |
|
|
|
} |
|
|
|