Sha256: bdbda43e8e020cb20782e55167f6fc004558a5313b5a8596de15b7193fcf3eb4

Contents?: true

Size: 1.4 KB

Versions: 4

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

module Mihari
  module Analyzers
    #
    # CIRCL passive DNS/SSL analyzer
    #
    class CIRCL < Base
      include Concerns::Refangable

      # @return [String, nil]
      attr_reader :type

      # @return [String, nil]
      attr_reader :username

      # @return [String, nil]
      attr_reader :password

      #
      # @param [String] query
      # @param [Hash, nil] options
      # @param [String, nil] username
      # @param [String, nil] password
      #
      def initialize(query, options: nil, username: nil, password: nil)
        super(refang(query), options: options)

        @type = DataType.type(query)

        @username = username || Mihari.config.circl_passive_username
        @password = password || Mihari.config.circl_passive_password
      end

      def artifacts
        case type
        when "domain"
          client.passive_dns_search query
        when "hash"
          client.passive_ssl_search query
        else
          raise ValueError, "#{@query}(type: #{@type || "unknown"}) is not supported."
        end
      end

      def configured?
        configuration_keys? || (username? && password?)
      end

      private

      def client
        Clients::CIRCL.new(username: username, password: password, timeout: timeout)
      end

      def username?
        !username.nil?
      end

      def password?
        !password.nil?
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mihari-7.3.2 lib/mihari/analyzers/circl.rb
mihari-7.3.1 lib/mihari/analyzers/circl.rb
mihari-7.3.0 lib/mihari/analyzers/circl.rb
mihari-7.2.0 lib/mihari/analyzers/circl.rb