MCPcopy
hub / github.com/OJ/gobuster / run

Function run

cli/dns/dns.go:40–83  ·  view source on GitHub ↗
(c *cli.Context)

Source from the content-addressed store, hash-verified

38}
39
40func run(c *cli.Context) error {
41 pluginOpts := gobusterdns.NewOptions()
42
43 pluginOpts.Domain = c.String("domain")
44 pluginOpts.CheckCNAME = c.Bool("check-cname")
45 pluginOpts.Timeout = c.Duration("timeout")
46 pluginOpts.WildcardForced = c.Bool("wildcard")
47 pluginOpts.NoFQDN = c.Bool("no-fqdn")
48 pluginOpts.Resolver = c.String("resolver")
49 pluginOpts.Protocol = c.String("protocol")
50
51 if pluginOpts.Resolver != "" && runtime.GOOS == "windows" {
52 return errors.New("currently can not set custom dns resolver on windows. See https://golang.org/pkg/net/#hdr-Name_Resolution")
53 }
54
55 if pluginOpts.Protocol != "udp" && pluginOpts.Protocol != "tcp" {
56 return errors.New("protocol must be either 'udp' or 'tcp'")
57 }
58
59 if pluginOpts.Protocol != "udp" && pluginOpts.Resolver == "" {
60 return errors.New("custom protocol can only be set if a custom resolver is set")
61 }
62
63 globalOpts, err := internalcli.ParseGlobalOptions(c)
64 if err != nil {
65 return err
66 }
67
68 plugin, err := gobusterdns.New(&globalOpts, pluginOpts)
69 if err != nil {
70 return fmt.Errorf("error on creating gobusterdns: %w", err)
71 }
72
73 log := libgobuster.NewLogger(globalOpts.Debug)
74 if err := internalcli.Gobuster(c.Context, &globalOpts, plugin, log); err != nil {
75 var wErr *gobusterdns.WildcardError
76 if errors.As(err, &wErr) {
77 return fmt.Errorf("%w. To force processing of Wildcard DNS, specify the '--wildcard' switch", wErr)
78 }
79 log.Debugf("%#v", err)
80 return fmt.Errorf("error on running gobuster on %s: %w", pluginOpts.Domain, err)
81 }
82 return nil
83}

Callers

nothing calls this directly

Calls 5

DebugfMethod · 0.95
NewOptionsFunction · 0.92
NewFunction · 0.92
NewLoggerFunction · 0.92
ErrorfMethod · 0.80

Tested by

no test coverage detected