Files
HackBrowserData/cmd/hack-browser-data/dumpkeys.go
T
Roger 8ce917d57e fix: write keys.json atomically, unify zip handling (#686)
dumpkeys truncated keys.json before writing it, so a failed write left a partial file; app now writes it through the
same temp-file-and-rename path zips use. Unzipping moves next to zip writing and checks entries with filepath.IsLocal.
2026-11-09 17:25:35 +08:00

41 lines
1.1 KiB
Go

package main
import (
"github.com/spf13/cobra"
"github.com/moond4rk/hackbrowserdata/internal/app"
"github.com/moond4rk/hackbrowserdata/internal/log"
)
func newDumpKeysCommand() *cobra.Command {
var (
flags app.Flags
outputPath string
)
command := &cobra.Command{
Use: "dumpkeys",
Short: "Export Chromium master keys as JSON for cross-host decryption",
Example: ` hack-browser-data dumpkeys -o keys.json
hack-browser-data dumpkeys -b chrome`,
RunE: func(command *cobra.Command, args []string) error {
options, err := app.ValidateDumpKeys(flags)
if err != nil {
return err
}
vaultCount, err := app.DumpKeys(command.Context(), app.Discover(options), options, outputPath)
if err != nil {
return err
}
log.Infof("Exported keys for %d vault(s)", vaultCount)
return nil
},
}
command.Flags().StringVarP(&flags.Browser, "browser", "b", "all", "target browser: all|"+browserNames())
command.Flags().StringVarP(&outputPath, "output", "o", "", "output file (default: stdout)")
addKeychainPasswordFlags(command, &flags)
return command
}