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.
115 lines
3.4 KiB
115 lines
3.4 KiB
3 years ago
|
package browingdata
|
||
3 years ago
|
|
||
3 years ago
|
import (
|
||
3 years ago
|
"path"
|
||
3 years ago
|
|
||
2 years ago
|
"github.com/moond4rk/HackBrowserData/browingdata/bookmark"
|
||
|
"github.com/moond4rk/HackBrowserData/browingdata/cookie"
|
||
|
"github.com/moond4rk/HackBrowserData/browingdata/creditcard"
|
||
|
"github.com/moond4rk/HackBrowserData/browingdata/download"
|
||
|
"github.com/moond4rk/HackBrowserData/browingdata/extension"
|
||
|
"github.com/moond4rk/HackBrowserData/browingdata/history"
|
||
|
"github.com/moond4rk/HackBrowserData/browingdata/localstorage"
|
||
|
"github.com/moond4rk/HackBrowserData/browingdata/password"
|
||
|
"github.com/moond4rk/HackBrowserData/item"
|
||
|
"github.com/moond4rk/HackBrowserData/log"
|
||
|
"github.com/moond4rk/HackBrowserData/utils/fileutil"
|
||
3 years ago
|
)
|
||
3 years ago
|
|
||
3 years ago
|
type Data struct {
|
||
3 years ago
|
sources map[item.Item]Source
|
||
3 years ago
|
}
|
||
|
|
||
|
type Source interface {
|
||
3 years ago
|
Parse(masterKey []byte) error
|
||
|
|
||
|
Name() string
|
||
3 years ago
|
|
||
|
Length() int
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
func New(sources []item.Item) *Data {
|
||
|
bd := &Data{
|
||
3 years ago
|
sources: make(map[item.Item]Source),
|
||
3 years ago
|
}
|
||
|
bd.addSource(sources)
|
||
|
return bd
|
||
|
}
|
||
|
|
||
3 years ago
|
func (d *Data) Recovery(masterKey []byte) error {
|
||
3 years ago
|
for _, source := range d.sources {
|
||
3 years ago
|
if err := source.Parse(masterKey); err != nil {
|
||
3 years ago
|
log.Errorf("parse %s error %s", source.Name(), err.Error())
|
||
3 years ago
|
}
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
3 years ago
|
func (d *Data) Output(dir, browserName, flag string) {
|
||
|
output := NewOutPutter(flag)
|
||
3 years ago
|
|
||
3 years ago
|
for _, source := range d.sources {
|
||
3 years ago
|
if source.Length() == 0 {
|
||
|
// if the length of the export data is 0, then it is not necessary to output
|
||
|
continue
|
||
|
}
|
||
2 years ago
|
filename := fileutil.ItemName(browserName, source.Name(), output.Ext())
|
||
3 years ago
|
|
||
3 years ago
|
f, err := output.CreateFile(dir, filename)
|
||
3 years ago
|
if err != nil {
|
||
2 years ago
|
log.Errorf("create file %s error %s", filename, err.Error())
|
||
|
continue
|
||
3 years ago
|
}
|
||
3 years ago
|
if err := output.Write(source, f); err != nil {
|
||
2 years ago
|
log.Errorf("write to file %s error %s", filename, err.Error())
|
||
|
continue
|
||
|
}
|
||
|
if err := f.Close(); err != nil {
|
||
|
log.Errorf("close file %s error %s", filename, err.Error())
|
||
|
continue
|
||
3 years ago
|
}
|
||
|
log.Noticef("output to file %s success", path.Join(dir, filename))
|
||
|
}
|
||
|
}
|
||
|
|
||
3 years ago
|
func (d *Data) addSource(Sources []item.Item) {
|
||
|
for _, source := range Sources {
|
||
3 years ago
|
switch source {
|
||
|
case item.ChromiumPassword:
|
||
3 years ago
|
d.sources[source] = &password.ChromiumPassword{}
|
||
3 years ago
|
case item.ChromiumCookie:
|
||
3 years ago
|
d.sources[source] = &cookie.ChromiumCookie{}
|
||
3 years ago
|
case item.ChromiumBookmark:
|
||
3 years ago
|
d.sources[source] = &bookmark.ChromiumBookmark{}
|
||
3 years ago
|
case item.ChromiumHistory:
|
||
3 years ago
|
d.sources[source] = &history.ChromiumHistory{}
|
||
3 years ago
|
case item.ChromiumDownload:
|
||
3 years ago
|
d.sources[source] = &download.ChromiumDownload{}
|
||
3 years ago
|
case item.ChromiumCreditCard:
|
||
3 years ago
|
d.sources[source] = &creditcard.ChromiumCreditCard{}
|
||
3 years ago
|
case item.ChromiumLocalStorage:
|
||
|
d.sources[source] = &localstorage.ChromiumLocalStorage{}
|
||
3 years ago
|
case item.ChromiumExtension:
|
||
|
d.sources[source] = &extension.ChromiumExtension{}
|
||
3 years ago
|
case item.YandexPassword:
|
||
3 years ago
|
d.sources[source] = &password.YandexPassword{}
|
||
3 years ago
|
case item.YandexCreditCard:
|
||
3 years ago
|
d.sources[source] = &creditcard.YandexCreditCard{}
|
||
3 years ago
|
case item.FirefoxPassword:
|
||
3 years ago
|
d.sources[source] = &password.FirefoxPassword{}
|
||
3 years ago
|
case item.FirefoxCookie:
|
||
3 years ago
|
d.sources[source] = &cookie.FirefoxCookie{}
|
||
3 years ago
|
case item.FirefoxBookmark:
|
||
3 years ago
|
d.sources[source] = &bookmark.FirefoxBookmark{}
|
||
3 years ago
|
case item.FirefoxHistory:
|
||
3 years ago
|
d.sources[source] = &history.FirefoxHistory{}
|
||
3 years ago
|
case item.FirefoxDownload:
|
||
3 years ago
|
d.sources[source] = &download.FirefoxDownload{}
|
||
3 years ago
|
case item.FirefoxLocalStorage:
|
||
|
d.sources[source] = &localstorage.FirefoxLocalStorage{}
|
||
3 years ago
|
case item.FirefoxExtension:
|
||
|
d.sources[source] = &extension.FirefoxExtension{}
|
||
3 years ago
|
}
|
||
|
}
|
||
|
}
|