File: gcs.go

package info (click to toggle)
gobuster 3.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,200 kB
  • sloc: makefile: 8
file content (62 lines) | stat: -rw-r--r-- 1,581 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package gcs

import (
	"fmt"

	internalcli "github.com/OJ/gobuster/v3/cli"
	"github.com/OJ/gobuster/v3/gobustergcs"
	"github.com/OJ/gobuster/v3/libgobuster"
	"github.com/urfave/cli/v2"
)

func Command() *cli.Command {
	cmd := cli.Command{
		Name:   "gcs",
		Usage:  "Uses gcs bucket enumeration mode",
		Action: run,
		Flags:  getFlags(),
	}
	return &cmd
}

func getFlags() []cli.Flag {
	var flags []cli.Flag
	flags = append(flags, []cli.Flag{
		&cli.IntFlag{Name: "max-files", Aliases: []string{"m"}, Value: 5, Usage: "max files to list when listing buckets"},
		&cli.BoolFlag{Name: "show-files", Aliases: []string{"s"}, Value: true, Usage: "show files from found buckets"},
	}...)
	flags = append(flags, internalcli.GlobalOptions()...)
	flags = append(flags, internalcli.BasicHTTPOptions()...)
	return flags
}

func run(c *cli.Context) error {
	pluginOpts := gobustergcs.NewOptions()

	httpOptions, err := internalcli.ParseBasicHTTPOptions(c)
	if err != nil {
		return err
	}
	pluginOpts.BasicHTTPOptions = httpOptions

	pluginOpts.MaxFilesToList = c.Int("max-files")
	pluginOpts.ShowFiles = c.Bool("show-files")

	globalOpts, err := internalcli.ParseGlobalOptions(c)
	if err != nil {
		return err
	}

	log := libgobuster.NewLogger(globalOpts.Debug)

	plugin, err := gobustergcs.New(&globalOpts, pluginOpts, log)
	if err != nil {
		return fmt.Errorf("error on creating gobustergcs: %w", err)
	}

	if err := internalcli.Gobuster(c.Context, &globalOpts, plugin, log); err != nil {
		log.Debugf("%#v", err)
		return fmt.Errorf("error on running gobuster: %w", err)
	}
	return nil
}