这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions v2/pkg/runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ func ParseOptions() *Options {
os.Exit(0)
}

options.preProcessOptions()

// Validate the options passed by the user and if any
// invalid options have been used, exit.
err = options.validateOptions()
Expand Down Expand Up @@ -160,3 +162,7 @@ func listSources(options *Options) {
gologger.Silent().Msgf(message, source)
}
}

func (options *Options) preProcessOptions() {
options.Domain, _ = sanitize(options.Domain)
}
6 changes: 3 additions & 3 deletions v2/pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"path"

"github.com/pkg/errors"
"github.com/projectdiscovery/gologger"
"github.com/projectdiscovery/subfinder/v2/pkg/passive"
"github.com/projectdiscovery/subfinder/v2/pkg/resolve"
Expand Down Expand Up @@ -83,12 +84,11 @@ func (r *Runner) RunEnumeration(ctx context.Context) error {
func (r *Runner) EnumerateMultipleDomains(ctx context.Context, reader io.Reader, outputs []io.Writer) error {
scanner := bufio.NewScanner(reader)
for scanner.Scan() {
domain := scanner.Text()
if domain == "" {
domain, err := sanitize(scanner.Text())
if errors.Is(err, ErrEmptyInput) {
continue
}

var err error
var file *os.File
// If the user has specified an output file, use that output file instead
// of creating a new output file for each domain. Else create a new file
Expand Down
20 changes: 18 additions & 2 deletions v2/pkg/runner/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package runner
import (
"bufio"
"os"
"strings"

"github.com/pkg/errors"
)

func loadFromFile(file string) ([]string, error) {
Expand All @@ -14,11 +17,24 @@ func loadFromFile(file string) ([]string, error) {
defer f.Close()
scanner := bufio.NewScanner(f)
for scanner.Scan() {
text := scanner.Text()
if text == "" {
text, err := sanitize(scanner.Text())
if errors.Is(err, ErrEmptyInput) {
continue
}
items = append(items, text)
}
return items, scanner.Err()
}

var (
ErrEmptyInput = errors.New("empty data")
)

func sanitize(data string) (string, error) {
data = strings.Trim(data, "\n\t\"' ")
if data == "" {
return "", ErrEmptyInput
}

return data, nil
}