class Apullo::Fingerprint::Domain

Constants

RESOURCES

Private Instance Methods

admin_contacts() click to toggle source
# File lib/apullo/fingerprints/domain.rb, line 75
def admin_contacts
  whois&.parser&.admin_contacts&.map(&:to_h)
rescue Whois::ParserError => _e
  []
end
build_results() click to toggle source
# File lib/apullo/fingerprints/domain.rb, line 21
def build_results
  {
    dns: resources,
    whois: contacts,
    meta: {
      links: links
    }
  }
end
contacts() click to toggle source
# File lib/apullo/fingerprints/domain.rb, line 87
def contacts
  return {} unless whois

  {
    registrant_contacts: registrant_contacts,
    admin_contacts: admin_contacts,
    technical_contacts: technical_contacts
  }
end
dns() click to toggle source
# File lib/apullo/fingerprints/domain.rb, line 31
def dns
  @dns ||= Resolv::DNS.new
end
registrant_contacts() click to toggle source
# File lib/apullo/fingerprints/domain.rb, line 69
def registrant_contacts
  whois&.parser&.registrant_contacts&.map(&:to_h)
rescue Whois::ParserError => _e
  []
end
resolve(resource) click to toggle source
# File lib/apullo/fingerprints/domain.rb, line 43
def resolve(resource)
  ress = dns.getresources(target.host, resource)
  values = ress.map do |res|
    if res.respond_to?(:address)
      res.address.to_s
    elsif res.respond_to?(:exchange)
      res.exchange.to_s
    elsif res.respond_to?(:name)
      res.name.to_s
    elsif res.respond_to?(:rname)
      res.rname.to_s
    end
  end.compact
  values.reject(&:empty?).empty? ? [] : values
end
resources() click to toggle source
# File lib/apullo/fingerprints/domain.rb, line 35
def resources
  @resources ||= RESOURCES.map do |resource|
    name = resource.to_s.split("::").last.to_s.downcase
    values = resolve(resource)
    [name, values]
  end.to_h
end
technical_contacts() click to toggle source
# File lib/apullo/fingerprints/domain.rb, line 81
def technical_contacts
  whois&.parser&.technical_contacts&.map(&:to_h)
rescue Whois::ParserError => _e
  []
end
whois() click to toggle source
# File lib/apullo/fingerprints/domain.rb, line 63
def whois
  @whois ||= whois_client.lookup(target.host)
rescue Timeout::Error, Whois::Error
  nil
end
whois_client() click to toggle source
# File lib/apullo/fingerprints/domain.rb, line 59
def whois_client
  @whois_client ||= Whois::Client.new(timeout: 3)
end