feat(firefox): decrypt profiles with a primary password (#704)

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
This commit is contained in:
Roger authored and GitHub committed 2026-11-19 16:51:00 +08:00
1 parent c733ac9d6d
commit b14b2c021a
15 files changed
+332 -69

No files matched your search

+7 -4
View File
@@ -14,6 +14,7 @@ func newDumpCommand() *cobra.Command {
var (
flags app.DumpFlags
keychain keychainFlags
firefox firefoxFlags
)
command := &cobra.Command{
@@ -25,7 +26,7 @@ func newDumpCommand() *cobra.Command {
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)
return runDump(command.Context(), command.ErrOrStderr(), flags, keychain, firefox)
},
}
@@ -35,14 +36,16 @@ func newDumpCommand() *cobra.Command {
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) error {
options, err := app.ValidateDump(flags, keychainPasswordFunc(keychain, os.Stdin))
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
}
@@ -50,7 +53,7 @@ func runDump(ctx context.Context, stderr io.Writer, flags app.DumpFlags, keychai
if warnIfNothingFound(stderr, discovery, "no browsers found") {
return nil
}
summary, err := app.Execute(ctx, discovery, options.Categories, options.Output, options.Keychain)
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)