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

Function run

cli/fuzz/fuzz.go:36–82  ·  view source on GitHub ↗
(c *cli.Context)

Source from the content-addressed store, hash-verified

34}
35
36func run(c *cli.Context) error {
37 pluginOpts := gobusterfuzz.NewOptions()
38
39 httpOptions, err := internalcli.ParseCommonHTTPOptions(c)
40 if err != nil {
41 return err
42 }
43 pluginOpts.HTTPOptions = httpOptions
44
45 pluginOpts.ExcludedStatusCodes = c.String("exclude-statuscodes")
46 ret, err := libgobuster.ParseCommaSeparatedInt(pluginOpts.ExcludedStatusCodes)
47 if err != nil {
48 return fmt.Errorf("invalid value for excludestatuscodes: %w", err)
49 }
50 pluginOpts.ExcludedStatusCodesParsed = ret
51
52 pluginOpts.ExcludeLength = c.String("exclude-length")
53 ret2, err := libgobuster.ParseCommaSeparatedInt(pluginOpts.ExcludeLength)
54 if err != nil {
55 return fmt.Errorf("invalid value for exclude-length: %w", err)
56 }
57 pluginOpts.ExcludeLengthParsed = ret2
58
59 pluginOpts.RequestBody = c.String("body")
60
61 globalOpts, err := internalcli.ParseGlobalOptions(c)
62 if err != nil {
63 return err
64 }
65
66 if !containsFuzzKeyword(*pluginOpts) {
67 return fmt.Errorf("please provide the %s keyword", gobusterfuzz.FuzzKeyword)
68 }
69
70 log := libgobuster.NewLogger(globalOpts.Debug)
71
72 plugin, err := gobusterfuzz.New(&globalOpts, pluginOpts, log)
73 if err != nil {
74 return fmt.Errorf("error on creating gobusterfuzz: %w", err)
75 }
76
77 if err := internalcli.Gobuster(c.Context, &globalOpts, plugin, log); err != nil {
78 log.Debugf("%#v", err)
79 return fmt.Errorf("error on running gobuster on %s: %w", pluginOpts.URL, err)
80 }
81 return nil
82}
83
84func containsFuzzKeyword(pluginopts gobusterfuzz.OptionsFuzz) bool {
85 if strings.Contains(pluginopts.URL.String(), gobusterfuzz.FuzzKeyword) {

Callers

nothing calls this directly

Calls 7

DebugfMethod · 0.95
NewOptionsFunction · 0.92
ParseCommaSeparatedIntFunction · 0.92
NewLoggerFunction · 0.92
NewFunction · 0.92
containsFuzzKeywordFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected