fix some code

This commit is contained in:
firefart
2025-07-06 10:48:18 +02:00
parent ba0a2f7d28
commit b6902dadc8
4 changed files with 12 additions and 8 deletions
+1 -1
View File
@@ -348,7 +348,7 @@ _Remember: Always test responsibly and with proper authorization._
## 3.8
TODO
- Add exclude-hostname-length flag to dynamically adjust exclude-length by @0xyy66
</details>
+5 -1
View File
@@ -48,13 +48,17 @@ func run(c *cli.Context) error {
pluginOpts.AppendDomain = c.Bool("append-domain")
pluginOpts.ExcludeLength = c.String("exclude-length")
pluginOpts.ExcludeHostnameLength = c.Bool("exclude-hostname-length")
ret, err := libgobuster.ParseCommaSeparatedInt(pluginOpts.ExcludeLength)
if err != nil {
return fmt.Errorf("invalid value for exclude-length: %w", err)
}
pluginOpts.ExcludeLengthParsed = ret
pluginOpts.ExcludeHostnameLength = c.Bool("exclude-hostname-length")
if pluginOpts.ExcludeHostnameLength && pluginOpts.ExcludeLengthParsed.Length() == 0 {
return errors.New("exclude-hostname-length requires exclude-length to be set")
}
pluginOpts.ExcludeStatus = c.String("exclude-status")
ret2, err := libgobuster.ParseCommaSeparatedInt(pluginOpts.ExcludeStatus)
if err != nil {
+4 -4
View File
@@ -127,7 +127,7 @@ func (v *GobusterVhost) PreRun(ctx context.Context, _ *libgobuster.Progress) err
// ProcessWord is the process implementation of gobusterdir
func (v *GobusterVhost) ProcessWord(ctx context.Context, word string, progress *libgobuster.Progress) (libgobuster.Result, error) {
var subdomain string
var wordLength int
var hostnameLength int
if v.options.AppendDomain {
subdomain = fmt.Sprintf("%s.%s", word, v.domain)
} else {
@@ -135,9 +135,9 @@ func (v *GobusterVhost) ProcessWord(ctx context.Context, word string, progress *
subdomain = word
}
if v.options.ExcludeHostnameLength {
wordLength = len(word)
hostnameLength = len(subdomain)
} else {
wordLength = 0
hostnameLength = 0
}
// warn people when there is no . detected so they might want to use the other options
@@ -200,7 +200,7 @@ func (v *GobusterVhost) ProcessWord(ctx context.Context, word string, progress *
// subdomain must not match default vhost and non existent vhost
// or verbose mode is enabled
found := body != nil && !bytes.Equal(body, v.normalBody) && !bytes.Equal(body, v.abnormalBody)
if found && !v.options.ExcludeLengthParsed.Contains(int(size)-wordLength) && !v.options.ExcludeStatusParsed.Contains(statusCode) {
if found && !v.options.ExcludeLengthParsed.Contains(int(size)-hostnameLength) && !v.options.ExcludeStatusParsed.Contains(statusCode) {
r := Result{
Vhost: subdomain,
StatusCode: statusCode,
+2 -2
View File
@@ -10,8 +10,8 @@ type OptionsVhost struct {
AppendDomain bool
ExcludeLength string
ExcludeLengthParsed libgobuster.Set[int]
ExcludeStatus string
ExcludeStatusParsed libgobuster.Set[int]
ExcludeStatus string
ExcludeStatusParsed libgobuster.Set[int]
Domain string
ExcludeHostnameLength bool
}