|
|
@ -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,10 +114,8 @@ 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 { |
|
|
@ -125,18 +126,21 @@ func (c *Chromium) GetAllItems(itemName string) (Items []common.Item, err error) |
|
|
|
log.Debugf("%s find %s File Success", c.name, item) |
|
|
|
log.Debugf("%s find %s File Success", c.name, item) |
|
|
|
items = append(items, i) |
|
|
|
items = append(items, i) |
|
|
|
} |
|
|
|
} |
|
|
|
} else if item, ok := chromiumItems[itemName]; ok { |
|
|
|
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,10 +153,8 @@ 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 |
|
|
@ -174,7 +176,12 @@ func (f *Firefox) GetAllItems(itemName string) ([]common.Item, error) { |
|
|
|
log.Debugf("%s find %s file success", f.name, item) |
|
|
|
log.Debugf("%s find %s file success", f.name, item) |
|
|
|
items = append(items, i) |
|
|
|
items = append(items, i) |
|
|
|
} |
|
|
|
} |
|
|
|
} else if item, ok := firefoxItems[itemName]; ok { |
|
|
|
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 { |
|
|
|