From 441c0091997473dcaecbd7de3133228aae72f678 Mon Sep 17 00:00:00 2001 From: Christian Mehlmauer <105281+firefart@users.noreply.github.com> Date: Thu, 17 Aug 2023 07:56:15 +0200 Subject: [PATCH] make error message more user friendly. See #437 --- go.mod | 2 +- go.sum | 4 ++-- gobusterdir/gobusterdir.go | 5 +++++ gobustervhost/gobustervhost.go | 8 ++++++++ libgobuster/helpers.go | 10 ---------- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index a155e1d..b78da46 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,6 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/spf13/pflag v1.0.5 // indirect - golang.org/x/net v0.11.0 // indirect + golang.org/x/net v0.14.0 // indirect golang.org/x/sys v0.11.0 // indirect ) diff --git a/go.sum b/go.sum index e21bd20..dc2327c 100644 --- a/go.sum +++ b/go.sum @@ -21,8 +21,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= -golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/gobusterdir/gobusterdir.go b/gobusterdir/gobusterdir.go index 5138d6c..7bf6fda 100644 --- a/gobusterdir/gobusterdir.go +++ b/gobusterdir/gobusterdir.go @@ -4,7 +4,9 @@ import ( "bufio" "bytes" "context" + "errors" "fmt" + "io" "net" "net/http" "strings" @@ -99,6 +101,9 @@ func (d *GobusterDir) PreRun(ctx context.Context, progress *libgobuster.Progress _, _, _, _, err := d.http.Request(ctx, d.options.URL, libgobuster.RequestOptions{}) if err != nil { + if errors.Is(err, io.EOF) { + return fmt.Errorf("server closed connection without sending any data back when connecting to %s. Maybe you are connecting via https to on http port or vice versa?", d.options.URL) + } return fmt.Errorf("unable to connect to %s: %w", d.options.URL, err) } diff --git a/gobustervhost/gobustervhost.go b/gobustervhost/gobustervhost.go index d3d8059..de413f5 100644 --- a/gobustervhost/gobustervhost.go +++ b/gobustervhost/gobustervhost.go @@ -4,7 +4,9 @@ import ( "bufio" "bytes" "context" + "errors" "fmt" + "io" "net" "net/http" "net/url" @@ -94,6 +96,9 @@ func (v *GobusterVhost) PreRun(ctx context.Context, progress *libgobuster.Progre // request default vhost for normalBody _, _, _, body, err := v.http.Request(ctx, v.options.URL, libgobuster.RequestOptions{ReturnBody: true}) if err != nil { + if errors.Is(err, io.EOF) { + return fmt.Errorf("server closed connection without sending any data back when connecting to %s. Maybe you are connecting via https to on http port or vice versa?", v.options.URL) + } return fmt.Errorf("unable to connect to %s: %w", v.options.URL, err) } v.normalBody = body @@ -102,6 +107,9 @@ func (v *GobusterVhost) PreRun(ctx context.Context, progress *libgobuster.Progre subdomain := fmt.Sprintf("%s.%s", uuid.New(), v.domain) _, _, _, body, err = v.http.Request(ctx, v.options.URL, libgobuster.RequestOptions{Host: subdomain, ReturnBody: true}) if err != nil { + if errors.Is(err, io.EOF) { + return fmt.Errorf("server closed connection without sending any data back when connecting to %s. Maybe you are connecting via https to on http port or vice versa?", v.options.URL) + } return fmt.Errorf("unable to connect to %s: %w", v.options.URL, err) } v.abnormalBody = body diff --git a/libgobuster/helpers.go b/libgobuster/helpers.go index 6df5c8e..9353be6 100644 --- a/libgobuster/helpers.go +++ b/libgobuster/helpers.go @@ -176,16 +176,6 @@ func ParseCommaSeparatedInt(inputString string) (Set[int], error) { return ret, nil } -// SliceContains checks if an integer slice contains a specific value -func SliceContains(s []int, e int) bool { - for _, a := range s { - if a == e { - return true - } - } - return false -} - // JoinIntSlice joins an int slice by , func JoinIntSlice(s []int) string { valuesText := make([]string, len(s))