Sha256: 7124ef0351ad979bea0c32148f8541cb33a8732c115b07514a5b4daff2508215
Contents?: true
Size: 1.37 KB
Versions: 5
Compression:
Stored size: 1.37 KB
Contents
# frozen_string_literal: true require "passive_circl" module Mihari module Analyzers class CIRCL < Base attr_reader :title, :description, :tags def initialize(query, title: nil, description: nil, tags: []) super() @query = query @type = TypeChecker.type(query) @title = title || "CIRCL passive lookup" @description = description || "query = #{query}" @tags = tags end def artifacts lookup || [] end private def config_keys %w[circl_passive_password circl_passive_username] end def api @api ||= ::PassiveCIRCL::API.new(username: Mihari.config.circl_passive_username, password: Mihari.config.circl_passive_password) end def lookup case @type when "domain" passive_dns_lookup when "hash" passive_ssl_lookup else raise InvalidInputError, "#{@query}(type: #{@type || "unknown"}) is not supported." end end def passive_dns_lookup results = api.dns.query(@query) results.map do |result| type = result["rrtype"] type == "A" ? result["rdata"] : nil end.compact.uniq end def passive_ssl_lookup result = api.ssl.cquery(@query) seen = result["seen"] || [] seen.uniq end end end end
Version data entries
5 entries across 5 versions & 1 rubygems