mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-07-04 21:37:47 +02:00
feat: remove export item selection, default select all items
This commit is contained in:
+6
-7
@@ -12,7 +12,6 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
browser string
|
browser string
|
||||||
exportData string
|
|
||||||
exportDir string
|
exportDir string
|
||||||
outputFormat string
|
outputFormat string
|
||||||
verbose bool
|
verbose bool
|
||||||
@@ -23,18 +22,16 @@ func Execute() {
|
|||||||
app := &cli.App{
|
app := &cli.App{
|
||||||
Name: "hack-browser-data",
|
Name: "hack-browser-data",
|
||||||
Usage: "Export passwords/cookies/history/bookmarks from browser",
|
Usage: "Export passwords/cookies/history/bookmarks from browser",
|
||||||
UsageText: "[hack-browser-data -b chrome -f json -dir results -e all -cc]\n Get all data(password/cookie/history/bookmark) from chrome",
|
UsageText: "[hack-browser-data -b chrome -f json -dir results -cc]\n Get all data(password/cookie/history/bookmark) from chrome",
|
||||||
Version: "0.2.2",
|
Version: "0.2.3",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.BoolFlag{Name: "verbose", Aliases: []string{"vv"}, Destination: &verbose, Value: false, Usage: "Verbose"},
|
&cli.BoolFlag{Name: "verbose", Aliases: []string{"vv"}, Destination: &verbose, Value: false, Usage: "Verbose"},
|
||||||
&cli.BoolFlag{Name: "compress", Aliases: []string{"cc"}, Destination: &compress, Value: false, Usage: "Compress result to zip"},
|
&cli.BoolFlag{Name: "compress", Aliases: []string{"cc"}, Destination: &compress, Value: false, Usage: "Compress result to zip"},
|
||||||
&cli.StringFlag{Name: "browser", Aliases: []string{"b"}, Destination: &browser, Value: "all", Usage: "Available browsers: all|" + strings.Join(core.ListBrowser(), "|")},
|
&cli.StringFlag{Name: "browser", Aliases: []string{"b"}, Destination: &browser, Value: "all", Usage: "Available browsers: all|" + strings.Join(core.ListBrowser(), "|")},
|
||||||
&cli.StringFlag{Name: "results-dir", Aliases: []string{"dir"}, Destination: &exportDir, Value: "results", Usage: "Export dir"},
|
&cli.StringFlag{Name: "results-dir", Aliases: []string{"dir"}, Destination: &exportDir, Value: "results", Usage: "Export dir"},
|
||||||
&cli.StringFlag{Name: "format", Aliases: []string{"f"}, Destination: &outputFormat, Value: "json", Usage: "Format, csv|json|console"},
|
&cli.StringFlag{Name: "format", Aliases: []string{"f"}, Destination: &outputFormat, Value: "json", Usage: "Format, csv|json|console"},
|
||||||
&cli.StringFlag{Name: "export-data", Aliases: []string{"e"}, Destination: &exportData, Value: "all", Usage: "all|" + strings.Join(core.ListItem(), "|")},
|
|
||||||
},
|
},
|
||||||
HideHelpCommand: true,
|
HideHelpCommand: true,
|
||||||
HideVersion: true,
|
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
if verbose {
|
if verbose {
|
||||||
log.InitLog("debug")
|
log.InitLog("debug")
|
||||||
@@ -55,14 +52,16 @@ func Execute() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
items, err := browser.GetAllItems(exportData)
|
// default select all items
|
||||||
|
// also you can get single item with browser.GetItem(itemName)
|
||||||
|
items, err := browser.GetAllItems()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
name := browser.GetName()
|
name := browser.GetName()
|
||||||
key := browser.GetSecretKey()
|
key := browser.GetSecretKey()
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
err := item.CopyItem()
|
err := item.CopyDB()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
|
|||||||
+46
-41
@@ -27,8 +27,11 @@ type Browser interface {
|
|||||||
// GetSecretKey return browser secret key
|
// GetSecretKey return browser secret key
|
||||||
GetSecretKey() []byte
|
GetSecretKey() []byte
|
||||||
|
|
||||||
// GetAllItems, default return all of items(password|bookmark|cookie|history)
|
// GetAllItems return all of items (password|bookmark|cookie|history)
|
||||||
GetAllItems(itemName string) ([]common.Item, error)
|
GetAllItems() ([]common.Item, error)
|
||||||
|
|
||||||
|
// GetItem return single one from password|bookmark|cookie|history
|
||||||
|
GetItem(itemName string) (common.Item, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -111,32 +114,33 @@ func (c *Chromium) GetSecretKey() []byte {
|
|||||||
return c.secretKey
|
return c.secretKey
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Chromium) GetAllItems(itemName string) (Items []common.Item, err error) {
|
func (c *Chromium) GetAllItems() (Items []common.Item, err error) {
|
||||||
itemName = strings.ToLower(itemName)
|
|
||||||
var items []common.Item
|
var items []common.Item
|
||||||
if itemName == "all" {
|
for item, choice := range chromiumItems {
|
||||||
for item, choice := range chromiumItems {
|
m, err := utils.GetItemPath(c.profilePath, choice.mainFile)
|
||||||
m, err := utils.GetItemPath(c.profilePath, choice.mainFile)
|
if err != nil {
|
||||||
if err != nil {
|
log.Errorf("%s find %s file failed, ERR:%s", c.name, item, err)
|
||||||
log.Errorf("%s find %s file failed, ERR:%s", c.name, item, err)
|
continue
|
||||||
continue
|
|
||||||
}
|
|
||||||
i := choice.newItem(m, "")
|
|
||||||
log.Debugf("%s find %s File Success", c.name, item)
|
|
||||||
items = append(items, i)
|
|
||||||
}
|
}
|
||||||
} else if item, ok := chromiumItems[itemName]; ok {
|
i := choice.newItem(m, "")
|
||||||
|
log.Debugf("%s find %s File Success", c.name, item)
|
||||||
|
items = append(items, i)
|
||||||
|
}
|
||||||
|
return items, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Chromium) GetItem(itemName string) (common.Item, error) {
|
||||||
|
itemName = strings.ToLower(itemName)
|
||||||
|
if item, ok := chromiumItems[itemName]; ok {
|
||||||
m, err := utils.GetItemPath(c.profilePath, item.mainFile)
|
m, err := utils.GetItemPath(c.profilePath, item.mainFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("%s find %s file failed, ERR:%s", c.name, item.mainFile, err)
|
log.Errorf("%s find %s file failed, ERR:%s", c.name, item.mainFile, err)
|
||||||
}
|
}
|
||||||
i := item.newItem(m, "")
|
i := item.newItem(m, "")
|
||||||
items = append(items, i)
|
return i, nil
|
||||||
return items, nil
|
|
||||||
} else {
|
} else {
|
||||||
return nil, errItemNotSupported
|
return nil, errItemNotSupported
|
||||||
}
|
}
|
||||||
return items, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Firefox struct {
|
type Firefox struct {
|
||||||
@@ -149,32 +153,35 @@ func NewFirefox(profile, key, name string) (Browser, error) {
|
|||||||
return &Firefox{profilePath: profile, keyPath: key, name: name}, nil
|
return &Firefox{profilePath: profile, keyPath: key, name: name}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Firefox) GetAllItems(itemName string) ([]common.Item, error) {
|
func (f *Firefox) GetAllItems() ([]common.Item, error) {
|
||||||
itemName = strings.ToLower(itemName)
|
|
||||||
var items []common.Item
|
var items []common.Item
|
||||||
if itemName == "all" {
|
for item, choice := range firefoxItems {
|
||||||
for item, choice := range firefoxItems {
|
var (
|
||||||
var (
|
sub, main string
|
||||||
sub, main string
|
err error
|
||||||
err error
|
)
|
||||||
)
|
if choice.subFile != "" {
|
||||||
if choice.subFile != "" {
|
sub, err = utils.GetItemPath(f.profilePath, choice.subFile)
|
||||||
sub, err = utils.GetItemPath(f.profilePath, choice.subFile)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("%s find %s file failed, ERR:%s", f.name, item, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
main, err = utils.GetItemPath(f.profilePath, choice.mainFile)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("%s find %s file failed, ERR:%s", f.name, item, err)
|
log.Errorf("%s find %s file failed, ERR:%s", f.name, item, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
i := choice.newItem(main, sub)
|
|
||||||
log.Debugf("%s find %s file success", f.name, item)
|
|
||||||
items = append(items, i)
|
|
||||||
}
|
}
|
||||||
} else if item, ok := firefoxItems[itemName]; ok {
|
main, err = utils.GetItemPath(f.profilePath, choice.mainFile)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("%s find %s file failed, ERR:%s", f.name, item, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
i := choice.newItem(main, sub)
|
||||||
|
log.Debugf("%s find %s file success", f.name, item)
|
||||||
|
items = append(items, i)
|
||||||
|
}
|
||||||
|
return items, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *Firefox) GetItem(itemName string) (common.Item, error) {
|
||||||
|
itemName = strings.ToLower(itemName)
|
||||||
|
if item, ok := firefoxItems[itemName]; ok {
|
||||||
var (
|
var (
|
||||||
sub, main string
|
sub, main string
|
||||||
err error
|
err error
|
||||||
@@ -191,12 +198,10 @@ func (f *Firefox) GetAllItems(itemName string) ([]common.Item, error) {
|
|||||||
}
|
}
|
||||||
i := item.newItem(main, sub)
|
i := item.newItem(main, sub)
|
||||||
log.Debugf("%s find %s file success", f.name, item.mainFile)
|
log.Debugf("%s find %s file success", f.name, item.mainFile)
|
||||||
items = append(items, i)
|
return i, nil
|
||||||
return items, nil
|
|
||||||
} else {
|
} else {
|
||||||
return nil, errItemNotSupported
|
return nil, errItemNotSupported
|
||||||
}
|
}
|
||||||
return items, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Firefox) GetName() string {
|
func (f *Firefox) GetName() string {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ func (c *Chromium) InitSecretKey() error {
|
|||||||
cmd *exec.Cmd
|
cmd *exec.Cmd
|
||||||
stdout, stderr bytes.Buffer
|
stdout, stderr bytes.Buffer
|
||||||
)
|
)
|
||||||
//➜ security find-generic-password -wa 'Chrome'
|
// ➜ security find-generic-password -wa 'Chrome'
|
||||||
cmd = exec.Command("security", "find-generic-password", "-wa", c.name)
|
cmd = exec.Command("security", "find-generic-password", "-wa", c.name)
|
||||||
cmd.Stdout = &stdout
|
cmd.Stdout = &stdout
|
||||||
cmd.Stderr = &stderr
|
cmd.Stderr = &stderr
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (c *Chromium) InitSecretKey() error {
|
func (c *Chromium) InitSecretKey() error {
|
||||||
//what is d-bus @https://dbus.freedesktop.org/
|
// what is d-bus @https://dbus.freedesktop.org/
|
||||||
var chromeSecret []byte
|
var chromeSecret []byte
|
||||||
conn, err := dbus.SessionBus()
|
conn, err := dbus.SessionBus()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ type Item interface {
|
|||||||
// FirefoxParse parse firefox items
|
// FirefoxParse parse firefox items
|
||||||
FirefoxParse() error
|
FirefoxParse() error
|
||||||
|
|
||||||
// OutPut with json or csv
|
// OutPut file name and format type
|
||||||
OutPut(format, browser, dir string) error
|
OutPut(format, browser, dir string) error
|
||||||
|
|
||||||
// Copy item file to local path
|
// CopyDB is copy item db file to current dir
|
||||||
CopyItem() error
|
CopyDB() error
|
||||||
|
|
||||||
// Release item file
|
// Release is delete item db file
|
||||||
Release() error
|
Release() error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ func (b *bookmarks) FirefoxParse() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bookmarks) CopyItem() error {
|
func (b *bookmarks) CopyDB() error {
|
||||||
return utils.CopyDB(b.mainPath, filepath.Base(b.mainPath))
|
return utils.CopyDB(b.mainPath, filepath.Base(b.mainPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ func (c *cookies) FirefoxParse() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cookies) CopyItem() error {
|
func (c *cookies) CopyDB() error {
|
||||||
return utils.CopyDB(c.mainPath, filepath.Base(c.mainPath))
|
return utils.CopyDB(c.mainPath, filepath.Base(c.mainPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,7 +383,7 @@ func (h *historyData) FirefoxParse() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *historyData) CopyItem() error {
|
func (h *historyData) CopyDB() error {
|
||||||
return utils.CopyDB(h.mainPath, filepath.Base(h.mainPath))
|
return utils.CopyDB(h.mainPath, filepath.Base(h.mainPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -526,14 +526,13 @@ func (p *passwords) FirefoxParse() error {
|
|||||||
Password: string(decrypt.PKCS5UnPadding(pwd)),
|
Password: string(decrypt.PKCS5UnPadding(pwd)),
|
||||||
CreateDate: v.CreateDate,
|
CreateDate: v.CreateDate,
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *passwords) CopyItem() error {
|
func (p *passwords) CopyDB() error {
|
||||||
err := utils.CopyDB(p.mainPath, filepath.Base(p.mainPath))
|
err := utils.CopyDB(p.mainPath, filepath.Base(p.mainPath))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
|
|||||||
@@ -84,16 +84,16 @@ func Nss(globalSalt, masterPwd []byte, pbe NssPBE) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func decryptPBE(globalSalt, masterPwd, entrySalt, encrypted []byte) ([]byte, error) {
|
func decryptPBE(globalSalt, masterPwd, entrySalt, encrypted []byte) ([]byte, error) {
|
||||||
//byte[] GLMP; // GlobalSalt + MasterPassword
|
// byte[] GLMP; // GlobalSalt + MasterPassword
|
||||||
//byte[] HP; // SHA1(GLMP)
|
// byte[] HP; // SHA1(GLMP)
|
||||||
//byte[] HPES; // HP + EntrySalt
|
// byte[] HPES; // HP + EntrySalt
|
||||||
//byte[] CHP; // SHA1(HPES)
|
// byte[] CHP; // SHA1(HPES)
|
||||||
//byte[] PES; // EntrySalt completed to 20 bytes by zero
|
// byte[] PES; // EntrySalt completed to 20 bytes by zero
|
||||||
//byte[] PESES; // PES + EntrySalt
|
// byte[] PESES; // PES + EntrySalt
|
||||||
//byte[] k1;
|
// byte[] k1;
|
||||||
//byte[] tk;
|
// byte[] tk;
|
||||||
//byte[] k2;
|
// byte[] k2;
|
||||||
//byte[] k; // final value containing key and iv
|
// byte[] k; // final value containing key and iv
|
||||||
glmp := append(globalSalt, masterPwd...)
|
glmp := append(globalSalt, masterPwd...)
|
||||||
hp := sha1.Sum(glmp)
|
hp := sha1.Sum(glmp)
|
||||||
s := append(hp[:], entrySalt...)
|
s := append(hp[:], entrySalt...)
|
||||||
|
|||||||
@@ -119,16 +119,16 @@ func Nss(globalSalt, masterPwd []byte, pbe NssPBE) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func decryptMeta(globalSalt, masterPwd, entrySalt, encrypted []byte) ([]byte, error) {
|
func decryptMeta(globalSalt, masterPwd, entrySalt, encrypted []byte) ([]byte, error) {
|
||||||
//byte[] GLMP; // GlobalSalt + MasterPassword
|
// byte[] GLMP; // GlobalSalt + MasterPassword
|
||||||
//byte[] HP; // SHA1(GLMP)
|
// byte[] HP; // SHA1(GLMP)
|
||||||
//byte[] HPES; // HP + EntrySalt
|
// byte[] HPES; // HP + EntrySalt
|
||||||
//byte[] CHP; // SHA1(HPES)
|
// byte[] CHP; // SHA1(HPES)
|
||||||
//byte[] PES; // EntrySalt completed to 20 bytes by zero
|
// byte[] PES; // EntrySalt completed to 20 bytes by zero
|
||||||
//byte[] PESES; // PES + EntrySalt
|
// byte[] PESES; // PES + EntrySalt
|
||||||
//byte[] k1;
|
// byte[] k1;
|
||||||
//byte[] tk;
|
// byte[] tk;
|
||||||
//byte[] k2;
|
// byte[] k2;
|
||||||
//byte[] k; // final value conytaining key and iv
|
// byte[] k; // final value conytaining key and iv
|
||||||
glmp := append(globalSalt, masterPwd...)
|
glmp := append(globalSalt, masterPwd...)
|
||||||
hp := sha1.Sum(glmp)
|
hp := sha1.Sum(glmp)
|
||||||
s := append(hp[:], entrySalt...)
|
s := append(hp[:], entrySalt...)
|
||||||
|
|||||||
Reference in New Issue
Block a user