mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-23 19:14:01 +02:00
feat: add copy file to local
This commit is contained in:
@@ -32,30 +32,17 @@ func New(name, storage, profilePath string, items []item.Item) (*chromium, error
|
||||
if !fileutil.FolderExists(profilePath) {
|
||||
return nil, fmt.Errorf("%s profile path is not exist: %s", name, profilePath)
|
||||
}
|
||||
masterKey, err := c.GetMasterKey()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
itemsPaths, err := c.getItemPath(profilePath, items)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.masterKey = masterKey
|
||||
c.profilePath = profilePath
|
||||
c.itemPaths = itemsPaths
|
||||
c.items = typeutil.Keys(itemsPaths)
|
||||
return c, err
|
||||
}
|
||||
|
||||
func (c *chromium) GetItems() []item.Item {
|
||||
return c.items
|
||||
}
|
||||
|
||||
func (c *chromium) GetItemPaths() map[item.Item]string {
|
||||
return c.itemPaths
|
||||
}
|
||||
|
||||
func (c *chromium) GetName() string {
|
||||
func (c *chromium) Name() string {
|
||||
return c.name
|
||||
}
|
||||
|
||||
@@ -65,6 +52,13 @@ func (c *chromium) GetBrowsingData() (*browingdata.Data, error) {
|
||||
if err := c.copyItemToLocal(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
masterKey, err := c.GetMasterKey()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
c.masterKey = masterKey
|
||||
if err := b.Recovery(c.masterKey); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -4,13 +4,18 @@ import (
|
||||
"bytes"
|
||||
"crypto/sha1"
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/crypto/pbkdf2"
|
||||
|
||||
"hack-browser-data/internal/item"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrWrongSecurityCommand = errors.New("macOS wrong security command")
|
||||
ErrWrongSecurityCommand = errors.New("macOS wrong security command")
|
||||
ErrCouldNotFindInKeychain = errors.New("macOS could not find in keychain")
|
||||
)
|
||||
|
||||
func (c *chromium) GetMasterKey() ([]byte, error) {
|
||||
@@ -18,6 +23,10 @@ func (c *chromium) GetMasterKey() ([]byte, error) {
|
||||
cmd *exec.Cmd
|
||||
stdout, stderr bytes.Buffer
|
||||
)
|
||||
// don't need chromium key file for macOS
|
||||
defer os.Remove(item.TempChromiumKey)
|
||||
// defer os.Remove(item.TempChromiumKey)
|
||||
// Get the master key from the keychain
|
||||
// $ security find-generic-password -wa 'Chrome'
|
||||
cmd = exec.Command("security", "find-generic-password", "-wa", c.storage)
|
||||
cmd.Stdout = &stdout
|
||||
@@ -27,6 +36,9 @@ func (c *chromium) GetMasterKey() ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
if stderr.Len() > 0 {
|
||||
if strings.Contains(stderr.String(), "could not be found") {
|
||||
return nil, ErrCouldNotFindInKeychain
|
||||
}
|
||||
return nil, errors.New(stderr.String())
|
||||
}
|
||||
chromeSecret := bytes.TrimSpace(stdout.Bytes())
|
||||
|
||||
Reference in New Issue
Block a user