Skip to content

Commit

Permalink
exclude length
Browse files Browse the repository at this point in the history
  • Loading branch information
firefart committed Apr 26, 2021
1 parent 985bb16 commit b456f01
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
6 changes: 6 additions & 0 deletions cli/cmd/vhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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()
Expand Down
15 changes: 13 additions & 2 deletions gobustervhost/gobustervhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"
"text/tabwriter"

"github.com/OJ/gobuster/v3/helper"
"github.com/OJ/gobuster/v3/libgobuster"
"github.com/google/uuid"
)
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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)
}
Expand Down
3 changes: 2 additions & 1 deletion gobustervhost/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit b456f01

Please sign in to comment.