Skip to content

Commit 2068890

Browse files
committed
allow to exclude status codes
1 parent 7c5d565 commit 2068890

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ All funds that are donated to this project will be donated to charity. A full lo
3535
- the version command now also shows some build variables for more info
3636
- switched to another pkcs12 library to support p12s generated with openssl3 that use SHA256 HMAC
3737
- comments in wordlists (strings starting with #) are no longer ignored
38+
- allow to exclude status code in vhost mode
3839

3940
## 3.6
4041

cli/vhost/vhost.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ func getFlags() []cli.Flag {
2525
flags = append(flags, internalcli.GlobalOptions()...)
2626
flags = append(flags, []cli.Flag{
2727
&cli.BoolFlag{Name: "append-domain", Aliases: []string{"ad"}, Value: false, Usage: "Append main domain from URL to words from wordlist. Otherwise the fully qualified domains need to be specified in the wordlist."},
28-
&cli.StringFlag{Name: "exclude-length", Aliases: []string{"xl"}, Usage: "exclude the following content lengths (completely ignores the status). You can separate multiple lengths by comma and it also supports ranges like 203-206"},
28+
&cli.StringFlag{Name: "exclude-length", Aliases: []string{"xl"}, Usage: "exclude the following content lengths. You can separate multiple lengths by comma and it also supports ranges like 203-206"},
29+
&cli.StringFlag{Name: "exclude-status", Aliases: []string{"xs"}, Usage: "exclude the following status codes. Can also handle ranges like 200,300-400,404.", Value: ""},
2930
&cli.StringFlag{Name: "domain", Aliases: []string{"do"}, Usage: "the domain to append when using an IP address as URL. If left empty and you specify a domain based URL the hostname from the URL is extracted"},
3031
}...)
3132

@@ -49,6 +50,13 @@ func run(c *cli.Context) error {
4950
}
5051
pluginOpts.ExcludeLengthParsed = ret
5152

53+
pluginOpts.ExcludeStatus = c.String("exclude-status")
54+
ret2, err := libgobuster.ParseCommaSeparatedInt(pluginOpts.ExcludeStatus)
55+
if err != nil {
56+
return fmt.Errorf("invalid value for exclude-status: %w", err)
57+
}
58+
pluginOpts.ExcludeStatusParsed = ret2
59+
5260
pluginOpts.Domain = c.String("domain")
5361

5462
globalOpts, err := internalcli.ParseGlobalOptions(c)

gobustervhost/gobustervhost.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func (v *GobusterVhost) ProcessWord(ctx context.Context, word string, progress *
183183
// subdomain must not match default vhost and non existent vhost
184184
// or verbose mode is enabled
185185
found := body != nil && !bytes.Equal(body, v.normalBody) && !bytes.Equal(body, v.abnormalBody)
186-
if found && !v.options.ExcludeLengthParsed.Contains(int(size)) {
186+
if found && !v.options.ExcludeLengthParsed.Contains(int(size)) && !v.options.ExcludeStatusParsed.Contains(statusCode) {
187187
progress.ResultChan <- Result{
188188
Vhost: subdomain,
189189
StatusCode: statusCode,

gobustervhost/options.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ type OptionsVhost struct {
1010
AppendDomain bool
1111
ExcludeLength string
1212
ExcludeLengthParsed libgobuster.Set[int]
13+
ExcludeStatus string
14+
ExcludeStatusParsed libgobuster.Set[int]
1315
Domain string
1416
}
1517

1618
// NewOptions returns a new initialized OptionsVhost
1719
func NewOptions() *OptionsVhost {
1820
return &OptionsVhost{
1921
ExcludeLengthParsed: libgobuster.NewSet[int](),
22+
ExcludeStatusParsed: libgobuster.NewSet[int](),
2023
}
2124
}

0 commit comments

Comments
 (0)