Sha256: db2dc5273cea9f29df49a46b29ef9505f0265c36e66d22da0f858a4d567454a6
Contents?: true
Size: 1.15 KB
Versions: 8
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true require "censysx" module Mihari module Analyzers class Censys < Base param :query option :title, default: proc { "Censys search" } option :description, default: proc { "query = #{query}" } option :tags, default: proc { [] } def artifacts search end private def search ipv4s = [] cursor = nil loop do response = api.search(query, cursor: cursor) ipv4s << response_to_ipv4s(response) links = response.dig("result", "links") cursor = links["next"] break if cursor == "" end ipv4s.flatten end # # Extract IPv4s from Censys search API response # # @param [Hash] response # # @return [Array<String>] # def response_to_ipv4s(response) hits = response.dig("result", "hits") || [] hits.map { |hit| hit["ip"] } end def configuration_keys %w[censys_id censys_secret] end def api @api ||= ::Censys::API.new(Mihari.config.censys_id, Mihari.config.censys_secret) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems