Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wildcard filter not work when RunEnumeration multi times #315

Closed
faint-star opened this issue May 2, 2024 · 1 comment · Fixed by #313
Closed

wildcard filter not work when RunEnumeration multi times #315

faint-star opened this issue May 2, 2024 · 1 comment · Fixed by #313
Assignees
Labels
Status: Completed Nothing further to be done with this issue. Awaiting to be closed. Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.

Comments

@faint-star
Copy link

faint-star commented May 2, 2024

shuffledns version:

v1.0.9

Current Behavior:

wildcard filter not work when RunEnumeration multi times

Expected Behavior:

wildcard filter should be work when RunEnumeration multi times

Steps To Reproduce:

cmd/shuffledns/main.go:

package main

import (
	"github.com/projectdiscovery/gologger"
	"github.com/projectdiscovery/shuffledns/pkg/runner"
)

func main() {
	// RunEnumeration first time
	options := runner.ShufflednsDefaultOptions()
	options.Domain = "eastmoney.cn"
	massdnsRunner, err := runner.New(options)
	if err != nil {
		gologger.Fatal().Msgf("Could not create runner: %s\n", err)
	}
	massdnsRunner.RunEnumeration()
	massdnsRunner.Close()

	// RunEnumeration second time
	options2 := runner.ShufflednsDefaultOptions()
	options2.Domain = "eastmoney.cn"
	massdnsRunner2, err := runner.New(options)
	if err != nil {
		gologger.Fatal().Msgf("Could not create runner: %s\n", err)
	}
	massdnsRunner2.RunEnumeration()
	massdnsRunner2.Close()
}

ShufflednsDefaultOptions:

func ShufflednsDefaultOptions() *Options {
	return &Options{
		Directory: "",
		//SubdomainsList:     "",
		ResolversFile:      "resolve.txt",
		Wordlist:           "words.txt",
		MassdnsPath:        "massdns.exe",
		Json:               false,
		Silent:             false,
		Version:            false,
		Retries:            5,
		Verbose:            true,
		NoColor:            false,
		Threads:            10000,
		MassdnsRaw:         "",
		WildcardThreads:    25,
		WildcardOutputFile: "",
		MassDnsCmd:         "",
		Stdin:              false,
		DisableUpdateCheck: false,
		StrictWildcard:     true,
	}
}

resolve.txt:

119.29.29.29
182.254.116.116
1.1.1.1
114.114.115.115
114.114.114.114
8.8.8.8
223.5.5.5
119.29.29.29

words.txt:

pop
imap
smtp
act
d
mail
test1
test2
test3
test4
test5
test6

frist output:
you can see the junk domains has been filtered
image

second output:
the filter not work
image

Anything else:

@faint-star faint-star added the Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors. label May 2, 2024
@faint-star
Copy link
Author

Maybe I found the reason:the pkg/wildcards/resolver.go:33,the code to genrate resolver is:

// AddServersFromList adds the resolvers from a list of servers
func (w *Resolver) AddServersFromList(list []string) {
	for i := 0; i < len(list); i++ {
		list[i] = list[i] + ":53"
	}
	w.servers, _ = transport.New(list...)
}

when the first RunEnumeration run, the excellentResolvers slice will be changed. So RunEnumeration again,the resolves will be 1.1.1.1:53:53, 1.1.1.1:53:53:53 and so on
image
So I change the code and it work correctly

// AddServersFromList adds the resolvers from a list of servers
func (w *Resolver) AddServersFromList(list []string) {
	var resolvers []string
	for i := 0; i < len(list); i++ {
		resolvers = append(resolvers, list[i]+":53")
	}
	w.servers, _ = transport.New(resolvers...)
}

and I notice the pkg/massdns/massdns.go:61
image
it use resolver.AddServersFromList(excellentResolvers) to generate resolvers, but shuffledns must be input resolvers.txt, but I didn't saw the use of ResolversFile, maybe the code shoud be this ?
image

@Mzack9999 Mzack9999 self-assigned this May 3, 2024
@Mzack9999 Mzack9999 linked a pull request May 3, 2024 that will close this issue
@ehsandeep ehsandeep added the Status: Completed Nothing further to be done with this issue. Awaiting to be closed. label May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Completed Nothing further to be done with this issue. Awaiting to be closed. Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants