config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 25 Imported by: 6

Documentation

Index

Constants

View Source
const DefaultQueriesPerBaselineResolver = 15

DefaultQueriesPerBaselineResolver is the number of queries sent to each trusted DNS resolver per second.

View Source
const DefaultQueriesPerPublicResolver = 5

DefaultQueriesPerPublicResolver is the number of queries sent to each public DNS resolver per second.

Variables

View Source
var PublicResolvers = []string{
	"8.8.8.8",
	"1.1.1.1",
	"9.9.9.9",
	"77.88.8.1",
}

PublicResolvers includes the addresses of public resolvers obtained dynamically.

Functions

func AcquireConfig

func AcquireConfig(dir, file string, cfg *Config) error

AcquireConfig populates the Config struct provided by the Config argument.

func ExpandMask

func ExpandMask(word string) ([]string, error)

ExpandMask will return a slice of words that a "hashcat-style" mask matches.

func ExpandMaskWordlist

func ExpandMaskWordlist(wordlist []string) ([]string, error)

ExpandMaskWordlist performs ExpandMask on a slice of words.

func GetListFromFile

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

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

func OutputDirectory

func OutputDirectory(dir ...string) string

OutputDirectory returns the file path of the Amass output directory. A suitable path provided will be used as the output directory instead.

Types

type Config

type Config struct {
	sync.Mutex `yaml:"-" json:"-"`

	// A Universally Unique Identifier (UUID) for the enumeration
	UUID uuid.UUID `yaml:"-" json:"-"`

	// The pseudo-random number generator
	Rand *rand.Rand `yaml:"-" json:"-"`

	// Logger for error messages
	Log *log.Logger `yaml:"-" json:"-"`

	// The date/time that discoveries must be active since to be included in the findings
	CollectionStartTime time.Time `yaml:"-" json:"-"`

	// Scope struct that contains ASN, CIDR, Domain, IP, and ports in scope
	Scope *Scope `yaml:"scope,omitempty" json:"scope,omitempty"`

	// Defines options like datasources config path and stuff like that
	Options map[string]interface{} `yaml:"options,omitempty" json:"-"`

	// Filepath of the configuration file. It is needed as a seed incase of relative paths in the config.
	Filepath string `yaml:"-" json:"-"`

	// Alternative directory for scripts provided by the user
	ScriptsDirectory string `yaml:"-" json:"-"`

	// The directory that stores the bolt db and other files created
	Dir string `yaml:"-" json:"-"`

	// The graph databases used by the system / enumerations
	GraphDBs []*Database `yaml:"-" json:"database,omitempty"`

	// The maximum number of concurrent DNS queries
	MaxDNSQueries int `yaml:"-" json:"-"`

	// The list of words to use when generating names
	Wordlist []string `yaml:"-" json:"wordlist,omitempty"`

	// Will the enumeration including brute forcing techniques
	BruteForcing bool `yaml:"-" json:"brute_force,omitempty"`

	// Will recursive brute forcing be performed?
	Recursive bool `yaml:"-" json:"-"`

	// Minimum number of subdomain discoveries before performing recursive brute forcing
	MinForRecursive int `yaml:"-" json:"-"`

	// Maximum depth for bruteforcing
	MaxDepth int `yaml:"-" json:"-"`

	// Will discovered subdomain name alterations be generated?
	Alterations    bool     `yaml:"-" json:"alterations,omitempty"`
	FlipWords      bool     `yaml:"-" json:"-"`
	FlipNumbers    bool     `yaml:"-" json:"-"`
	AddWords       bool     `yaml:"-" json:"-"`
	AddNumbers     bool     `yaml:"-" json:"-"`
	MinForWordFlip int      `yaml:"-" json:"-"`
	EditDistance   int      `yaml:"-" json:"-"`
	AltWordlist    []string `yaml:"-" json:"alt_worldlist,omitempty"`

	// Only access the data sources for names and return results?
	Passive bool `yaml:"-" json:"-"`

	// Determines if zone transfers will be attempted
	Active bool `yaml:"-" json:"-"`

	// A list of data sources that should not be utilized
	SourceFilter struct {
		Include bool     `yaml:"-" json:"-"` // true = include, false = exclude
		Sources []string `yaml:"-" json:"-"`
	} `yaml:"-" json:"-"`

	// The minimum number of minutes that data source responses will be reused
	MinimumTTL int `yaml:"-" json:"-"`

	// Type of DNS records to query for
	RecordTypes []string `yaml:"-" json:"-"`

	// Resolver settings
	Resolvers        []string `yaml:"-" json:"resolvers"`
	ResolversQPS     int      `yaml:"-" json:"-"`
	TrustedResolvers []string `yaml:"-" json:"trusted_resolvers,omitempty"`
	TrustedQPS       int      `yaml:"-" json:"-"`

	// Option for verbose logging and output
	Verbose bool `yaml:"-" json:"-"`

	// Names provided to seed the enumeration
	ProvidedNames []string `yaml:"-" json:"-"`

	// Mode should be determined based on scripts utilized
	Mode string `yaml:"-" json:"-"`

	// The data source configurations
	DataSrcConfigs *DataSourceConfig `yaml:"-" json:"datasource_config"`

	// The Transformations map will contain incoming assets, and what handlers should be called.
	Transformations map[string]*Transformation `yaml:"transformations" json:"transformations"`

	// The engine APIURI configuration
	EngineAPI *EngAPI `yaml:"-" json:"-"`
	// contains filtered or unexported fields
}

Config passes along Amass configuration settings and options.

func NewConfig

func NewConfig() *Config

NewConfig returns a default configuration object.

func (*Config) AbsPathFromConfigDir

func (c *Config) AbsPathFromConfigDir(path string) (string, error)

AbsPathFromConfigDir Creates a file path that is relative the the configuration file location. If the path is already absolute, return it as is.

func (*Config) AcquireScripts

func (c *Config) AcquireScripts() ([]string, error)

AcquireScripts returns all the default and user provided scripts for data sources.

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) AddResolver

func (c *Config) AddResolver(resolver string)

AddResolver appends the untrusted resolver name provided in the parameter to the list in the configuration.

func (*Config) AddResolvers

func (c *Config) AddResolvers(resolvers ...string)

AddResolvers appends the untrusted resolver names provided in the parameter to the list in the configuration.

func (*Config) AddTrustedResolver

func (c *Config) AddTrustedResolver(resolver string)

AddTrustedResolver appends the trusted resolver name provided in the parameter to the list in the configuration.

func (*Config) AddTrustedResolvers

func (c *Config) AddTrustedResolvers(resolvers ...string)

AddTrustedResolvers appends the trusted resolver names provided in the parameter to the list in the configuration.

func (*Config) BlacklistSubdomain

func (c *Config) BlacklistSubdomain(name string)

BlacklistSubdomain adds a subdomain name to the config blacklist.

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) CalcMaxQPS

func (c *Config) CalcMaxQPS()

CalcMaxQPS updates the MaxDNSQueries field of the configuration based on current settings.

func (*Config) CheckSettings

func (c *Config) CheckSettings() error

CheckSettings runs some sanity checks on the configuration options selected.

func (*Config) CheckTransformations

func (c *Config) CheckTransformations(from string, tos ...string) (*Matches, error)

CheckTransformations checks if the given 'From' type has a valid transformation to any of the given 'To' types.

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) GetDataSourceConfig

func (c *Config) GetDataSourceConfig(source string) *DataSource

GetDataSourceConfig returns the DataSourceConfig associated with the data source name argument.

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 .yaml file and assigns them to the Config.

func (*Config) LocalDatabaseSettings

func (c *Config) LocalDatabaseSettings(dbs []*Database) *Database

LocalDatabaseSettings returns the Database for the local bolt store.

func (*Config) SetResolvers

func (c *Config) SetResolvers(resolvers ...string)

SetResolvers assigns the untrusted resolver names provided in the parameter to the list in the configuration.

func (*Config) SetTrustedResolvers

func (c *Config) SetTrustedResolvers(resolvers ...string)

SetTrustedResolvers assigns the trusted resolver names provided in the parameter to the list in the configuration.

func (*Config) UpdateConfig

func (c *Config) UpdateConfig(update Updater) error

UpdateConfig allows the provided Updater to update the current configuration.

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 Credentials

type Credentials struct {
	Name     string `yaml:"-" json:"-"`
	Username string `yaml:"username,omitempty" json:"username,omitempty"`
	Password string `yaml:"password,omitempty" json:"password,omitempty"`
	Apikey   string `yaml:"apikey,omitempty" json:"apikey,omitempty"`
	Secret   string `yaml:"secret,omitempty" json:"secret,omitempty"`
}

Credentials contains values required for authenticating with web APIs.

type DataSource

type DataSource struct {
	Name  string                  `yaml:"name,omitempty" json:"name,omitempty"`
	TTL   int                     `yaml:"ttl,omitempty" json:"ttl,omitempty"`
	Creds map[string]*Credentials `yaml:"creds,omitempty" json:"creds,omitempty"`
}

DataSource contains the configurations specific to a data source.

func (*DataSource) AddCredentials

func (ds *DataSource) AddCredentials(accountName string, cred *Credentials) error

AddCredentials adds the Credentials provided to the configuration.

type DataSourceConfig

type DataSourceConfig struct {
	Datasources   []*DataSource  `yaml:"datasources,omitempty" json:"datasources,omitempty"`
	GlobalOptions map[string]int `yaml:"global_options,omitempty" json:"global_options,omitempty"`
}

DataSourceConfig contains the configuration for multiple data sources.

func (*DataSourceConfig) GetCredentials

func (dsc *DataSourceConfig) GetCredentials(dsName string) *Credentials

GetCredentials returns the first set of Credentials associated with the given DataSource name.

func (*DataSourceConfig) MapNames

func (dsc *DataSourceConfig) MapNames()

MapNames assigns the name of the DataSource to each associated Credential's Name field. This is especially useful after unmarshalling data where the relationship between a DataSource and its credentials may not have been explicitly set in the source data.

type Database

type Database struct {
	System   string `json:"system,omitempty"`   // Database system type (Postgres, MySQL, etc.)
	Primary  bool   `json:"primary,omitempty"`  // Whether this database is the primary store
	URL      string `json:"url,omitempty"`      // Full URI to the database
	Username string `json:"username,omitempty"` // Username for authentication
	Password string `json:"password,omitempty"` // Password for authentication
	Host     string `json:"host,omitempty"`     // Host of the database
	Port     string `json:"port,omitempty"`     // Port of the database
	DBName   string `json:"db_name,omitempty"`  // Name of the database
	Options  string `json:"options,omitempty"`  // Extra options used while connecting to the database
}

Database contains values required for connecting with graph database.

type EngAPI

type EngAPI struct {
	Scheme   string // Engine API scheme (http, https)
	URL      string // Full URI to the Engine API
	Username string // Username for authentication
	Password string // Password for authentication
	Host     string // Host of the Engine API
	Port     string // Port of the Engine API
	Path     string // Name of the Engine API
	Options  string // Extra options used while connecting to the Engine API
}

EngAPI structure holds various components necessary for establishing a connection with an Engine API. It includes fields for the scheme (http or https), the full API URL, authentication credentials (username, password), host and port information, the specific path (name) of the API, and any extra options that may be used during the connection.

type Matches

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

Matches represents a collection of transform matches.

func (*Matches) IsMatch

func (m *Matches) IsMatch(to string) bool

IsMatch checks if a valid transformation to the given 'To' type is present.

func (*Matches) Len

func (m *Matches) Len() int

Len returns the number of matches in the result set.

type ParseIPs

type ParseIPs []net.IP

ParseIPs represents a slice of net.IP addresses.

func (*ParseIPs) Set

func (p *ParseIPs) Set(s string) error

Set implements the flag.Value interface.

func (*ParseIPs) String

func (p *ParseIPs) String() string

type Scope

type Scope struct {
	// The root domain names that the enumeration will target
	Domains []string `yaml:"domains,omitempty" json:"domains,omitempty"`

	// IP Net.IP
	Addresses []net.IP `yaml:"-" json:"ips,omitempty"`

	// The IP addresses specified as in scope
	IP []string `yaml:"ips,omitempty" json:"-"`

	// ASNs specified as in scope
	ASNs []int `yaml:"asns,omitempty" json:"asns,omitempty"`

	// CIDR IPNET
	CIDRs []*net.IPNet `yaml:"-" json:"cidrs,omitempty"`

	// CIDR in scope
	CIDRStrings []string `yaml:"cidrs,omitempty" json:"-"`

	// The ports checked for certificates
	Ports []int `yaml:"ports,omitempty" json:"ports,omitempty"`

	// A blacklist of subdomain names that will not be investigated
	Blacklist []string `yaml:"blacklist,omitempty" json:"blacklist,omitempty"`
}

Scope represents the configuration for the enumeration scope.

type Transformation

type Transformation struct {
	From       string   `yaml:"-" json:"-"`
	To         string   `yaml:"-" json:"-"`
	Priority   int      `yaml:"priority,omitempty" json:"priority,omitempty"`
	Confidence int      `yaml:"confidence,omitempty" json:"confidence,omitempty"`
	Exclude    []string `yaml:"exclude,omitempty" json:"exclude,omitempty"`
}

Transformation represents an individual transofmration with optional priority & confidence.

func (*Transformation) Split

func (t *Transformation) Split(key string) error

Split splits the key into 'From' and 'To' components, expecting a "->" delimiter. Requires a non-nil Transformation pointer and a valid key format. Example: FQDN->IPaddress

func (*Transformation) Validate

func (t *Transformation) Validate(c *Config) error

Validate checks the validity of a given transformation with respect to OAM & previously registered transformations. The function ensures OAM compliance & that there are no conflicts between transformations with 'none' (indicating no action) and other valid transformations for the same 'From' type.

type Updater

type Updater interface {
	OverrideConfig(*Config) error
}

Updater allows an object to implement a method that updates a configuration.

Jump to

Keyboard shortcuts

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