Merge pull request #513 from projectdiscovery/issue-489-filter-ip

filter ip from targets
dev
Sandeep Singh 2022-03-14 18:27:59 +05:30 committed by GitHub
commit 5095f9a07d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -60,7 +60,8 @@ type Options struct {
Proxy string // HTTP proxy
RateLimit int // Maximum number of HTTP requests to send per second
// YAMLConfig contains the unmarshalled yaml config file
Providers *Providers
Providers *Providers
ExcludeIps bool
}
// ParseOptions parses the command line flags provided by a user
@ -116,6 +117,7 @@ func ParseOptions() *Options {
flagSet.StringVarP(&options.ResolverList, "rlist", "rL", "", "file containing list of resolvers to use"),
flagSet.BoolVarP(&options.RemoveWildcard, "active", "nW", false, "display active subdomains only"),
flagSet.StringVar(&options.Proxy, "proxy", "", "http proxy to use with subfinder"),
flagSet.BoolVarP(&options.ExcludeIps, "exclude-ip", "ei", false, "Exclude ips from the list of domains"),
)
createGroup(flagSet, "debug", "Debug",

View File

@ -6,6 +6,7 @@ import (
"io"
"os"
"path"
"regexp"
"strings"
"github.com/pkg/errors"
@ -71,9 +72,11 @@ func (r *Runner) RunEnumeration(ctx context.Context) error {
// We keep enumerating subdomains for a given domain until we reach an error
func (r *Runner) EnumerateMultipleDomains(ctx context.Context, reader io.Reader, outputs []io.Writer) error {
scanner := bufio.NewScanner(reader)
ip, _ := regexp.Compile(`^([0-9\.]+$)`)
for scanner.Scan() {
domain, err := sanitize(scanner.Text())
if errors.Is(err, ErrEmptyInput) {
isIp := ip.MatchString(domain)
if errors.Is(err, ErrEmptyInput) || (r.options.ExcludeIps && isIp) {
continue
}