You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HackBrowserData/internal/browingdata/browsingdata.go

95 lines
2.4 KiB

package browingdata
import (
"path"
"hack-browser-data/internal/browingdata/bookmark"
"hack-browser-data/internal/browingdata/cookie"
"hack-browser-data/internal/browingdata/creditcard"
"hack-browser-data/internal/browingdata/download"
"hack-browser-data/internal/browingdata/history"
"hack-browser-data/internal/browingdata/password"
"hack-browser-data/internal/item"
3 years ago
"hack-browser-data/internal/log"
"hack-browser-data/internal/utils/fileutil"
)
type Data struct {
Sources map[item.Item]Source
}
type Source interface {
Parse(masterKey []byte) error
Name() string
}
func New(sources []item.Item) *Data {
bd := &Data{
Sources: make(map[item.Item]Source),
}
bd.addSource(sources)
return bd
}
func (d *Data) Recovery(masterKey []byte) error {
for _, source := range d.Sources {
if err := source.Parse(masterKey); err != nil {
3 years ago
log.Error(err)
}
}
return nil
}
func (d *Data) Output(dir, browserName, flag string) {
output := NewOutPutter(flag)
for _, source := range d.Sources {
filename := fileutil.Filename(browserName, source.Name(), output.Ext())
f, err := output.CreateFile(dir, filename)
if err != nil {
log.Error(err)
}
if err := output.Write(source, f); err != nil {
log.Error(err)
}
log.Noticef("output to file %s success", path.Join(dir, filename))
}
}
func (d *Data) addSource(Sources []item.Item) {
for _, source := range Sources {
switch source {
case item.ChromiumPassword:
d.Sources[source] = &password.ChromiumPassword{}
case item.ChromiumCookie:
d.Sources[source] = &cookie.ChromiumCookie{}
case item.ChromiumBookmark:
d.Sources[source] = &bookmark.ChromiumBookmark{}
case item.ChromiumHistory:
d.Sources[source] = &history.ChromiumHistory{}
case item.ChromiumDownload:
d.Sources[source] = &download.ChromiumDownload{}
case item.ChromiumCreditCard:
d.Sources[source] = &creditcard.ChromiumCreditCard{}
case item.YandexPassword:
d.Sources[source] = &password.YandexPassword{}
case item.YandexCreditCard:
d.Sources[source] = &creditcard.YandexCreditCard{}
case item.FirefoxPassword:
d.Sources[source] = &password.FirefoxPassword{}
case item.FirefoxCookie:
d.Sources[source] = &cookie.FirefoxCookie{}
case item.FirefoxBookmark:
d.Sources[source] = &bookmark.FirefoxBookmark{}
case item.FirefoxHistory:
d.Sources[source] = &history.FirefoxHistory{}
case item.FirefoxDownload:
d.Sources[source] = &download.FirefoxDownload{}
}
}
}