From 353503f90fad194345a68157c917d9e04a3432fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=8D=E1=B4=8F=E1=B4=8F=C9=B4D4=CA=80=E1=B4=8B?= Date: Sat, 30 Apr 2022 00:37:23 +0800 Subject: [PATCH] feat: support extension for firefox --- cmd/hack-browser-data/main.go | 2 +- internal/browingdata/browsingdata.go | 2 ++ internal/browingdata/extension/extension.go | 24 +++++++++++++++++++++ internal/item/filename.go | 3 ++- internal/item/item.go | 6 +++--- 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/cmd/hack-browser-data/main.go b/cmd/hack-browser-data/main.go index d08a7fc..bfc53fc 100644 --- a/cmd/hack-browser-data/main.go +++ b/cmd/hack-browser-data/main.go @@ -29,7 +29,7 @@ func Execute() { Name: "hack-browser-data", Usage: "Export passwords/cookies/history/bookmarks from browser", UsageText: "[hack-browser-data -b chrome -f json -dir results -cc]\nExport all browingdata(password/cookie/history/bookmark) from browser\nGithub Link: https://github.com/moonD4rk/HackBrowserData", - Version: "0.4.1", + Version: "0.4.2", Flags: []cli.Flag{ &cli.BoolFlag{Name: "verbose", Aliases: []string{"vv"}, Destination: &verbose, Value: false, Usage: "verbose"}, &cli.BoolFlag{Name: "compress", Aliases: []string{"zip"}, Destination: &compress, Value: false, Usage: "compress result to zip"}, diff --git a/internal/browingdata/browsingdata.go b/internal/browingdata/browsingdata.go index 53cddec..01024a4 100644 --- a/internal/browingdata/browsingdata.go +++ b/internal/browingdata/browsingdata.go @@ -97,6 +97,8 @@ func (d *Data) addSource(Sources []item.Item) { d.sources[source] = &download.FirefoxDownload{} case item.FirefoxLocalStorage: d.sources[source] = &localstorage.FirefoxLocalStorage{} + case item.FirefoxExtension: + d.sources[source] = &extension.FirefoxExtension{} } } } diff --git a/internal/browingdata/extension/extension.go b/internal/browingdata/extension/extension.go index 7712560..ecc8261 100644 --- a/internal/browingdata/extension/extension.go +++ b/internal/browingdata/extension/extension.go @@ -49,3 +49,27 @@ func (c *ChromiumExtension) Parse(masterKey []byte) error { func (c *ChromiumExtension) Name() string { return "extension" } + +type FirefoxExtension []*extension + +func (f *FirefoxExtension) Parse(masterKey []byte) error { + s, err := fileutil.ReadFile(item.TempFirefoxExtension) + if err != nil { + return err + } + defer os.Remove(item.TempFirefoxExtension) + j := gjson.Parse(s) + for _, v := range j.Get("addons").Array() { + *f = append(*f, &extension{ + Name: v.Get("defaultLocale.name").String(), + Description: v.Get("defaultLocale.description").String(), + Version: v.Get("version").String(), + HomepageURL: v.Get("defaultLocale.homepageURL").String(), + }) + } + return nil +} + +func (f *FirefoxExtension) Name() string { + return "extension" +} diff --git a/internal/item/filename.go b/internal/item/filename.go index 3077702..8810f53 100644 --- a/internal/item/filename.go +++ b/internal/item/filename.go @@ -20,6 +20,7 @@ const ( fileFirefoxPassword = "logins.json" fileFirefoxData = "places.sqlite" fileFirefoxLocalStorage = "webappsstore.sqlite" + fileFirefoxExtension = "extensions.json" ) const ( @@ -49,5 +50,5 @@ const ( TempFirefoxDownload = "firefoxDownload" TempFirefoxLocalStorage = "firefoxLocalStorage" TempFirefoxCreditCard = "" - TempFirefoxExtension = "" + TempFirefoxExtension = "firefoxExtension" ) diff --git a/internal/item/item.go b/internal/item/item.go index b39f8a0..671cb0e 100644 --- a/internal/item/item.go +++ b/internal/item/item.go @@ -63,11 +63,11 @@ func (i Item) FileName() string { return fileFirefoxData case FirefoxLocalStorage: return fileFirefoxLocalStorage - case FirefoxCreditCard: - return UnsupportedItem case FirefoxHistory: return fileFirefoxData case FirefoxExtension: + return fileFirefoxExtension + case FirefoxCreditCard: return UnsupportedItem default: return UnknownItem @@ -115,7 +115,7 @@ func (i Item) String() string { case FirefoxCreditCard: return UnsupportedItem case FirefoxExtension: - return UnsupportedItem + return TempFirefoxExtension default: return UnknownItem }