mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-06-10 20:07:46 +02:00
feat(cli): add archive command for cross-host data transport (#610)
* feat(cli): add archive command for cross-host data transport * fix(archive): correct flat-layout path and entry-count wording * refactor(archive): rename BuildArchive to WriteArchive
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/moond4rk/hackbrowserdata/browser"
|
||||
"github.com/moond4rk/hackbrowserdata/log"
|
||||
)
|
||||
|
||||
func archiveCmd() *cobra.Command {
|
||||
var (
|
||||
browserName string
|
||||
category string
|
||||
outputPath string
|
||||
)
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "archive",
|
||||
Short: "Pack decryption-relevant profile files into a zip for cross-host restore",
|
||||
Example: ` hack-browser-data archive
|
||||
hack-browser-data archive -b chrome -c cookie -o chrome-cookies.zip`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
browsers, err := browser.DiscoverBrowsers(browser.DiscoverOptions{Name: browserName})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(browsers) == 0 {
|
||||
log.Warnf("no browsers found")
|
||||
return nil
|
||||
}
|
||||
categories, err := parseCategories(category)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
n, err := browser.WriteArchive(browsers, categories, outputPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Infof("Archived %d entries to %s", n, outputPath)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().StringVarP(&browserName, "browser", "b", "all", "target browser: all|"+browser.Names())
|
||||
cmd.Flags().StringVarP(&category, "category", "c", "all", "data categories (comma-separated): all|"+categoryNames())
|
||||
cmd.Flags().StringVarP(&outputPath, "output", "o", "browser-data.zip", "output archive of decryption-relevant browser files")
|
||||
|
||||
return cmd
|
||||
}
|
||||
Reference in New Issue
Block a user