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.
118 lines
3.5 KiB
118 lines
3.5 KiB
1 year ago
|
package browsingdata
|
||
3 years ago
|
|
||
3 years ago
|
import (
|
||
3 years ago
|
"path"
|
||
3 years ago
|
|
||
1 year ago
|
"github.com/moond4rk/hackbrowserdata/browsingdata/bookmark"
|
||
|
"github.com/moond4rk/hackbrowserdata/browsingdata/cookie"
|
||
|
"github.com/moond4rk/hackbrowserdata/browsingdata/creditcard"
|
||
|
"github.com/moond4rk/hackbrowserdata/browsingdata/download"
|
||
|
"github.com/moond4rk/hackbrowserdata/browsingdata/extension"
|
||
|
"github.com/moond4rk/hackbrowserdata/browsingdata/history"
|
||
|
"github.com/moond4rk/hackbrowserdata/browsingdata/localstorage"
|
||
|
"github.com/moond4rk/hackbrowserdata/browsingdata/password"
|
||
|
"github.com/moond4rk/hackbrowserdata/browsingdata/sessionstorage"
|
||
2 years ago
|
"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
|
|
||
2 years ago
|
Len() int
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
2 years ago
|
func New(items []item.Item) *Data {
|
||
3 years ago
|
bd := &Data{
|
||
3 years ago
|
sources: make(map[item.Item]Source),
|
||
3 years ago
|
}
|
||
2 years ago
|
bd.addSources(items)
|
||
3 years ago
|
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) {
|
||
2 years ago
|
output := newOutPutter(flag)
|
||
3 years ago
|
|
||
3 years ago
|
for _, source := range d.sources {
|
||
2 years ago
|
if source.Len() == 0 {
|
||
3 years ago
|
// 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))
|
||
|
}
|
||
|
}
|
||
|
|
||
2 years ago
|
func (d *Data) addSources(items []item.Item) {
|
||
|
for _, source := range items {
|
||
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{}
|
||
2 years ago
|
case item.ChromiumSessionStorage:
|
||
|
d.sources[source] = &sessionstorage.ChromiumSessionStorage{}
|
||
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
|
}
|
||
|
}
|
||
|
}
|