summaryrefslogtreecommitdiffstats
path: root/cmd/shortlinks.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/shortlinks.go')
-rw-r--r--cmd/shortlinks.go48
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())
+}