Documentation ¶
Index ¶
- Constants
- Variables
- func LogDebug(format string, a ...interface{})
- func LogErr(format string, a ...interface{})
- func LogInfo(format string, a ...interface{})
- func LogPanic(format string, a ...interface{})
- type ASRecord
- type BGPResolution
- type BGPResolver
- type CTAggregatedLog
- type CTLog
- type CTResolution
- type CTResolver
- type DNSRecord
- type DNSRecordPair
- type DNSResolution
- type DNSResolver
- type DomainRelationFn
- type DomainResolver
- type GeoRecord
- type GeoResolution
- type GeoResolver
- type HTTPHeader
- type HTTPResolution
- type HTTPResolver
- type IPResolver
- type Resolution
- type ResolutionBase
- type ResolutionType
- type TLSCertificate
- type TLSResolution
- type TLSResolver
- type Udig
- type WhoisContact
- type WhoisResolution
- type WhoisResolver
Constants ¶
const ( LogLevelDebug = 0 LogLevelInfo = 10 LogLevelErr = 100 LogLevelNone = 1000 )
Logging levels: the smaller value the more verbose the output will be.
const DefaultCTApiUrl = "https://crt.sh"
const ( // DefaultTimeout is a default timeout used in all network clients. DefaultTimeout = 3 * time.Second )
Variables ¶
var CTApiUrl = DefaultCTApiUrl
var CTExclude = "expired"
var CTLogFrom = time.Now().AddDate(-1, 0, 0).Format("2006-01-02")
var ( // DefaultDNSQueryTypes is a list of default DNS RR types that we query. DefaultDNSQueryTypes = [...]uint16{ dns.TypeA, dns.TypeNS, dns.TypeSOA, dns.TypeMX, dns.TypeTXT, dns.TypeSIG, dns.TypeKEY, dns.TypeAAAA, dns.TypeSRV, dns.TypeCERT, dns.TypeDNAME, dns.TypeOPT, dns.TypeKX, dns.TypeDS, dns.TypeRRSIG, dns.TypeNSEC, dns.TypeDNSKEY, dns.TypeNSEC3, dns.TypeNSEC3PARAM, dns.TypeTKEY, dns.TypeTSIG, dns.TypeIXFR, dns.TypeAXFR, dns.TypeMAILB, dns.TypeANY, } )
var ( // DefaultHTTPHeaders is a list of default HTTP header names that we look for. DefaultHTTPHeaders = [...]string{ "access-control-allow-origin", "alt-svc", "content-security-policy", "content-security-policy-report-only", } )
var (
// GeoDBPath is a path to IP2Location DB file.
GeoDBPath = findGeoipDatabase("IP2LOCATION-LITE-DB1.IPV6.BIN")
)
var LogLevel = LogLevelDebug
LogLevel contains the actual log level setting.
var ( // SupportedWhoisProperties is a set of WHOIS properties that WhoisResolver honors. SupportedWhoisProperties = map[string]bool{ "registry domain id": true, "registrant": true, "registrant organization": true, "registrant state/province": true, "registrant country": true, "registrar": true, "registrar iana id": true, "registrar whois server": true, "registrar url": true, "creation date": true, "updated date": true, "registered": true, "changed": true, "expire": true, "nsset": true, "contact": true, "name": true, "address": true, } )
Functions ¶
func LogDebug ¶
func LogDebug(format string, a ...interface{})
LogDebug formats and prints a given log on STDOUT.
func LogErr ¶
func LogErr(format string, a ...interface{})
LogErr formats and prints a given log on STDERR.
Types ¶
type BGPResolution ¶ added in v1.3.0
type BGPResolution struct { *ResolutionBase Records []ASRecord }
BGPResolution is a BGP resolution of a given IP yielding AS records.
func (*BGPResolution) Type ¶ added in v1.3.0
func (res *BGPResolution) Type() ResolutionType
Type returns "BGP".
type BGPResolver ¶ added in v1.3.0
type BGPResolver struct { IPResolver Client *dns.Client // contains filtered or unexported fields }
BGPResolver is a Resolver which is able to resolve an IP to AS name and ASN.
Internally this resolver is leveraging a DNS interface of IP-to-ASN lookup service by Team Cymru.
func NewBGPResolver ¶ added in v1.3.0
func NewBGPResolver() *BGPResolver
NewBGPResolver creates a new BGPResolver with sensible defaults.
func (*BGPResolver) ResolveIP ¶ added in v1.3.0
func (resolver *BGPResolver) ResolveIP(ip string) Resolution
ResolveIP resolves a given IP address to a list of corresponding AS records.
func (*BGPResolver) Type ¶ added in v1.3.0
func (resolver *BGPResolver) Type() ResolutionType
Type returns "BGP".
type CTAggregatedLog ¶ added in v1.5.0
CTAggregatedLog is a wrapper of a CT log that is aggregated over all logs with the same CN in time.
func (*CTAggregatedLog) String ¶ added in v1.5.0
func (log *CTAggregatedLog) String() string
type CTLog ¶ added in v1.5.0
type CTLog struct { Id int64 `json:"id"` IssuerName string `json:"issuer_name"` NameValue string `json:"name_value"` LoggedAt string `json:"entry_timestamp"` NotBefore string `json:"not_before"` NotAfter string `json:"not_after"` }
CTLog is a wrapper for attributes of interest that appear in the CT log. The json mapping comes from crt.sh API schema.
func (*CTLog) ExtractDomains ¶ added in v1.5.0
type CTResolution ¶ added in v1.5.0
type CTResolution struct { *ResolutionBase Logs []CTAggregatedLog }
CTResolution is a certificate transparency project resolution, which yields a CT log.
func (*CTResolution) Domains ¶ added in v1.5.0
func (res *CTResolution) Domains() (domains []string)
Domains returns a list of domains discovered in records within this Resolution.
func (*CTResolution) Type ¶ added in v1.5.0
func (res *CTResolution) Type() ResolutionType
Type returns "CT".
type CTResolver ¶ added in v1.5.0
type CTResolver struct { DomainResolver Client *http.Client // contains filtered or unexported fields }
CTResolver is a Resolver responsible for resolution of a given domain to a list of CT logs.
func NewCTResolver ¶ added in v1.5.0
func NewCTResolver() *CTResolver
NewCTResolver creates a new CTResolver with sensible defaults.
func (*CTResolver) ResolveDomain ¶ added in v1.5.0
func (resolver *CTResolver) ResolveDomain(domain string) Resolution
ResolveDomain resolves a given domain to a list of TLS certificates.
func (*CTResolver) Type ¶ added in v1.5.0
func (resolver *CTResolver) Type() ResolutionType
Type returns "CT".
type DNSRecordPair ¶
DNSRecordPair is a pair of DNS record type used in the query and a corresponding record found in the answer.
type DNSResolution ¶
type DNSResolution struct { *ResolutionBase Records []DNSRecordPair // contains filtered or unexported fields }
DNSResolution is a DNS multi-query resolution yielding many DNS records in a form of query-answer pairs.
func (*DNSResolution) Domains ¶
func (res *DNSResolution) Domains() (domains []string)
Domains returns a list of domains discovered in records within this Resolution.
func (*DNSResolution) IPs ¶ added in v1.3.0
func (res *DNSResolution) IPs() (ips []string)
IPs returns a list of IP addresses discovered in this resolution.
type DNSResolver ¶
type DNSResolver struct { DomainResolver QueryTypes []uint16 NameServer string Client *dns.Client // contains filtered or unexported fields }
DNSResolver is a Resolver which is able to resolve a domain to a bunch of the most interesting DNS records.
You can configure which query types are actually used and you can also supply a custom name server. If you don't a name server for each domain is discovered using NS record query, falling back to a local NS (e.g. the one in /etc/resolv.conf).
func NewDNSResolver ¶
func NewDNSResolver() *DNSResolver
NewDNSResolver creates a new DNS resolver instance pre-populated with sensible defaults.
func (*DNSResolver) ResolveDomain ¶ added in v1.3.0
func (resolver *DNSResolver) ResolveDomain(domain string) Resolution
ResolveDomain attempts to resolve a given domain for every DNS record type defined in resolver.QueryTypes using either a user-supplied name-server or dynamically resolved one for this domain.
type DomainRelationFn ¶ added in v1.4.0
var ( DefaultDomainRelation DomainRelationFn = func(domainA string, domainB string) bool { return isDomainRelated(domainA, domainB, false) } StrictDomainRelation DomainRelationFn = func(domainA string, domainB string) bool { return isDomainRelated(domainA, domainB, true) } IsDomainRelated = DefaultDomainRelation )
type DomainResolver ¶ added in v1.3.0
type DomainResolver interface {
ResolveDomain(domain string) Resolution // Resolves a given domain.
}
DomainResolver is an API contract for all Resolver modules that resolve domains. Discovered domains that relate to the original query are recursively resolved.
type GeoRecord ¶ added in v1.3.0
type GeoRecord struct {
CountryCode string
}
GeoRecord contains information about a geographical location.
type GeoResolution ¶ added in v1.3.0
type GeoResolution struct { *ResolutionBase Record *GeoRecord }
GeoResolution is a GeoIP resolution of a given IP yielding geographical records.
func (*GeoResolution) Type ¶ added in v1.3.0
func (res *GeoResolution) Type() ResolutionType
Type returns "BGP".
type GeoResolver ¶ added in v1.3.0
type GeoResolver struct { IPResolver // contains filtered or unexported fields }
GeoResolver is a Resolver which is able to resolve an IP to a geographical location.
func NewGeoResolver ¶ added in v1.3.0
func NewGeoResolver() *GeoResolver
NewGeoResolver creates a new GeoResolver with sensible defaults.
func (*GeoResolver) ResolveIP ¶ added in v1.3.0
func (resolver *GeoResolver) ResolveIP(ip string) Resolution
ResolveIP resolves a given IP address to a corresponding GeoIP record.
func (*GeoResolver) Type ¶ added in v1.3.0
func (resolver *GeoResolver) Type() ResolutionType
Type returns "GEO".
type HTTPHeader ¶ added in v1.2.0
HTTPHeader is a pair of HTTP header name and corresponding value(s).
func (*HTTPHeader) String ¶ added in v1.2.0
func (header *HTTPHeader) String() string
type HTTPResolution ¶ added in v1.2.0
type HTTPResolution struct { *ResolutionBase Headers []HTTPHeader }
HTTPResolution is a HTTP header resolution yielding many HTTP protocol headers.
func (*HTTPResolution) Domains ¶ added in v1.2.0
func (res *HTTPResolution) Domains() (domains []string)
Domains returns a list of domains discovered in records within this Resolution.
func (*HTTPResolution) Type ¶ added in v1.2.0
func (res *HTTPResolution) Type() ResolutionType
Type returns "HTTP".
type HTTPResolver ¶ added in v1.2.0
type HTTPResolver struct { DomainResolver Headers []string Client *http.Client }
HTTPResolver is a Resolver responsible for resolution of a given domain to a list of corresponding HTTP headers.
func NewHTTPResolver ¶ added in v1.2.0
func NewHTTPResolver() *HTTPResolver
NewHTTPResolver creates a new HTTPResolver with sensible defaults.
func (*HTTPResolver) ResolveDomain ¶ added in v1.3.0
func (resolver *HTTPResolver) ResolveDomain(domain string) Resolution
ResolveDomain resolves a given domain to a list of corresponding HTTP headers.
func (*HTTPResolver) Type ¶ added in v1.2.0
func (resolver *HTTPResolver) Type() ResolutionType
Type returns "HTTP".
type IPResolver ¶ added in v1.3.0
type IPResolver interface {
ResolveIP(ip string) Resolution // Resolves a given IP.
}
IPResolver is an API contract for all Resolver modules that resolve IPs.
type Resolution ¶
type Resolution interface { Type() ResolutionType // Returns a type of this resolution. Query() string // Returns the queried domain or IP. Domains() []string // Returns a list of domains discovered in this resolution. IPs() []string // Returns a list of IP addresses discovered in this resolution. }
Resolution is an API contract for all Resolutions (i.e. results).
type ResolutionBase ¶
type ResolutionBase struct { Resolution `json:"-"` // contains filtered or unexported fields }
ResolutionBase is a shared implementation for all Resolutions (i.e. results).
func (*ResolutionBase) Domains ¶ added in v1.3.0
func (res *ResolutionBase) Domains() (domains []string)
Domains returns a list of domains discovered in this resolution.
func (*ResolutionBase) IPs ¶ added in v1.3.0
func (res *ResolutionBase) IPs() (ips []string)
IPs returns a list of IP addresses discovered in this resolution.
type ResolutionType ¶
type ResolutionType string
ResolutionType is an enumeration type for resolutions types.
const ( // TypeDNS is a type of all DNS resolutions. TypeDNS ResolutionType = "DNS" // TypeWHOIS is a type of all WHOIS resolutions. TypeWHOIS ResolutionType = "WHOIS" // TypeTLS is a type of all TLS resolutions. TypeTLS ResolutionType = "TLS" // TypeHTTP is a type of all HTTP resolutions. TypeHTTP ResolutionType = "HTTP" // TypeCT is a type of all CT resolutions. TypeCT ResolutionType = "CT" // TypeBGP is a type of all BGP resolutions. TypeBGP ResolutionType = "BGP" // TypeGEO is a type of all GeoIP resolutions. TypeGEO ResolutionType = "GEO" )
type TLSCertificate ¶ added in v1.1.0
type TLSCertificate struct {
x509.Certificate
}
TLSCertificate is a wrapper for the actual x509.Certificate.
func (*TLSCertificate) String ¶ added in v1.1.0
func (cert *TLSCertificate) String() string
type TLSResolution ¶
type TLSResolution struct { *ResolutionBase Certificates []TLSCertificate }
TLSResolution is a TLS handshake resolution, which yields a certificate chain.
func (*TLSResolution) Domains ¶
func (res *TLSResolution) Domains() (domains []string)
Domains returns a list of domains discovered in records within this Resolution.
type TLSResolver ¶
type TLSResolver struct { DomainResolver Client *http.Client }
TLSResolver is a Resolver responsible for resolution of a given domain to a list of TLS certificates.
func NewTLSResolver ¶
func NewTLSResolver() *TLSResolver
NewTLSResolver creates a new TLSResolver with sensible defaults.
func (*TLSResolver) ResolveDomain ¶ added in v1.3.0
func (resolver *TLSResolver) ResolveDomain(domain string) Resolution
ResolveDomain resolves a given domain to a list of TLS certificates.
type Udig ¶
type Udig interface { Resolve(domain string) []Resolution AddDomainResolver(resolver DomainResolver) AddIPResolver(resolver IPResolver) }
Udig is a high-level facade for domain resolution which:
- delegates work to specific resolvers
- deals with domain crawling
- caches intermediate results and summarizes the outputs
type WhoisContact ¶
WhoisContact is just a set of key/value pairs.
Note that all map keys are lowercase intentionally. For a default list of supported properties refer to `udig.SupportedWhoisProperties`.
func (*WhoisContact) String ¶ added in v1.1.0
func (contact *WhoisContact) String() string
type WhoisResolution ¶
type WhoisResolution struct { *ResolutionBase Contacts []WhoisContact }
WhoisResolution is a WHOIS query resolution yielding many contacts.
func (*WhoisResolution) Domains ¶
func (res *WhoisResolution) Domains() (domains []string)
Domains returns a list of domains discovered in records within this Resolution.
func (*WhoisResolution) Type ¶
func (res *WhoisResolution) Type() ResolutionType
Type returns "WHOIS".
type WhoisResolver ¶
type WhoisResolver struct { DomainResolver Client *whois.Client }
WhoisResolver is a Resolver responsible for resolution of a given domain to a list of WHOIS contacts.
func NewWhoisResolver ¶
func NewWhoisResolver() *WhoisResolver
NewWhoisResolver creates a new WhoisResolver instance provisioned with sensible defaults.
func (*WhoisResolver) ResolveDomain ¶ added in v1.3.0
func (resolver *WhoisResolver) ResolveDomain(domain string) Resolution
ResolveDomain attempts to resolve a given domain using WHOIS query yielding a list of WHOIS contacts.
func (*WhoisResolver) Type ¶
func (resolver *WhoisResolver) Type() ResolutionType
Type returns "WHOIS".