diff options
| author | s <[email protected]> | 2025-11-13 22:25:02 -0500 |
|---|---|---|
| committer | s <[email protected]> | 2025-11-13 22:25:02 -0500 |
| commit | 07662d9403eb85b39e1ffcf91014bbf36efd1c5a (patch) | |
| tree | 1181435223899bae039a947c5fc4fdeec085f91b /cmd/shortlinks.go | |
| parent | 239936e87183a10a33ce593709eb16c92a04af98 (diff) | |
| download | dborg-1.0.1.tar.gz dborg-1.0.1.zip | |
refactor: break down large osint.go file into separate command modules and add helper functionsv1.0.1
Diffstat (limited to 'cmd/shortlinks.go')
| -rw-r--r-- | cmd/shortlinks.go | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/cmd/shortlinks.go b/cmd/shortlinks.go new file mode 100644 index 0000000..0621da6 --- /dev/null +++ b/cmd/shortlinks.go @@ -0,0 +1,48 @@ +package cmd + +import ( + "git.db.org.ai/dborg/internal/formatter" + "git.db.org.ai/dborg/internal/models" + "github.com/spf13/cobra" +) + +var shortlinksCmd = &cobra.Command{ + Use: "shortlinks", + Short: "Search brute forced short links", + Long: `Search for exposed URLs discovered through brute forcing URL shortener services`, + RunE: runShortlinksSearch, +} + +func init() { + rootCmd.AddCommand(shortlinksCmd) + shortlinksCmd.Flags().StringP("keywords", "w", "", "Search keywords") + shortlinksCmd.Flags().StringP("ext", "e", "", "File extensions (comma-separated, e.g. 'pdf,docx,xlsx')") + shortlinksCmd.Flags().StringP("order", "o", "", "Sort by property (size, timestamp)") + shortlinksCmd.Flags().StringP("direction", "d", "", "Sort direction (asc, desc)") + shortlinksCmd.Flags().BoolP("regexp", "r", false, "Treat keywords as regular expression") + shortlinksCmd.Flags().IntP("limit", "l", 100, "Number of results to return") + shortlinksCmd.Flags().IntP("start", "t", 0, "Starting offset for pagination") +} + +func runShortlinksSearch(cmd *cobra.Command, args []string) error { + c, err := newClient() + if err != nil { + return err + } + + params := &models.ShortlinksSearchParams{} + params.Keywords, _ = cmd.Flags().GetString("keywords") + params.Ext, _ = cmd.Flags().GetString("ext") + params.Order, _ = cmd.Flags().GetString("order") + params.Direction, _ = cmd.Flags().GetString("direction") + params.Regexp, _ = cmd.Flags().GetBool("regexp") + params.Limit, _ = cmd.Flags().GetInt("limit") + params.Start, _ = cmd.Flags().GetInt("start") + + response, err := c.SearchShortlinks(params) + if err != nil { + return err + } + + return formatter.FormatShortlinksResults(response, IsJSONOutput()) +} |
