core

package
v5.1.3-0...-3506166 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ALT      = "alt"
	ARCHIVE  = "archive"
	API      = "api"
	AXFR     = "axfr"
	BRUTE    = "brute"
	CERT     = "cert"
	DNS      = "dns"
	EXTERNAL = "ext"
	SCRAPE   = "scrape"
)

Request tag types.

View Source
const (
	NewNameTopic      = "amass:newname" //Появился новый домен
	NewAddrTopic      = "amass:newaddr"
	NewSubdomainTopic = "amass:newsub"
	ResolveNameTopic  = "amass:resolve" //Нужно отрезолвить Домен
	NameResolvedTopic = "amass:resolved"
	ReverseSweepTopic = "amass:sweep"      //new IP, cdir in asn
	ActiveCertTopic   = "amass:activecert" //new IP
	OutputTopic       = "amass:output"     //Готово - выводим
	IPToASNTopic      = "amass:iptoasn"
	NewASNTopic       = "amass:asn"
	WhoisRequestTopic = "amass:whoisreq"
	NewWhoisTopic     = "amass:whoisinfo"
)

Request Pub/Sub topics used across Amass.

View Source
const (
	PriorityLow int = iota
	PriorityHigh
	PriorityCritical
)

The priority levels for DNS resolution.

View Source
const (
	APIKeyRequired int = iota
	APIKeyNotRequired
	APIkeyOptional
)

Possible values for the AmassService.APIKeyRequired field.

View Source
const (
	// ServiceRequestChanLength is the length of the chan that pulls requests off the queue.
	ServiceRequestChanLength int = 1000
)

Variables

This section is empty.

Functions

func GetListFromFile

func GetListFromFile(path string) ([]string, error)

GetListFromFile reads a wordlist text or gzip file and returns the slice of words

func GetResolversFromSettings

func GetResolversFromSettings(path string) ([]string, error)

GetResolversFromSettings loads the configuration file and returns all resolvers found.

func RemoveLastDot

func RemoveLastDot(name string) string

RemoveLastDot removes the '.' at the end of the provided FQDN.

func ReverseDNS

func ReverseDNS(addr string) (string, string, error)

ReverseDNS is performs reverse DNS queries without using the DNSService object.

func SetCustomResolvers

func SetCustomResolvers(res []string)

SetCustomResolvers modifies the set of resolvers used during enumeration.

func SubdomainToDomain

func SubdomainToDomain(name string) string

SubdomainToDomain returns the first subdomain name of the provided parameter that responds to a DNS query for the NS record type.

Types

type APIKey

type APIKey struct {
	Username string `ini:"username"`
	Password string `ini:"password"`
	Key      string `ini:"apikey"`
	Secret   string `ini:"secret"`
}

APIKey contains values required for authenticating with web APIs.

type ASNRequest

type ASNRequest struct {
	Address        string
	ASN            int
	Prefix         string
	CC             string
	Registry       string
	AllocationDate time.Time
	Description    string
	Netblocks      []string
	Tag            string
	Source         string
}

ASNRequest handles all autonomous system information needed by Amass.

type AddrRequest

type AddrRequest struct {
	Address string
	Domain  string
	Tag     string
	Source  string
}

AddrRequest handles data needed throughout Service processing of a network address.

type AddressInfo

type AddressInfo struct {
	Address     net.IP     `json:"ip"`
	Netblock    *net.IPNet `json:"-"`
	CIDRStr     string     `json:"cidr"`
	ASN         int        `json:"asn"`
	Description string     `json:"desc"`
}

AddressInfo stores all network addressing info for the Output type.

type BaseService

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

BaseService provides common mechanisms to all Amass services in the enumeration architecture. It is used to compose a type that completely meets the AmassService interface.

func NewBaseService

func NewBaseService(srv Service, name string, config *Config, bus *EventBus) *BaseService

NewBaseService returns an initialized BaseService object.

func (*BaseService) ASNRequestChan

func (bas *BaseService) ASNRequestChan() <-chan *ASNRequest

ASNRequestChan returns the channel that provides new service requests.

func (*BaseService) ASNRequestLen

func (bas *BaseService) ASNRequestLen() int

ASNRequestLen returns the current length of the request queue.

func (*BaseService) AddrRequestChan

func (bas *BaseService) AddrRequestChan() <-chan *AddrRequest

AddrRequestChan returns the channel that provides new service requests.

func (*BaseService) AddrRequestLen

func (bas *BaseService) AddrRequestLen() int

AddrRequestLen returns the current length of the request queue.

func (*BaseService) Bus

func (bas *BaseService) Bus() *EventBus

Bus returns the EventBus that handles communication for the enumeration.

func (*BaseService) Config

func (bas *BaseService) Config() *Config

Config returns the Config for the enumeration this service supports.

func (*BaseService) DNSRequestChan

func (bas *BaseService) DNSRequestChan() <-chan *DNSRequest

DNSRequestChan returns the channel that provides new service requests.

func (*BaseService) DNSRequestLen

func (bas *BaseService) DNSRequestLen() int

DNSRequestLen returns the current length of the request queue.

func (*BaseService) IsActive

func (bas *BaseService) IsActive() bool

IsActive returns true if SetActive has been called for the service within the last 3 seconds.

func (*BaseService) LowNumberOfNames

func (bas *BaseService) LowNumberOfNames() error

LowNumberOfNames calls the OnLowNumberOfNames method implemented for the Service.

func (*BaseService) OnLowNumberOfNames

func (bas *BaseService) OnLowNumberOfNames() error

OnLowNumberOfNames is a placeholder that should be implemented by a Service that has code to be executed when the enumeration is low in names to resolve.

func (*BaseService) OnPause

func (bas *BaseService) OnPause() error

OnPause implements the Service interface

func (*BaseService) OnResume

func (bas *BaseService) OnResume() error

OnResume implements the Service interface

func (*BaseService) OnStart

func (bas *BaseService) OnStart() error

OnStart is a placeholder that should be implemented by an Service that has code to execute during service start.

func (*BaseService) OnStop

func (bas *BaseService) OnStop() error

OnStop is a placeholder that should be implemented by a Service that has code to execute during service stop.

func (*BaseService) Pause

func (bas *BaseService) Pause() error

Pause implements the Service interface

func (*BaseService) PauseChan

func (bas *BaseService) PauseChan() <-chan struct{}

PauseChan returns the pause channel for the service.

func (*BaseService) Quit

func (bas *BaseService) Quit() <-chan struct{}

Quit return the quit channel for the service.

func (*BaseService) Resume

func (bas *BaseService) Resume() error

Resume implements the Service interface

func (*BaseService) ResumeChan

func (bas *BaseService) ResumeChan() <-chan struct{}

ResumeChan returns the resume channel for the service.

func (*BaseService) SendASNRequest

func (bas *BaseService) SendASNRequest(req *ASNRequest)

SendASNRequest adds the request provided by the parameter to the service request channel.

func (*BaseService) SendAddrRequest

func (bas *BaseService) SendAddrRequest(req *AddrRequest)

SendAddrRequest adds the request provided by the parameter to the service request channel.

func (*BaseService) SendDNSRequest

func (bas *BaseService) SendDNSRequest(req *DNSRequest)

SendDNSRequest adds the request provided by the parameter to the service request channel.

func (*BaseService) SendWhoisRequest

func (bas *BaseService) SendWhoisRequest(req *WhoisRequest)

SendWhoisRequest adds the request provided by the parameter to the service request channel.

func (*BaseService) SetActive

func (bas *BaseService) SetActive()

SetActive marks the service as being active at time.Now() for future checks performed by the IsActive method.

func (*BaseService) Start

func (bas *BaseService) Start() error

Start calls the OnStart method implemented for the Service.

func (*BaseService) Stats

func (bas *BaseService) Stats() *ServiceStats

Stats returns current ServiceStats that provide performance metrics

func (*BaseService) Stop

func (bas *BaseService) Stop() error

Stop calls the OnStop method implemented for the Service.

func (*BaseService) String

func (bas *BaseService) String() string

String returns the name of the service.

func (*BaseService) WhoisRequestChan

func (bas *BaseService) WhoisRequestChan() <-chan *WhoisRequest

WhoisRequestChan returns the channel that provides new service requests.

func (*BaseService) WhoisRequestLen

func (bas *BaseService) WhoisRequestLen() int

WhoisRequestLen returns the current length of the request queue.

type Config

type Config struct {
	sync.Mutex

	//Append to output Out of scope domain
	IncludeOutOfScope bool

	//Append to domain root all domain if have same admin eMail
	IncludeDomainByAdminMail bool

	// A Universally Unique Identifier (UUID) for the enumeration
	UUID uuid.UUID

	// Logger for error messages
	Log *log.Logger

	// The writer used to save the data operations performed
	DataOptsWriter io.Writer

	// The directory that stores the bolt db and other files created
	Dir string `ini:"output_directory"`

	// The settings for connecting with a Gremlin Server
	GremlinURL  string
	GremlinUser string
	GremlinPass string

	// The maximum number of concurrent DNS queries
	MaxDNSQueries int `ini:"maximum_dns_queries"`

	// Semaphore to enforce the maximum DNS queries
	SemMaxDNSQueries utils.Semaphore

	// The IP addresses specified as in scope
	Addresses []net.IP

	// CIDR that is in scope
	CIDRs []*net.IPNet

	// ASNs specified as in scope
	ASNs []int

	// The ports that will be checked for certificates
	Ports []int

	// The list of words to use when generating names
	Wordlist []string

	// Will the enumeration including brute forcing techniques
	BruteForcing bool `ini:"brute_forcing"`

	// Will recursive brute forcing be performed?
	Recursive bool `ini:"recursive_brute_forcing"`

	// Minimum number of subdomain discoveries before performing recursive brute forcing
	MinForRecursive int `ini:"minimum_for_recursive"`

	// Will discovered subdomain name alterations be generated?
	Alterations    bool
	FlipWords      bool
	FlipNumbers    bool
	AddWords       bool
	AddNumbers     bool
	MinForWordFlip int
	EditDistance   int
	AltWordlist    []string

	// Only access the data sources for names and return results?
	Passive bool

	// Determines if zone transfers will be attempted
	Active bool

	// Determines if unresolved DNS names will be output by the enumeration
	IncludeUnresolvable bool `ini:"include_unresolvable"`

	// A blacklist of subdomain names that will not be investigated
	Blacklist []string

	// A list of data sources that should not be utilized
	DisabledDataSources []string
	// contains filtered or unexported fields
}

Config passes along Amass enumeration configurations

func (*Config) AddAPIKey

func (c *Config) AddAPIKey(source string, ak *APIKey)

AddAPIKey adds the data source and API key association provided to the configuration.

func (*Config) AddDomain

func (c *Config) AddDomain(domain string)

AddDomain appends the domain name provided in the parameter to the list in the configuration.

func (*Config) AddDomains

func (c *Config) AddDomains(domains []string)

AddDomains appends the domain names provided in the parameter to the list in the configuration.

func (*Config) Blacklisted

func (c *Config) Blacklisted(name string) bool

Blacklisted returns true is the name in the parameter ends with a subdomain name in the config blacklist.

func (*Config) CheckSettings

func (c *Config) CheckSettings() error

CheckSettings runs some sanity checks on the configuration options selected.

func (*Config) DomainRegex

func (c *Config) DomainRegex(domain string) *regexp.Regexp

DomainRegex returns the Regexp object for the domain name identified by the parameter.

func (*Config) Domains

func (c *Config) Domains() []string

Domains returns the list of domain names currently in the configuration.

func (*Config) ExcludeDisabledDataSources

func (c *Config) ExcludeDisabledDataSources(services []Service) []Service

ExcludeDisabledDataSources returns a list of data sources excluding DisabledDataSources.

func (*Config) GetAPIKey

func (c *Config) GetAPIKey(source string) *APIKey

GetAPIKey returns the API key associated with the provided data source name.

func (*Config) IsAddressInScope

func (c *Config) IsAddressInScope(addr string) bool

IsAddressInScope returns true if the addr parameter matches provided network scope and when no network scope has been set.

func (*Config) IsDomainInScope

func (c *Config) IsDomainInScope(name string) bool

IsDomainInScope returns true if the DNS name in the parameter ends with a domain in the config list.

func (*Config) LoadSettings

func (c *Config) LoadSettings(path string) error

LoadSettings parses settings from an .ini file and assigns them to the Config.

func (*Config) WhichDomain

func (c *Config) WhichDomain(name string) string

WhichDomain returns the domain in the config list that the DNS name in the parameter ends with.

type DNSAnswer

type DNSAnswer struct {
	Name string `json:"name"`
	Type int    `json:"type"`
	TTL  int    `json:"TTL"`
	Data string `json:"data"`
}

DNSAnswer is the type used by Amass to represent a DNS record.

func Resolve

func Resolve(name, qtype string, priority int) ([]DNSAnswer, error)

Resolve allows all components to make DNS requests without using the DNSService object.

type DNSRequest

type DNSRequest struct {
	Name    string
	Domain  string
	Records []DNSAnswer
	Tag     string
	Source  string
}

DNSRequest handles data needed throughout Service processing of a DNS name.

func NsecTraversal

func NsecTraversal(domain, server string) ([]*DNSRequest, error)

NsecTraversal attempts to retrieve a DNS zone using NSEC-walking.

func ZoneTransfer

func ZoneTransfer(sub, domain, server string) ([]*DNSRequest, error)

ZoneTransfer attempts a DNS zone transfer using the server identified in the parameters. The returned slice contains all the records discovered from the zone transfer.

type EventBus

type EventBus struct {
	sync.Mutex
	// contains filtered or unexported fields
}

EventBus handles sending and receiving events across Amass.

func NewEventBus

func NewEventBus() *EventBus

NewEventBus initializes and returns an EventBus object.

func (*EventBus) Publish

func (eb *EventBus) Publish(topic string, args ...interface{})

Publish sends req on the channel labeled with name.

func (*EventBus) Stop

func (eb *EventBus) Stop()

Stop prevents any additional requests from being sent.

func (*EventBus) Subscribe

func (eb *EventBus) Subscribe(topic string, fn interface{})

Subscribe registers callback to be executed for all requests on the channel.

func (*EventBus) Unsubscribe

func (eb *EventBus) Unsubscribe(topic string, fn interface{})

Unsubscribe deregisters the callback from the channel.

type MetricsCollector

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

MetricsCollector provides Amass services with the ability to track performance.

func NewMetricsCollector

func NewMetricsCollector(srv Service) *MetricsCollector

NewMetricsCollector returns an initialized MetricsCollector.

func (*MetricsCollector) NamesRemainingCallback

func (mc *MetricsCollector) NamesRemainingCallback(nrc func() int)

NamesRemainingCallback updates the names remaining callback routine.

func (*MetricsCollector) QueryTime

func (mc *MetricsCollector) QueryTime(t time.Time)

QueryTime allows a DNS query event time to be posted with the MetricsCollector.

func (*MetricsCollector) Stats

func (mc *MetricsCollector) Stats() *ServiceStats

Stats returns ServiceStats for the metrics collected by this MetricsCollector.

func (*MetricsCollector) Stop

func (mc *MetricsCollector) Stop()

Stop halts execution of the metrics collector.

type Output

type Output struct {
	Timestamp  time.Time
	Name       string        `json:"name"`
	Domain     string        `json:"domain"`
	Addresses  []AddressInfo `json:"addresses"`
	Tag        string        `json:"tag"`
	Source     string        `json:"source"`
	OutOfScope bool          `json:"out_of_scope"`
}

Output contains all the output data for an enumerated DNS name.

type ResolveError

type ResolveError struct {
	Err   string
	Rcode int
}

ResolveError contains the Rcode returned during the DNS query.

func (*ResolveError) Error

func (e *ResolveError) Error() string

type Service

type Service interface {
	// Start the service
	Start() error
	OnStart() error

	// Pause the service
	Pause() error
	OnPause() error

	// Resume the service
	Resume() error
	OnResume() error

	// Stop the service
	Stop() error
	OnStop() error

	// Architecture is ready for more names
	LowNumberOfNames() error
	OnLowNumberOfNames() error

	// Methods to support processing of DNSRequests
	SendDNSRequest(req *DNSRequest)
	DNSRequestChan() <-chan *DNSRequest
	DNSRequestLen() int

	// Methods to support processing of AddrRequests
	SendAddrRequest(req *AddrRequest)
	AddrRequestChan() <-chan *AddrRequest
	AddrRequestLen() int

	// Methods to support processing of ASNRequests
	SendASNRequest(req *ASNRequest)
	ASNRequestChan() <-chan *ASNRequest
	ASNRequestLen() int

	// Methods to support processing of WhoisRequests
	SendWhoisRequest(req *WhoisRequest)
	WhoisRequestChan() <-chan *WhoisRequest
	WhoisRequestLen() int

	IsActive() bool
	SetActive()

	// Returns channels that fire during Pause/Resume operations
	PauseChan() <-chan struct{}
	ResumeChan() <-chan struct{}

	// Returns a channel that is closed when the service is stopped
	Quit() <-chan struct{}

	// String description of the service
	String() string

	// Returns the configuration for the enumeration this service supports
	Config() *Config

	// Returns the event bus that handles communication for the enumeration
	Bus() *EventBus

	// Returns current ServiceStats that provide performance metrics
	Stats() *ServiceStats
}

Service is the object type for a service running within the Amass enumeration architecture.

type ServiceStats

type ServiceStats struct {
	DNSQueriesPerSec int
	NamesRemaining   int
	AddrsRemaining   int
}

ServiceStats provides metrics from an Amass service.

type WhoisRequest

type WhoisRequest struct {
	Domain     string
	Company    string
	Email      string
	NewDomains []string
	Tag        string
	Source     string
}

WhoisRequest handles data needed throughout Service processing of reverse whois.

Jump to

Keyboard shortcuts

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