diff --git a/internal/runner/runner.go b/internal/runner/runner.go index 2b913d939f..2f37f72365 100644 --- a/internal/runner/runner.go +++ b/internal/runner/runner.go @@ -500,7 +500,7 @@ func (r *Runner) RunEnumeration() error { } ret := uncover.GetUncoverTargetsFromMetadata(context.TODO(), store.Templates(), r.options.UncoverField, uncoverOpts) for host := range ret { - r.hmapInputProvider.Set(host) + r.hmapInputProvider.SetWithExclusions(host) } } // list all templates diff --git a/pkg/core/inputs/hybrid/hmap.go b/pkg/core/inputs/hybrid/hmap.go index 9e805e22cf..37c3ab6e6f 100644 --- a/pkg/core/inputs/hybrid/hmap.go +++ b/pkg/core/inputs/hybrid/hmap.go @@ -39,7 +39,9 @@ type Input struct { inputCount int64 excludedCount int64 dupeCount int64 + skippedCount int64 hostMap *hybrid.HybridMap + excludedHosts map[string]struct{} hostMapStream *filekv.FileDB hostMapStreamOnce sync.Once sync.Once @@ -95,6 +97,9 @@ func New(opts *Options) (*Input, error) { if input.dupeCount > 0 { gologger.Info().Msgf("Supplied input was automatically deduplicated (%d removed).", input.dupeCount) } + if input.skippedCount > 0 { + gologger.Info().Msgf("Number of hosts skipped from input due to exclusion: %d", input.skippedCount) + } return input, nil } @@ -282,6 +287,32 @@ func (i *Input) Set(value string) { } } +// SetWithExclusions normalizes and stores passed input values if not excluded +func (i *Input) SetWithExclusions(value string) { + URL := strings.TrimSpace(value) + if URL == "" { + return + } + if i.isExcluded(URL) { + i.skippedCount++ + return + } + i.Set(URL) +} + +// isExcluded checks if a URL is in the exclusion list +func (i *Input) isExcluded(URL string) bool { + metaInput := &contextargs.MetaInput{Input: URL} + key, err := metaInput.MarshalString() + if err != nil { + gologger.Warning().Msgf("%s\n", err) + return false + } + + _, exists := i.excludedHosts[key] + return exists +} + func (i *Input) Del(value string) { URL := strings.TrimSpace(value) if URL == "" { @@ -407,6 +438,7 @@ func (i *Input) delItem(metaInput *contextargs.MetaInput) { if tmpUrl.Host == targetUrl.Host { _ = i.hostMap.Del(tmpKey) + i.excludedHosts[tmpKey] = struct{}{} i.excludedCount++ i.inputCount-- }