|
| 1 | +package cmd |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/spf13/cobra" |
| 5 | + "github.com/h0tak88r/AutoAR/internal/modules/subdomains" |
| 6 | + "github.com/h0tak88r/AutoAR/internal/modules/livehosts" |
| 7 | + "github.com/h0tak88r/AutoAR/internal/modules/cnames" |
| 8 | + "github.com/h0tak88r/AutoAR/internal/modules/tech" |
| 9 | + "github.com/h0tak88r/AutoAR/internal/modules/ports" |
| 10 | + "github.com/h0tak88r/AutoAR/internal/modules/urls" |
| 11 | +) |
| 12 | + |
| 13 | +var ( |
| 14 | + subdomainsCmd = &cobra.Command{ |
| 15 | + Use: "subdomains", |
| 16 | + Short: "Enumerate subdomains", |
| 17 | + RunE: func(cmd *cobra.Command, args []string) error { |
| 18 | + domain, _ := cmd.Flags().GetString("domain") |
| 19 | + _, err := subdomains.EnumerateSubdomains(domain, 100) |
| 20 | + return err |
| 21 | + }, |
| 22 | + } |
| 23 | + |
| 24 | + livehostsCmd = &cobra.Command{ |
| 25 | + Use: "livehosts", |
| 26 | + Short: "Filter live hosts", |
| 27 | + RunE: func(cmd *cobra.Command, args []string) error { |
| 28 | + domain, _ := cmd.Flags().GetString("domain") |
| 29 | + _, err := livehosts.FilterLiveHosts(domain, 100, true) |
| 30 | + return err |
| 31 | + }, |
| 32 | + } |
| 33 | + |
| 34 | + cnamesCmd = &cobra.Command{ |
| 35 | + Use: "cnames", |
| 36 | + Short: "Collect CNAME records", |
| 37 | + RunE: func(cmd *cobra.Command, args []string) error { |
| 38 | + domain, _ := cmd.Flags().GetString("domain") |
| 39 | + _, err := cnames.CollectCNAMEs(domain) |
| 40 | + return err |
| 41 | + }, |
| 42 | + } |
| 43 | + |
| 44 | + techCmd = &cobra.Command{ |
| 45 | + Use: "tech", |
| 46 | + Short: "Detect technologies", |
| 47 | + RunE: func(cmd *cobra.Command, args []string) error { |
| 48 | + domain, _ := cmd.Flags().GetString("domain") |
| 49 | + _, err := tech.DetectTech(domain, 100) |
| 50 | + return err |
| 51 | + }, |
| 52 | + } |
| 53 | + |
| 54 | + portsCmd = &cobra.Command{ |
| 55 | + Use: "ports", |
| 56 | + Short: "Scan for open ports", |
| 57 | + RunE: func(cmd *cobra.Command, args []string) error { |
| 58 | + domain, _ := cmd.Flags().GetString("domain") |
| 59 | + _, err := ports.ScanPorts(domain, 100) |
| 60 | + return err |
| 61 | + }, |
| 62 | + } |
| 63 | + |
| 64 | + urlsCmd = &cobra.Command{ |
| 65 | + Use: "urls", |
| 66 | + Short: "Collect URLs and JS files", |
| 67 | + RunE: func(cmd *cobra.Command, args []string) error { |
| 68 | + domain, _ := cmd.Flags().GetString("domain") |
| 69 | + _, err := urls.CollectURLs(domain, 100, false) |
| 70 | + return err |
| 71 | + }, |
| 72 | + } |
| 73 | +) |
| 74 | + |
| 75 | +func init() { |
| 76 | + reconCmd := &cobra.Command{ |
| 77 | + Use: "recon", |
| 78 | + Short: "Reconnaissance operations", |
| 79 | + } |
| 80 | + rootCmd.AddCommand(reconCmd) |
| 81 | + |
| 82 | + subcmds := []*cobra.Command{subdomainsCmd, livehostsCmd, cnamesCmd, techCmd, portsCmd, urlsCmd} |
| 83 | + for _, sc := range subcmds { |
| 84 | + sc.Flags().StringP("domain", "d", "", "Target domain") |
| 85 | + sc.MarkFlagRequired("domain") |
| 86 | + reconCmd.AddCommand(sc) |
| 87 | + } |
| 88 | + |
| 89 | + // Also support the original flat structure for compatibility |
| 90 | + // (e.g., autoar subdomains get -d domain) |
| 91 | + // For now let's just use the 'recon' grouping for new modularity |
| 92 | +} |
0 commit comments