Sha256: 0d8c979222e0539e3b4f61bff42a749506b7b6fb387a28d97ddd6420eced0c45
Contents?: true
Size: 1.38 KB
Versions: 27
Compression:
Stored size: 1.38 KB
Contents
# frozen_string_literal: true require "dnstwister" module Mihari module Analyzers class DNSTwister < Base include Mixins::Refang param :query option :tags, default: proc { [] } attr_reader :type def initialize(*args, **kwargs) super @query = refang(query) @type = TypeChecker.type(query) end def artifacts search || [] end private # # Check whether a type is valid or not # # @return [Boolean] # def valid_type? type == "domain" end def api @api ||= ::DNSTwister::API.new end # # Check whether a domain is resolvable or not # # @param [String] domain # # @return [Boolean] # def resolvable?(domain) Resolv.getaddress domain true rescue Resolv::ResolvError => _e false end # # Search # # @return [Array<String>] # def search raise InvalidInputError, "#{query}(type: #{type || "unknown"}) is not supported." unless valid_type? res = api.fuzz(query) fuzzy_domains = res["fuzzy_domains"] || [] domains = fuzzy_domains.map { |domain| domain["domain"] } Parallel.map(domains) do |domain| resolvable?(domain) ? domain : nil end.compact end end end end
Version data entries
27 entries across 27 versions & 1 rubygems