From b456f016249bde708a231150b98f15a45110644d Mon Sep 17 00:00:00 2001 From: Christian Mehlmauer Date: Mon, 26 Apr 2021 15:30:29 +0200 Subject: [PATCH] exclude length --- cli/cmd/vhost.go | 6 ++++++ gobustervhost/gobustervhost.go | 15 +++++++++++++-- gobustervhost/options.go | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/cli/cmd/vhost.go b/cli/cmd/vhost.go index 00de78fa..676640f7 100644 --- a/cli/cmd/vhost.go +++ b/cli/cmd/vhost.go @@ -58,6 +58,11 @@ func parseVhostOptions() (*libgobuster.Options, *gobustervhost.OptionsVhost, err return nil, nil, fmt.Errorf("invalid value for append-domain: %w", err) } + plugin.ExcludeLength, err = cmdVhost.Flags().GetIntSlice("exclude-length") + if err != nil { + return nil, nil, fmt.Errorf("invalid value for excludelength: %w", err) + } + return globalopts, &plugin, nil } @@ -72,6 +77,7 @@ func init() { log.Fatalf("%v", err) } cmdVhost.Flags().BoolP("append-domain", "", false, "Append main domain from URL to words from wordlist. Otherwise the fully qualified domains need to be specified in the wordlist.") + cmdVhost.Flags().IntSlice("exclude-length", []int{}, "exclude the following content length (completely ignores the status). Supply multiple times to exclude multiple sizes.") cmdVhost.PersistentPreRun = func(cmd *cobra.Command, args []string) { configureGlobalOptions() diff --git a/gobustervhost/gobustervhost.go b/gobustervhost/gobustervhost.go index 3013fba4..7ce51473 100644 --- a/gobustervhost/gobustervhost.go +++ b/gobustervhost/gobustervhost.go @@ -9,6 +9,7 @@ import ( "strings" "text/tabwriter" + "github.com/OJ/gobuster/v3/helper" "github.com/OJ/gobuster/v3/libgobuster" "github.com/google/uuid" ) @@ -120,9 +121,9 @@ func (v *GobusterVhost) Run(ctx context.Context, word string, resChannel chan<- // subdomain must not match default vhost and non existent vhost // or verbose mode is enabled found := !bytes.Equal(body, v.baseline1) && !bytes.Equal(body, v.baseline2) - if found || v.globalopts.Verbose { + if found || !helper.SliceContains(v.options.ExcludeLength, int(size)) || v.globalopts.Verbose { resultStatus := false - if found { + if found || !helper.SliceContains(v.options.ExcludeLength, int(size)) { resultStatus = true } resChannel <- Result{ @@ -208,6 +209,16 @@ func (v *GobusterVhost) GetConfigString() (string, error) { return "", err } + if _, err := fmt.Fprintf(tw, "[+] Append Domain:\t%t\n", v.options.AppendDomain); err != nil { + return "", err + } + + if len(o.ExcludeLength) > 0 { + if _, err := fmt.Fprintf(tw, "[+] Exclude Length:\t%s\n", helper.JoinIntSlice(v.options.ExcludeLength)); err != nil { + return "", err + } + } + if err := tw.Flush(); err != nil { return "", fmt.Errorf("error on tostring: %w", err) } diff --git a/gobustervhost/options.go b/gobustervhost/options.go index a5e387d5..5acb4ed8 100644 --- a/gobustervhost/options.go +++ b/gobustervhost/options.go @@ -7,5 +7,6 @@ import ( // OptionsVhost is the struct to hold all options for this plugin type OptionsVhost struct { libgobuster.HTTPOptions - AppendDomain bool + AppendDomain bool + ExcludeLength []int }