mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-04 05:43:27 +01:00
Names say what each thing is: no package stutter, one word per concept, spelled out, none that differ only in case. The browser table puts one field per line. Wire names (flags, output fields, keys.json) are unchanged.
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/moond4rk/hackbrowserdata/internal/app"
|
|
"github.com/moond4rk/hackbrowserdata/internal/log"
|
|
)
|
|
|
|
func newArchiveCommand() *cobra.Command {
|
|
var (
|
|
flags app.Flags
|
|
outputPath string
|
|
)
|
|
|
|
command := &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(command *cobra.Command, args []string) error {
|
|
options, err := app.ValidateArchive(flags)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
discovery := app.Discover(options)
|
|
if len(discovery.Dirs) == 0 {
|
|
log.Warnf("no browsers found")
|
|
return nil
|
|
}
|
|
fileCount, err := app.Archive(command.Context(), discovery, options, outputPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log.Infof("Archived %d entries to %s", fileCount, outputPath)
|
|
return nil
|
|
},
|
|
}
|
|
|
|
command.Flags().StringVarP(&flags.Browser, "browser", "b", "all", "target browser: all|"+browserNames())
|
|
command.Flags().StringVarP(&flags.Categories, "category", "c", "all", "data categories (comma-separated): all|"+categoryNames())
|
|
command.Flags().StringVarP(&outputPath, "output", "o", "browser-data.zip", "output archive of decryption-relevant browser files")
|
|
|
|
return command
|
|
}
|