resolve

package
v2.0.0-...-eb6a9d5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultSanitizer

func DefaultSanitizer(domain string) string

DefaultSanitizer is the default sanitizer function. It transforms the domain to lower characters, and ensures only valid characters are present. Returns an empty string if the domain fails sanitization.

Types

type CacheReader

type CacheReader struct {
	// contains filtered or unexported fields
}

CacheReader reads a DNS cache from a file and can fill a wildcarder.DNSCache object, save valid domains to a file, and count valid domains. The number of items processed can be limited to a specific number, and subsequent calls to Read will resume without starting over.

func NewCacheReader

func NewCacheReader(r io.ReadCloser) *CacheReader

NewCacheReader returns a new CacheReader.

func (CacheReader) Close

func (c CacheReader) Close() error

Close closes the input reader.

func (CacheReader) Read

func (c CacheReader) Read(w io.Writer, cache *wildcarder.DNSCache, maxCount int) (count int, err error)

Read reads a massdns cache from a file (created with -o Snl), can save the valid domains to a writer, fill a wildcarder.DNSCache object, and return the number of valid domains in the cache. Subsequent calls to Read will resume without starting over.

type DefaultMassResolver

type DefaultMassResolver struct {
	// contains filtered or unexported fields
}

DefaultMassResolver implements the MassResolver interface.

func NewDefaultMassResolver

func NewDefaultMassResolver(binPath string) *DefaultMassResolver

NewDefaultMassResolver creates a new DefaultMassResolver.

func (*DefaultMassResolver) Resolve

func (m *DefaultMassResolver) Resolve(r io.Reader, output string, total int, resolversFilename string, qps int) error

Resolve calls massdns to resolve the domains contained in the input file.

type DefaultRequirementChecker

type DefaultRequirementChecker struct {
	// contains filtered or unexported fields
}

DefaultRequirementChecker checks that the required binaries are present.

func NewDefaultRequirementChecker

func NewDefaultRequirementChecker(executor Executor) DefaultRequirementChecker

NewDefaultRequirementChecker returns a new checker object used to validate whether the required binaries can be run.

func (DefaultRequirementChecker) Check

Check makes sure that massdns can be executed on the system. If not, it displays a message to help the user fix the issue.

type DefaultResolverLoader

type DefaultResolverLoader struct{}

DefaultResolverLoader loads resolvers from a text file.

func NewDefaultResolverFileLoader

func NewDefaultResolverFileLoader() *DefaultResolverLoader

NewDefaultResolverFileLoader creates a new ResolverFileLoader instance.

func (*DefaultResolverLoader) Load

func (l *DefaultResolverLoader) Load(ctx *ctx.Ctx, filename string) error

Load parses the specified filename to load resolvers and saves them to the program context.

type DefaultWildcardFilter

type DefaultWildcardFilter struct {
	// contains filtered or unexported fields
}

DefaultWildcardFilter implements the WildcardFilter interface used to filter wildcards.

func NewDefaultWildcardFilter

func NewDefaultWildcardFilter() *DefaultWildcardFilter

NewDefaultWildcardFilter returns a new DefaultWildcardFilter object.

func (*DefaultWildcardFilter) Filter

func (f *DefaultWildcardFilter) Filter(opt WildcardFilterOptions, totalCount int) (found int, roots []string, err error)

Filter returns the number of domains that are not wildcards along with the wildcard roots found. It uses the massdns cache file to prepopulate a cache of DNS responses to optimize the number of DNS queries to perform. It saves the results to the specified filenames.

type DefaultWorkfileCreator

type DefaultWorkfileCreator struct {
	// contains filtered or unexported fields
}

DefaultWorkfileCreator is a service that creates a set of workfiles on disk.

func NewDefaultWorkfileCreator

func NewDefaultWorkfileCreator() *DefaultWorkfileCreator

NewDefaultWorkfileCreator creates a new set of temporary files. Call Close() to cleanup the files once they are no longer needed.

func (*DefaultWorkfileCreator) Create

func (w *DefaultWorkfileCreator) Create() (*Workfiles, error)

Create creates a new set of workfiles.

type DomainReader

type DomainReader struct {
	// contains filtered or unexported fields
}

DomainReader implements an io.Reader interface that generates subdomains to resolve. It reads data line by line from a source scanner. This data is either words that will be prefixed to a domain to create subdomains, or a straight list of subdomains to resolve. The DomainReader will also discard any generated domains that do not pass the specified domain sanitizer filter if present.

func NewDomainReader

func NewDomainReader(source io.ReadCloser, domains []string, sanitizer DomainSanitizer) *DomainReader

NewDomainReader creates a new DomainReader. If domains is not empty, the source reader is expected to contain words that will be prefixed to the domains to create subdomains.

func (*DomainReader) Read

func (r *DomainReader) Read(p []byte) (int, error)

Read creates and returns subdomains in the buffer specified.

type DomainSanitizer

type DomainSanitizer func(domain string) string

DomainSanitizer is a function that sanitizes a domain, typically removing invalid characters. If the domain cannot be sanitized or is invalid, an empty string is expected.

type Executor

type Executor interface {
	Shell(name string, arg ...string) error
}

Executor is a simple interface to execute shell commands.

type MassResolver

type MassResolver interface {
	Resolve(reader io.Reader, output string, total int, resolversFilename string, qps int) error
}

MassResolver resolves the domains contained in the input file using the resolvers present in the resolvers file and saves the results. Queries per second can be limited by setting the qps argument (0 for unlimited).

type RequirementChecker

type RequirementChecker interface {
	Check(opt *ctx.ResolveOptions) error
}

RequirementChecker checks if the dependencies are present on the system.

type ResolverLoader

type ResolverLoader interface {
	Load(ctx *ctx.Ctx, filename string) error
}

ResolverLoader loads the resolvers from a file and put them into the application context.

type ResultFileSaver

type ResultFileSaver struct {
	// contains filtered or unexported fields
}

ResultFileSaver is responsible for saving the results of the resolve operation to files.

func NewResultFileSaver

func NewResultFileSaver() *ResultFileSaver

NewResultFileSaver creates a new ResultSaver object.

func (*ResultFileSaver) Save

func (s *ResultFileSaver) Save(workfiles *Workfiles, opt *ctx.ResolveOptions) error

Save saves the results contained in the working files according to the specified options.

type ResultSaver

type ResultSaver interface {
	Save(workfiles *Workfiles, opt *ctx.ResolveOptions) error
}

ResultSaver saves the results as direction by the options specified.

type Service

type Service struct {
	Context *ctx.Ctx
	Options *ctx.ResolveOptions

	RequirementChecker RequirementChecker
	ResolverLoader     ResolverLoader
	WorkfileCreator    WorkfileCreator
	MassResolver       MassResolver
	ResultSaver        ResultSaver
	WildcardFilter     WildcardFilter
	// contains filtered or unexported fields
}

Service contains the interfaces required to operate the service.

func NewService

func NewService(ctx *ctx.Ctx, opt *ctx.ResolveOptions) *Service

NewService creates a new ResolveService object.

func (*Service) Close

func (s *Service) Close(debug bool)

Close terminates the service.

func (*Service) Initialize

func (s *Service) Initialize() error

Initialize makes sure that the required binaries can be run and that all the required files are present.

func (*Service) Resolve

func (s *Service) Resolve() error

Resolve resolves domain names contained in a file and saves the output according to the program context.

type WildcardFilter

type WildcardFilter interface {
	Filter(opt WildcardFilterOptions, totalCount int) (found int, roots []string, err error)
}

WildcardFilter filters the wildcard subdomains from a list of domains.

type WildcardFilterOptions

type WildcardFilterOptions struct {
	// Input files
	CacheFilename string

	// Output files
	DomainOutputFilename string
	RootOutputFilename   string

	// Filtering parameters
	Resolvers        []string
	QueriesPerSecond int
	ThreadCount      int
	ResolveTestCount int
	BatchSize        int
}

WildcardFilterOptions defines the options for the Filter function.

type WorkfileCreator

type WorkfileCreator interface {
	Create() (*Workfiles, error)
}

WorkfileCreator creates a new set of workfiles used during the program execution.

type Workfiles

type Workfiles struct {
	TempDirectory string

	Domains        string
	MassdnsPublic  string
	MassdnsTrusted string
	Temporary      string

	PublicResolvers  string
	TrustedResolvers string

	WildcardRoots string
}

Workfiles are temporary files used during the program execution.

func (*Workfiles) Close

func (w *Workfiles) Close()

Close deletes all the temporary files that were created.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL