2021-12-31 08:50:50 +00:00
|
|
|
package browser
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
2022-03-26 06:03:40 +00:00
|
|
|
"hack-browser-data/internal/log"
|
2022-04-02 08:59:34 +00:00
|
|
|
"hack-browser-data/internal/outputter"
|
2021-12-31 08:50:50 +00:00
|
|
|
)
|
|
|
|
|
2022-01-11 10:19:17 +00:00
|
|
|
func TestPickChromium(t *testing.T) {
|
2022-01-16 14:31:51 +00:00
|
|
|
browsers := pickChromium("chrome")
|
|
|
|
log.InitLog("debug")
|
2021-12-31 08:50:50 +00:00
|
|
|
filetype := "json"
|
|
|
|
dir := "result"
|
|
|
|
output := outputter.NewOutPutter(filetype)
|
|
|
|
if err := output.MakeDir("result"); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
for _, b := range browsers {
|
|
|
|
fmt.Printf("%+v\n", b)
|
2022-01-16 14:31:51 +00:00
|
|
|
if err := b.CopyItemFileToLocal(); err != nil {
|
2021-12-31 08:50:50 +00:00
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
masterKey, err := b.GetMasterKey()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
2022-01-16 14:31:51 +00:00
|
|
|
browserName := b.GetName()
|
2021-12-31 08:50:50 +00:00
|
|
|
multiData := b.GetBrowsingData()
|
|
|
|
for _, data := range multiData {
|
|
|
|
if err := data.Parse(masterKey); err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
filename := fmt.Sprintf("%s_%s.%s", browserName, data.Name(), filetype)
|
|
|
|
file, err := output.CreateFile(dir, filename)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if err := output.Write(data, file); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-01-11 10:19:17 +00:00
|
|
|
|
2022-04-01 07:00:56 +00:00
|
|
|
func TestGetChromiumItemAbsPath(t *testing.T) {
|
|
|
|
p := `/Library/Application Support/Google/Chrome/`
|
|
|
|
s, err := getChromiumItemPath(p, defaultChromiumItems)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
fmt.Println(s)
|
|
|
|
}
|
|
|
|
|
2022-03-26 06:03:40 +00:00
|
|
|
func TestPickBrowsers(t *testing.T) {
|
|
|
|
browsers := PickBrowser("all")
|
|
|
|
for _, v := range browsers {
|
|
|
|
fmt.Println(v.GetName())
|
|
|
|
}
|
|
|
|
// filetype := "json"
|
|
|
|
// dir := "result"
|
|
|
|
// output := outputter.NewOutPutter(filetype)
|
|
|
|
}
|
|
|
|
|
2022-01-11 10:19:17 +00:00
|
|
|
func TestPickFirefox(t *testing.T) {
|
2022-01-16 14:31:51 +00:00
|
|
|
browsers := pickFirefox("all")
|
2022-01-11 10:19:17 +00:00
|
|
|
filetype := "json"
|
|
|
|
dir := "result"
|
|
|
|
output := outputter.NewOutPutter(filetype)
|
|
|
|
if err := output.MakeDir("result"); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
for _, b := range browsers {
|
|
|
|
fmt.Printf("%+v\n", b)
|
2022-01-16 14:31:51 +00:00
|
|
|
if err := b.CopyItemFileToLocal(); err != nil {
|
2022-01-11 10:19:17 +00:00
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
masterKey, err := b.GetMasterKey()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
2022-01-16 14:31:51 +00:00
|
|
|
browserName := b.GetName()
|
2022-01-11 10:19:17 +00:00
|
|
|
multiData := b.GetBrowsingData()
|
|
|
|
for _, data := range multiData {
|
|
|
|
if err := data.Parse(masterKey); err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
filename := fmt.Sprintf("%s_%s.%s", browserName, data.Name(), filetype)
|
|
|
|
file, err := output.CreateFile(dir, filename)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if err := output.Write(data, file); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|