Skip to content

Commit ba619dd

Browse files
authored
3.6
1 parent c3fed5e commit ba619dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+673
-410
lines changed

.github/workflows/docker.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build Docker Images
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
schedule:
9+
- cron: "0 0 * * *"
10+
11+
jobs:
12+
Dockerhub:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
steps:
19+
- name: checkout sources
20+
uses: actions/checkout@v3
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v2
24+
25+
- name: Build and push
26+
uses: docker/build-push-action@v4
27+
with:
28+
push: true
29+
tags: |
30+
ghcr.io/OJ/gobuster:latest

.github/workflows/go.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ jobs:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
9-
go: ["1.18", "1.19"]
9+
go: ["1.18", "1.19", "stable"]
1010
steps:
1111
- name: Set up Go ${{ matrix.go }}
12-
uses: actions/setup-go@v3
12+
uses: actions/setup-go@v4
1313
with:
1414
go-version: ${{ matrix.go }}
1515

.github/workflows/golangci-lint.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ jobs:
77
steps:
88
- uses: actions/[email protected]
99

10-
- uses: actions/setup-go@v3
10+
- uses: actions/setup-go@v4
1111
with:
12-
go-version: "^1.19"
12+
go-version: "stable"
1313

1414
- name: golangci-lint
1515
uses: golangci/golangci-lint-action@v3

.github/workflows/release.yml

+8-5
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,23 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v3.3.0
16+
uses: actions/checkout@v3.2.0
1717
with:
1818
fetch-depth: 0
19+
1920
- name: Fetch all tags
2021
run: git fetch --force --tags
22+
2123
- name: Set up Go
22-
uses: actions/setup-go@v3
24+
uses: actions/setup-go@v4
2325
with:
24-
go-version: 1.19
26+
go-version: "stable"
27+
2528
- name: Run GoReleaser
26-
uses: goreleaser/goreleaser-action@v4
29+
uses: goreleaser/goreleaser-action@v4.4.0
2730
with:
2831
distribution: goreleaser
2932
version: latest
30-
args: release --rm-dist
33+
args: release --clean
3134
env:
3235
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yaml

+21-12
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,33 @@ builds:
1313
- linux
1414
- windows
1515
- darwin
16+
1617
archives:
1718
- format: tar.gz
19+
# this name template makes the OS and Arch compatible with the results of uname.
20+
name_template: >-
21+
{{ .ProjectName }}_
22+
{{- title .Os }}_
23+
{{- if eq .Arch "amd64" }}x86_64
24+
{{- else if eq .Arch "386" }}i386
25+
{{- else }}{{ .Arch }}{{ end }}
26+
{{- if .Arm }}v{{ .Arm }}{{ end }}
27+
# use zip for windows archives
1828
format_overrides:
19-
- goos: windows
20-
format: zip
21-
replacements:
22-
darwin: Darwin
23-
linux: Linux
24-
windows: Windows
25-
386: i386
26-
amd64: x86_64
29+
- goos: windows
30+
format: zip
2731
checksum:
28-
name_template: "checksums.txt"
32+
name_template: 'checksums.txt'
2933
snapshot:
30-
name_template: "{{ incpatch .Version }}-dev"
34+
name_template: "{{ incpatch .Version }}-next"
3135
changelog:
3236
sort: asc
3337
filters:
3438
exclude:
35-
- "^docs:"
36-
- "^test:"
39+
- '^docs:'
40+
- '^test:'
41+
42+
# The lines beneath this are called `modelines`. See `:help modeline`
43+
# Feel free to remove those if you don't want/use them.
44+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
45+
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ All funds that are donated to this project will be donated to charity. A full lo
2424

2525
# Changes
2626

27+
## 3.6
28+
29+
- Wordlist offset parameter to skip x lines from the wordlist
30+
- prevent double slashes when building up an url in dir mode
31+
- allow for multiple values and ranges on `--exclude-length`
32+
- `no-fqdn` parameter on dns bruteforce to disable the use of the systems search domains. This should speed up the run if you have configured some search domains. [https://github.com/OJ/gobuster/pull/418](https://github.com/OJ/gobuster/pull/418)
33+
2734
## 3.5
2835

2936
- Allow Ranges in status code and status code blacklist. Example: 200,300-305,404

cli/cmd/dir.go

+15-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
"github.com/OJ/gobuster/v3/cli"
99
"github.com/OJ/gobuster/v3/gobusterdir"
10-
"github.com/OJ/gobuster/v3/helper"
1110
"github.com/OJ/gobuster/v3/libgobuster"
1211
"github.com/spf13/cobra"
1312
)
@@ -26,11 +25,13 @@ func runDir(cmd *cobra.Command, args []string) error {
2625
return fmt.Errorf("error on creating gobusterdir: %w", err)
2726
}
2827

29-
if err := cli.Gobuster(mainContext, globalopts, plugin); err != nil {
28+
log := libgobuster.NewLogger(globalopts.Debug)
29+
if err := cli.Gobuster(mainContext, globalopts, plugin, log); err != nil {
3030
var wErr *gobusterdir.ErrWildcard
3131
if errors.As(err, &wErr) {
3232
return fmt.Errorf("%w. To continue please exclude the status code or the length", wErr)
3333
}
34+
log.Debugf("%#v", err)
3435
return fmt.Errorf("error on running gobuster: %w", err)
3536
}
3637
return nil
@@ -69,7 +70,7 @@ func parseDirOptions() (*libgobuster.Options, *gobusterdir.OptionsDir, error) {
6970
return nil, nil, fmt.Errorf("invalid value for extensions: %w", err)
7071
}
7172

72-
ret, err := helper.ParseExtensions(pluginOpts.Extensions)
73+
ret, err := libgobuster.ParseExtensions(pluginOpts.Extensions)
7374
if err != nil {
7475
return nil, nil, fmt.Errorf("invalid value for extensions: %w", err)
7576
}
@@ -81,7 +82,7 @@ func parseDirOptions() (*libgobuster.Options, *gobusterdir.OptionsDir, error) {
8182
}
8283

8384
if pluginOpts.ExtensionsFile != "" {
84-
extensions, err := helper.ParseExtensionsFile(pluginOpts.ExtensionsFile)
85+
extensions, err := libgobuster.ParseExtensionsFile(pluginOpts.ExtensionsFile)
8586
if err != nil {
8687
return nil, nil, fmt.Errorf("invalid value for extensions file: %w", err)
8788
}
@@ -93,7 +94,7 @@ func parseDirOptions() (*libgobuster.Options, *gobusterdir.OptionsDir, error) {
9394
if err != nil {
9495
return nil, nil, fmt.Errorf("invalid value for status-codes: %w", err)
9596
}
96-
ret2, err := helper.ParseCommaSeparatedInt(pluginOpts.StatusCodes)
97+
ret2, err := libgobuster.ParseCommaSeparatedInt(pluginOpts.StatusCodes)
9798
if err != nil {
9899
return nil, nil, fmt.Errorf("invalid value for status-codes: %w", err)
99100
}
@@ -104,7 +105,7 @@ func parseDirOptions() (*libgobuster.Options, *gobusterdir.OptionsDir, error) {
104105
if err != nil {
105106
return nil, nil, fmt.Errorf("invalid value for status-codes-blacklist: %w", err)
106107
}
107-
ret3, err := helper.ParseCommaSeparatedInt(pluginOpts.StatusCodesBlacklist)
108+
ret3, err := libgobuster.ParseCommaSeparatedInt(pluginOpts.StatusCodesBlacklist)
108109
if err != nil {
109110
return nil, nil, fmt.Errorf("invalid value for status-codes-blacklist: %w", err)
110111
}
@@ -144,10 +145,15 @@ func parseDirOptions() (*libgobuster.Options, *gobusterdir.OptionsDir, error) {
144145
return nil, nil, fmt.Errorf("invalid value for discover-backup: %w", err)
145146
}
146147

147-
pluginOpts.ExcludeLength, err = cmdDir.Flags().GetIntSlice("exclude-length")
148+
pluginOpts.ExcludeLength, err = cmdDir.Flags().GetString("exclude-length")
148149
if err != nil {
149-
return nil, nil, fmt.Errorf("invalid value for excludelength: %w", err)
150+
return nil, nil, fmt.Errorf("invalid value for exclude-length: %w", err)
150151
}
152+
ret4, err := libgobuster.ParseCommaSeparatedInt(pluginOpts.ExcludeLength)
153+
if err != nil {
154+
return nil, nil, fmt.Errorf("invalid value for exclude-length: %w", err)
155+
}
156+
pluginOpts.ExcludeLengthParsed = ret4
151157

152158
return globalopts, pluginOpts, nil
153159
}
@@ -172,7 +178,7 @@ func init() {
172178
cmdDir.Flags().Bool("hide-length", false, "Hide the length of the body in the output")
173179
cmdDir.Flags().BoolP("add-slash", "f", false, "Append / to each request")
174180
cmdDir.Flags().BoolP("discover-backup", "d", false, "Also search for backup files by appending multiple backup extensions")
175-
cmdDir.Flags().IntSlice("exclude-length", []int{}, "exclude the following content length (completely ignores the status). Supply multiple times to exclude multiple sizes.")
181+
cmdDir.Flags().String("exclude-length", "", "exclude the following content lengths (completely ignores the status). You can separate multiple lengths by comma and it also supports ranges like 203-206")
176182

177183
cmdDir.PersistentPreRun = func(cmd *cobra.Command, args []string) {
178184
configureGlobalOptions()

cli/cmd/dir_test.go

+4-8
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package cmd
33
import (
44
"context"
55
"fmt"
6-
"io"
7-
"log"
86
"net/http"
97
"net/http/httptest"
108
"os"
@@ -13,7 +11,6 @@ import (
1311

1412
"github.com/OJ/gobuster/v3/cli"
1513
"github.com/OJ/gobuster/v3/gobusterdir"
16-
"github.com/OJ/gobuster/v3/helper"
1714
"github.com/OJ/gobuster/v3/libgobuster"
1815
)
1916

@@ -33,14 +30,14 @@ func BenchmarkDirMode(b *testing.B) {
3330
pluginopts.Timeout = 10 * time.Second
3431

3532
pluginopts.Extensions = ".php,.csv"
36-
tmpExt, err := helper.ParseExtensions(pluginopts.Extensions)
33+
tmpExt, err := libgobuster.ParseExtensions(pluginopts.Extensions)
3734
if err != nil {
3835
b.Fatalf("could not parse extensions: %v", err)
3936
}
4037
pluginopts.ExtensionsParsed = tmpExt
4138

4239
pluginopts.StatusCodes = "200,204,301,302,307,401,403"
43-
tmpStat, err := helper.ParseCommaSeparatedInt(pluginopts.StatusCodes)
40+
tmpStat, err := libgobuster.ParseCommaSeparatedInt(pluginopts.StatusCodes)
4441
if err != nil {
4542
b.Fatalf("could not parse status codes: %v", err)
4643
}
@@ -71,8 +68,7 @@ func BenchmarkDirMode(b *testing.B) {
7168
b.Fatalf("could not get devnull %v", err)
7269
}
7370
defer devnull.Close()
74-
log.SetFlags(0)
75-
log.SetOutput(io.Discard)
71+
log := libgobuster.NewLogger(false)
7672

7773
// Run the real benchmark
7874
for x := 0; x < b.N; x++ {
@@ -83,7 +79,7 @@ func BenchmarkDirMode(b *testing.B) {
8379
b.Fatalf("error on creating gobusterdir: %v", err)
8480
}
8581

86-
if err := cli.Gobuster(ctx, &globalopts, plugin); err != nil {
82+
if err := cli.Gobuster(ctx, &globalopts, plugin, log); err != nil {
8783
b.Fatalf("error on running gobuster: %v", err)
8884
}
8985
os.Stdout = oldStdout

cli/cmd/dns.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ func runDNS(cmd *cobra.Command, args []string) error {
2727
return fmt.Errorf("error on creating gobusterdns: %w", err)
2828
}
2929

30-
if err := cli.Gobuster(mainContext, globalopts, plugin); err != nil {
30+
log := libgobuster.NewLogger(globalopts.Debug)
31+
if err := cli.Gobuster(mainContext, globalopts, plugin, log); err != nil {
3132
var wErr *gobusterdns.ErrWildcard
3233
if errors.As(err, &wErr) {
3334
return fmt.Errorf("%w. To force processing of Wildcard DNS, specify the '--wildcard' switch", wErr)
3435
}
36+
log.Debugf("%#v", err)
3537
return fmt.Errorf("error on running gobuster: %w", err)
3638
}
3739
return nil
@@ -74,6 +76,11 @@ func parseDNSOptions() (*libgobuster.Options, *gobusterdns.OptionsDNS, error) {
7476
return nil, nil, fmt.Errorf("invalid value for resolver: %w", err)
7577
}
7678

79+
pluginOpts.NoFQDN, err = cmdDNS.Flags().GetBool("no-fqdn")
80+
if err != nil {
81+
return nil, nil, fmt.Errorf("invalid value for no-fqdn: %w", err)
82+
}
83+
7784
if pluginOpts.Resolver != "" && runtime.GOOS == "windows" {
7885
return nil, nil, fmt.Errorf("currently can not set custom dns resolver on windows. See https://golang.org/pkg/net/#hdr-Name_Resolution")
7986
}
@@ -94,6 +101,7 @@ func init() {
94101
cmdDNS.Flags().BoolP("show-cname", "c", false, "Show CNAME records (cannot be used with '-i' option)")
95102
cmdDNS.Flags().DurationP("timeout", "", time.Second, "DNS resolver timeout")
96103
cmdDNS.Flags().BoolP("wildcard", "", false, "Force continued operation when wildcard found")
104+
cmdDNS.Flags().BoolP("no-fqdn", "", false, "Do not automatically add a trailing dot to the domain, so the resolver uses the DNS search domain")
97105
cmdDNS.Flags().StringP("resolver", "r", "", "Use custom DNS server (format server.com or server.com:port)")
98106
if err := cmdDNS.MarkFlagRequired("domain"); err != nil {
99107
log.Fatalf("error on marking flag as required: %v", err)

cli/cmd/fuzz.go

+12-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88

99
"github.com/OJ/gobuster/v3/cli"
1010
"github.com/OJ/gobuster/v3/gobusterfuzz"
11-
"github.com/OJ/gobuster/v3/helper"
1211
"github.com/OJ/gobuster/v3/libgobuster"
1312
"github.com/spf13/cobra"
1413
)
@@ -31,11 +30,13 @@ func runFuzz(cmd *cobra.Command, args []string) error {
3130
return fmt.Errorf("error on creating gobusterfuzz: %w", err)
3231
}
3332

34-
if err := cli.Gobuster(mainContext, globalopts, plugin); err != nil {
33+
log := libgobuster.NewLogger(globalopts.Debug)
34+
if err := cli.Gobuster(mainContext, globalopts, plugin, log); err != nil {
3535
var wErr *gobusterfuzz.ErrWildcard
3636
if errors.As(err, &wErr) {
3737
return fmt.Errorf("%w. To continue please exclude the status code or the length", wErr)
3838
}
39+
log.Debugf("%#v", err)
3940
return fmt.Errorf("error on running gobuster: %w", err)
4041
}
4142
return nil
@@ -74,16 +75,21 @@ func parseFuzzOptions() (*libgobuster.Options, *gobusterfuzz.OptionsFuzz, error)
7475
if err != nil {
7576
return nil, nil, fmt.Errorf("invalid value for excludestatuscodes: %w", err)
7677
}
77-
ret, err := helper.ParseCommaSeparatedInt(pluginOpts.ExcludedStatusCodes)
78+
ret, err := libgobuster.ParseCommaSeparatedInt(pluginOpts.ExcludedStatusCodes)
7879
if err != nil {
7980
return nil, nil, fmt.Errorf("invalid value for excludestatuscodes: %w", err)
8081
}
8182
pluginOpts.ExcludedStatusCodesParsed = ret
8283

83-
pluginOpts.ExcludeLength, err = cmdFuzz.Flags().GetIntSlice("exclude-length")
84+
pluginOpts.ExcludeLength, err = cmdFuzz.Flags().GetString("exclude-length")
8485
if err != nil {
85-
return nil, nil, fmt.Errorf("invalid value for excludelength: %w", err)
86+
return nil, nil, fmt.Errorf("invalid value for exclude-length: %w", err)
8687
}
88+
ret2, err := libgobuster.ParseCommaSeparatedInt(pluginOpts.ExcludeLength)
89+
if err != nil {
90+
return nil, nil, fmt.Errorf("invalid value for exclude-length: %w", err)
91+
}
92+
pluginOpts.ExcludeLengthParsed = ret2
8793

8894
pluginOpts.RequestBody, err = cmdFuzz.Flags().GetString("body")
8995
if err != nil {
@@ -105,7 +111,7 @@ func init() {
105111
log.Fatalf("%v", err)
106112
}
107113
cmdFuzz.Flags().StringP("excludestatuscodes", "b", "", "Excluded status codes. Can also handle ranges like 200,300-400,404.")
108-
cmdFuzz.Flags().IntSlice("exclude-length", []int{}, "exclude the following content length (completely ignores the status). Supply multiple times to exclude multiple sizes.")
114+
cmdFuzz.Flags().String("exclude-length", "", "exclude the following content lengths (completely ignores the status). You can separate multiple lengths by comma and it also supports ranges like 203-206")
109115
cmdFuzz.Flags().StringP("body", "B", "", "Request body")
110116

111117
cmdFuzz.PersistentPreRun = func(cmd *cobra.Command, args []string) {

cli/cmd/gcs.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ func runGCS(cmd *cobra.Command, args []string) error {
2323
return fmt.Errorf("error on creating gobustergcs: %w", err)
2424
}
2525

26-
if err := cli.Gobuster(mainContext, globalopts, plugin); err != nil {
26+
log := libgobuster.NewLogger(globalopts.Debug)
27+
if err := cli.Gobuster(mainContext, globalopts, plugin, log); err != nil {
28+
log.Debugf("%#v", err)
2729
return fmt.Errorf("error on running gobuster: %w", err)
2830
}
2931
return nil

0 commit comments

Comments
 (0)