mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-04 05:43:27 +01:00
Profiles protected by a Firefox primary password could not be decrypted; --firefox-pw and --firefox-pw-stdin supply it, read once per run, and new 48-byte NSS salts hash with SHA-384. Closes #109
63 lines
2.3 KiB
Go
63 lines
2.3 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/moond4rk/hackbrowserdata/internal/app"
|
|
)
|
|
|
|
func newDumpCommand() *cobra.Command {
|
|
var (
|
|
flags app.DumpFlags
|
|
keychain keychainFlags
|
|
firefox firefoxFlags
|
|
)
|
|
|
|
command := &cobra.Command{
|
|
Use: "dump",
|
|
Short: "Extract and decrypt browser data (default command)",
|
|
Example: ` hack-browser-data dump
|
|
hack-browser-data dump -b chrome -c password,cookie
|
|
hack-browser-data dump -b chrome -f json -d output
|
|
hack-browser-data dump -f cookie-editor
|
|
hack-browser-data dump --zip`,
|
|
RunE: func(command *cobra.Command, args []string) error {
|
|
return runDump(command.Context(), command.ErrOrStderr(), flags, keychain, firefox)
|
|
},
|
|
}
|
|
|
|
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(&flags.Format, "format", "f", "json", "output format: csv|json|cookie-editor")
|
|
command.Flags().StringVarP(&flags.OutputDir, "dir", "d", "results", "output directory")
|
|
command.Flags().StringVarP(&flags.ProfilePath, "profile-path", "p", "", "custom profile dir path, get with chrome://version")
|
|
addKeychainPasswordFlags(command, &keychain)
|
|
addFirefoxPasswordFlags(command, &firefox)
|
|
command.Flags().BoolVar(&flags.Zip, "zip", false, "compress output to zip")
|
|
command.Flags().IntVar(&flags.MaxStorageValue, "max-storage-value", app.DefaultMaxStorageValue, "max storage value chars, 0=unlimited")
|
|
command.MarkFlagsMutuallyExclusive("keychain-pw-stdin", "firefox-pw-stdin")
|
|
|
|
return command
|
|
}
|
|
|
|
func runDump(ctx context.Context, stderr io.Writer, flags app.DumpFlags, keychain keychainFlags, firefox firefoxFlags) error {
|
|
options, err := app.ValidateDump(flags, keychainPasswordFunc(keychain, os.Stdin), firefoxPasswordFunc(firefox, os.Stdin))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
discovery := app.Discover(ctx, options.Target)
|
|
if warnIfNothingFound(stderr, discovery, "no browsers found") {
|
|
return nil
|
|
}
|
|
summary, err := app.Execute(ctx, discovery, options.Categories, options.Output, options.Keychain, options.FirefoxPassword)
|
|
announceExport(stderr, summary.Exported)
|
|
if ctx.Err() == nil {
|
|
report(stderr, summary)
|
|
}
|
|
return err
|
|
}
|