Documentation
¶
Index ¶
- Constants
- func CanonicalCertName(name string) string
- func CanonicalHostname(name string) (string, bool)
- func CenterString(str string, width int, symbol string) string
- func CertEmailAddresses(cert *x509.Certificate) []string
- func CertEmailDomains(cert *x509.Certificate) []string
- func CertHostnames(cert *x509.Certificate) []string
- func CertOrganizations(cert *x509.Certificate) []string
- func CertURIHosts(cert *x509.Certificate) []string
- func ChunkBy[T any](items []T, chunkSize int) (chunks [][]T)
- func Contains(s []string, e string) bool
- func ContainsFold(s []string, e string) bool
- func DNSDomainInArray(d []string, domain string) bool
- func EmailDomain(email string) (string, bool)
- func EncodingVariants(host string) []string
- func ExpandCIDR(cidr string) ([]string, error)
- func FQDNToSLD(FQDN string) (string, error)
- func GetLabelByLevelFromFQDN(fqdn string, level int) (string, string)
- func GetURLPath(rawURL string) string
- func IsCIDR(potentialCIDR string) bool
- func IsIPLiteral(name string) bool
- func IsPortOpen(host string, port string, timeout time.Duration) bool
- func IsValidHostname(name string) bool
- func MetaSplit(s []string, sep string) []string
- func ParseListFile(path string) ([]string, error)
- func RandStringBytes(n int) string
- func RemoveDuplicate[T string | int](sliceList []T) []T
- func RemoveEmpty[T string](s []T) []T
- func ResolveUserAgent(userAgent string) string
- func SanitizeHostname(name string) (string, bool)
- func SetUserAgent(req *http.Request, userAgent string)
- func SortDomains(domains []string)
- func SortIPAddresses(ipAddresses []string) []string
- func SplitIntoCidrAndPort(cidrWithPort string) (string, int, error)
- func WildcardOrFullMatch(hostname string, matchHostList []string) bool
Constants ¶
const DefaultUserAgent = "Mozilla/5.0 (compatible; SNItch/1.4; +https://github.com/cirosec/SNItch)"
DefaultUserAgent is the User-Agent sent on every outbound HTTP(S) request when the user does not override it via --user-agent. Go's default ("Go-http-client/1.1") is trivially fingerprintable and is blocked by some WAFs/CDNs, which would otherwise corrupt HTTP status and title results.
Variables ¶
This section is empty.
Functions ¶
func CanonicalCertName ¶ added in v1.4.0
CanonicalCertName normalizes a certificate name for display and comparison: IP literals (including bracketed IPv6 like "[::1]") become their canonical form so they deduplicate against the certificate's IP SANs; any other name is returned unchanged.
func CanonicalHostname ¶ added in v1.4.0
CanonicalHostname returns the canonical form of a hostname: trimmed, without trailing dots, lowercased, with IDN U-labels converted to punycode A-labels. A leading "*." wildcard prefix is preserved and canonicalized with the name. ok is false when the result is not a syntactically valid hostname; in that case no name is returned.
func CertEmailAddresses ¶ added in v1.4.0
func CertEmailAddresses(cert *x509.Certificate) []string
CertEmailAddresses returns every email address a certificate carries: SAN rfc822Name entries plus the legacy emailAddress attribute in the subject and issuer DNs. These often name the device vendor and are otherwise invisible to SNItch's DNS-SAN-only parsing.
func CertEmailDomains ¶ added in v1.4.0
func CertEmailDomains(cert *x509.Certificate) []string
CertEmailDomains returns the deduplicated domains of all email addresses in a certificate (see CertEmailAddresses). Only domains that are syntactically valid hostnames are returned.
func CertHostnames ¶ added in v1.4.0
func CertHostnames(cert *x509.Certificate) []string
func CertOrganizations ¶ added in v1.4.0
func CertOrganizations(cert *x509.Certificate) []string
CertOrganizations returns the organization (O) values of the subject and issuer DNs, deduplicated. Intended for display only: organization names are free text and must not be treated as hostnames.
func CertURIHosts ¶ added in v1.4.0
func CertURIHosts(cert *x509.Certificate) []string
CertURIHosts returns the hostnames of every URI SAN entry, deduplicated. Such URIs (e.g. a provisioning or management endpoint) can reveal a hostname that the DNS SANs omit.
func ContainsFold ¶ added in v1.4.0
func DNSDomainInArray ¶
DNSDomainInArray reports whether domain is covered by any entry in d. Matching is case-insensitive and ignores trailing dots. A wildcard entry ("*.example.com") covers exactly one label (RFC 6125): it matches "foo.example.com" but neither "a.b.example.com" nor "example.com".
func EmailDomain ¶ added in v1.4.0
EmailDomain returns the domain part of an email address, or ok=false when it carries no usable domain. Only the domain is returned: the local part is a mailbox, not a hostname.
func EncodingVariants ¶ added in v1.4.0
EncodingVariants returns de-duplicated alternative encodings of host that a TLS server might treat differently from the literal hostname. The input itself is never included. A trailing dot, uppercased form and the IDN A-label/U-label counterparts are considered.
func ExpandCIDR ¶
func GetLabelByLevelFromFQDN ¶
func GetURLPath ¶
GetURLPath extracts the path and query from a URL string, stripping scheme and host. This is used to compare redirect URLs from catch-all servers that echo back the requested hostname but redirect to the same path.
func IsIPLiteral ¶ added in v1.4.0
IsIPLiteral reports whether name is an IP address, accepting both bare and bracketed (IPv6) forms. Certificate SANs sometimes carry IP addresses in DNS-type entries, e.g. "127.0.0.1" or "[::1]".
func IsValidHostname ¶ added in v1.4.0
IsValidHostname reports whether name is syntactically a valid DNS hostname (RFC 1123, plus underscore-bearing labels such as "_dmarc.example.com" that occur in real SANs and DNS), optionally prefixed with "*." for a wildcard. It deliberately does not require a public suffix, so single-label names ("synology", "localhost") and internal names ("host.corp.local") are accepted as long as they are well-formed; SNItch is tolerant and after information.
func ParseListFile ¶
func RandStringBytes ¶
RandStringBytes generates a random string of n length
func RemoveDuplicate ¶
func RemoveEmpty ¶
func RemoveEmpty[T string](s []T) []T
func ResolveUserAgent ¶ added in v1.4.0
ResolveUserAgent returns the configured user agent, falling back to DefaultUserAgent when none was supplied.
func SanitizeHostname ¶ added in v1.4.0
CertHostnames returns the names a certificate may be matched against under a tolerant, legacy-compatible interpretation: its SAN DNS entries plus its CommonName. Modern clients ignore CN whenever SANs are present, but SNItch is looking for information rather than strict certificate correctness, so a CN-only certificate still surfaces the hostname it identifies. SanitizeHostname returns the canonical form of a candidate name (see CanonicalHostname) and reports whether it is a usable hostname. Names that fail validation must not be fed into the scan queue or used to build tree nodes.
func SetUserAgent ¶ added in v1.4.0
SetUserAgent sets the User-Agent header on req to the resolved user agent. It always sets a non-empty value so that Go's fingerprintable default is never sent.
func SortDomains ¶
func SortDomains(domains []string)
func SortIPAddresses ¶
func WildcardOrFullMatch ¶
WildcardOrFullMatch reports whether hostname is covered by an ignore-style match list. Entries are compared case-insensitively and without trailing dots. A "*.<domain>" entry matches the domain itself and every subdomain below it. A wildcard suffix without a label boundary ("*example.com") never matches, and a bare "*" matches nothing: use an explicit domain instead.
Types ¶
This section is empty.