Sha256: 952e215d178cfb27c36bc3d3bd7c769a5fb68dc710c8f4c2d20fa36bf07c295a

Contents?: true

Size: 938 Bytes

Versions: 4

Compression:

Stored size: 938 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Clients
    #
    # DNSTwister API client
    #
    class DNSTwister < Base
      #
      # @param [String] base_url
      # @param [Hash] headers
      # @param [Integer, nil] timeout
      #
      def initialize(base_url = "https://dnstwister.report", headers: {}, timeout: nil)
        super(base_url, headers:, timeout:)
      end

      #
      # Get fuzzy domains
      #
      # @param [String] domain
      #
      # @return [Array<String>]
      #
      def fuzz(domain)
        res = get_json("/api/fuzz/#{to_hex(domain)}")
        fuzzy_domains = res["fuzzy_domains"] || []
        fuzzy_domains.map { |d| d["domain"] }
      end

      private

      #
      # Converts string to hex
      #
      # @param [String] str String
      #
      # @return [String] Hex
      #
      def to_hex(str)
        str.each_byte.map { |b| b.to_s(16) }.join
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mihari-7.6.1 lib/mihari/clients/dnstwister.rb
mihari-7.6.0 lib/mihari/clients/dnstwister.rb
mihari-7.5.0 lib/mihari/clients/dnstwister.rb
mihari-7.4.0 lib/mihari/clients/dnstwister.rb