summaryrefslogtreecommitdiffstats
path: root/cmd/osint.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/osint.go')
-rw-r--r--cmd/osint.go103
1 files changed, 103 insertions, 0 deletions
diff --git a/cmd/osint.go b/cmd/osint.go
new file mode 100644
index 0000000..2f1f427
--- /dev/null
+++ b/cmd/osint.go
@@ -0,0 +1,103 @@
+package cmd
+
+import (
+ "dborg/internal/client"
+ "dborg/internal/config"
+ "dborg/internal/models"
+ "encoding/json"
+ "fmt"
+
+ "github.com/spf13/cobra"
+)
+
+var osintCmd = &cobra.Command{
+ Use: "osint",
+ Short: "OSINT tools and searches",
+ Long: `Open Source Intelligence tools for username, email, and other searches`,
+}
+
+var osintUsernameCmd = &cobra.Command{
+ Use: "username [username]",
+ Short: "Check username availability across websites",
+ Long: `Check username availability across hundreds of websites using WhatsMyName dataset`,
+ Args: cobra.ExactArgs(1),
+ RunE: runOsintUsernameCheck,
+}
+
+var osintBSSIDCmd = &cobra.Command{
+ Use: "bssid [bssid]",
+ Short: "Lookup WiFi access point location by BSSID",
+ Long: `Lookup geographic location of a WiFi access point by its BSSID (MAC address) using Apple's location services`,
+ Args: cobra.ExactArgs(1),
+ RunE: runOsintBSSIDLookup,
+}
+
+func init() {
+ rootCmd.AddCommand(osintCmd)
+ osintCmd.AddCommand(osintUsernameCmd)
+ osintCmd.AddCommand(osintBSSIDCmd)
+
+ osintUsernameCmd.Flags().StringSliceP("sites", "s", []string{}, "Specific sites to check (comma-separated)")
+ osintUsernameCmd.Flags().BoolP("fuzzy", "f", false, "Enable fuzzy validation mode")
+ osintUsernameCmd.Flags().IntP("max_tasks", "m", 50, "Maximum concurrent tasks")
+
+ osintBSSIDCmd.Flags().BoolP("all", "a", false, "Show all related results instead of exact match only")
+ osintBSSIDCmd.Flags().BoolP("map", "m", false, "Include Google Maps URL for the location")
+}
+
+func runOsintUsernameCheck(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.USRSXParams{
+ Username: args[0],
+ }
+ params.Sites, _ = cmd.Flags().GetStringSlice("sites")
+ params.Fuzzy, _ = cmd.Flags().GetBool("fuzzy")
+ params.MaxTasks, _ = cmd.Flags().GetInt("max_tasks")
+
+ err = c.CheckUsernameStream(params, func(result json.RawMessage) error {
+ fmt.Println(string(result))
+ return nil
+ })
+
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func runOsintBSSIDLookup(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.BSSIDParams{
+ BSSID: args[0],
+ }
+ params.All, _ = cmd.Flags().GetBool("all")
+ params.Map, _ = cmd.Flags().GetBool("map")
+
+ response, err := c.LookupBSSID(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
+}