summaryrefslogtreecommitdiffstats
path: root/cmd/files.go
diff options
context:
space:
mode:
authors <[email protected]>2025-11-13 22:25:02 -0500
committers <[email protected]>2025-11-13 22:25:02 -0500
commit07662d9403eb85b39e1ffcf91014bbf36efd1c5a (patch)
tree1181435223899bae039a947c5fc4fdeec085f91b /cmd/files.go
parent239936e87183a10a33ce593709eb16c92a04af98 (diff)
downloaddborg-07662d9403eb85b39e1ffcf91014bbf36efd1c5a.tar.gz
dborg-07662d9403eb85b39e1ffcf91014bbf36efd1c5a.zip
refactor: break down large osint.go file into separate command modules and add helper functionsv1.0.1
Diffstat (limited to 'cmd/files.go')
-rw-r--r--cmd/files.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/cmd/files.go b/cmd/files.go
new file mode 100644
index 0000000..6ce818c
--- /dev/null
+++ b/cmd/files.go
@@ -0,0 +1,47 @@
+package cmd
+
+import (
+ "git.db.org.ai/dborg/internal/formatter"
+ "git.db.org.ai/dborg/internal/models"
+ "github.com/spf13/cobra"
+)
+
+var filesCmd = &cobra.Command{
+ Use: "files [url]",
+ Short: "Search open directory files",
+ Long: `Search for files in open directories using various filters (free OSINT endpoint)`,
+ Args: cobra.ExactArgs(1),
+ RunE: runFilesSearch,
+}
+
+func init() {
+ rootCmd.AddCommand(filesCmd)
+ filesCmd.Flags().StringP("filename", "n", "", "Search term to match in filenames")
+ filesCmd.Flags().StringP("extension", "e", "", "Filter by file extension(s) - comma-separated (e.g., pdf,doc,txt)")
+ filesCmd.Flags().StringP("exclude", "x", "html,HTML", "Exclude file extension(s) - comma-separated")
+ filesCmd.Flags().IntP("size", "s", 10, "Number of results to return (max 40)")
+ filesCmd.Flags().IntP("from", "f", 0, "Starting offset for pagination")
+}
+
+func runFilesSearch(cmd *cobra.Command, args []string) error {
+ c, err := newUnauthenticatedClient()
+ if err != nil {
+ return err
+ }
+
+ params := &models.OpenDirectorySearchParams{
+ URL: args[0],
+ }
+ params.Filename, _ = cmd.Flags().GetString("filename")
+ params.Extension, _ = cmd.Flags().GetString("extension")
+ params.Exclude, _ = cmd.Flags().GetString("exclude")
+ params.Size, _ = cmd.Flags().GetInt("size")
+ params.From, _ = cmd.Flags().GetInt("from")
+
+ response, err := c.SearchOpenDirectoryFiles(params)
+ if err != nil {
+ return err
+ }
+
+ return formatter.FormatFilesResults(*response, IsJSONOutput())
+}