Sha256: 768196220ab541c694c2a0cde44b3765866282a61238f26827d989fa0c45d7a7

Contents?: true

Size: 721 Bytes

Versions: 34

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true

require "net/https"

module Mihari
  module Enrichers
    class Shodan < Base
      # @return [Boolean]
      def valid?
        true
      end

      class << self
        include Memist::Memoizable

        #
        # Query Shodan Internet DB
        #
        # @param [String] ip
        #
        # @return [Mihari::Structs::Shodan::InternetDBResponse, nil]
        #
        def query(ip)
          url = "https://internetdb.shodan.io/#{ip}"
          res = HTTP.get(url)
          data = JSON.parse(res.body.to_s)

          Structs::Shodan::InternetDBResponse.from_dynamic! data
        rescue HTTPError
          nil
        end
        memoize :query
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
mihari-5.4.3 lib/mihari/enrichers/shodan.rb
mihari-5.4.2 lib/mihari/enrichers/shodan.rb
mihari-5.4.1 lib/mihari/enrichers/shodan.rb
mihari-5.4.0 lib/mihari/enrichers/shodan.rb
mihari-5.3.2 lib/mihari/enrichers/shodan.rb
mihari-5.3.1 lib/mihari/enrichers/shodan.rb
mihari-5.3.0 lib/mihari/enrichers/shodan.rb
mihari-5.2.4 lib/mihari/enrichers/shodan.rb
mihari-5.2.3 lib/mihari/enrichers/shodan.rb
mihari-5.2.2 lib/mihari/enrichers/shodan.rb
mihari-5.2.1 lib/mihari/enrichers/shodan.rb
mihari-5.2.0 lib/mihari/enrichers/shodan.rb
mihari-5.1.4 lib/mihari/enrichers/shodan.rb
mihari-5.1.3 lib/mihari/enrichers/shodan.rb
mihari-5.1.2 lib/mihari/enrichers/shodan.rb
mihari-5.1.1 lib/mihari/enrichers/shodan.rb
mihari-5.1.0 lib/mihari/enrichers/shodan.rb
mihari-5.0.1 lib/mihari/enrichers/shodan.rb
mihari-5.0.0 lib/mihari/enrichers/shodan.rb
mihari-4.12.0 lib/mihari/enrichers/shodan.rb