From 5f0e15788032951f215bda1df3b5ce1e55125f59 Mon Sep 17 00:00:00 2001 From: s Date: Thu, 6 Nov 2025 22:15:35 -0500 Subject: feat: add breachforum search command with api client integration --- cmd/osint.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'cmd/osint.go') diff --git a/cmd/osint.go b/cmd/osint.go index 13c3c6e..49b94ab 100644 --- a/cmd/osint.go +++ b/cmd/osint.go @@ -32,10 +32,19 @@ var osintBSSIDCmd = &cobra.Command{ RunE: runOsintBSSIDLookup, } +var osintBreachForumCmd = &cobra.Command{ + Use: "breachforum [search]", + Short: "Search BreachForum data", + Long: `Search breachdetect index for BreachForum messages and detections`, + Args: cobra.ExactArgs(1), + RunE: runOsintBreachForumSearch, +} + func init() { rootCmd.AddCommand(osintCmd) osintCmd.AddCommand(osintUsernameCmd) osintCmd.AddCommand(osintBSSIDCmd) + osintCmd.AddCommand(osintBreachForumCmd) osintUsernameCmd.Flags().StringSliceP("sites", "s", []string{}, "Specific sites to check (comma-separated)") osintUsernameCmd.Flags().BoolP("fuzzy", "f", false, "Enable fuzzy validation mode") @@ -44,6 +53,8 @@ func init() { osintBSSIDCmd.Flags().BoolP("all", "a", false, "Show all related results instead of exact match only") osintBSSIDCmd.Flags().BoolP("google", "g", false, "Include Google Maps URL for the location") osintBSSIDCmd.Flags().BoolP("osm", "o", false, "Include OpenStreetMap URL for the location") + + osintBreachForumCmd.Flags().IntP("max_hits", "m", 10, "Maximum number of hits to return") } func runOsintUsernameCheck(cmd *cobra.Command, args []string) error { @@ -103,3 +114,31 @@ func runOsintBSSIDLookup(cmd *cobra.Command, args []string) error { fmt.Println(string(output)) return nil } + +func runOsintBreachForumSearch(cmd *cobra.Command, args []string) error { + apiKey, _ := cmd.Flags().GetString("api-key") + cfg := config.New().WithAPIKey(apiKey) + + c, err := client.New(cfg) + if err != nil { + return err + } + + params := &models.BreachForumSearchParams{ + Search: args[0], + } + params.MaxHits, _ = cmd.Flags().GetInt("max_hits") + + response, err := c.SearchBreachForum(params) + if err != nil { + return err + } + + output, err := json.MarshalIndent(response, "", " ") + if err != nil { + return fmt.Errorf("failed to format response: %w", err) + } + + fmt.Println(string(output)) + return nil +} -- cgit v1.2.3