class Shodanz::Client

General client container class for all three of the available API endpoints in a convenient place to use.

@author Kent 'picat' Gruber

Attributes

exploits_api[R]

@return [Shodanz::API::Exploits]

rest_api[R]

@return [Shodanz::API::REST]

streaming_api[R]

@return [Shodanz::API::Streaming]

Public Class Methods

new(key: ENV['SHODAN_API_KEY']) click to toggle source

Create a new client to connect to any of the APIs.

Optionally provide your Shodan API key, or the environment variable SHODAN_API_KEY will be used.

# File lib/shodanz/client.rb, line 21
def initialize(key: ENV['SHODAN_API_KEY'])
  raise Shodanz::Errors::NoAPIKey if key.nil?

  # pass the given API key to each of the underlying clients
  #
  # Note: you can optionally change these API keys later, if you
  # had multiple for whatever reason. ;)
  #
  @rest_api      = Shodanz.api.rest.new(key: key)
  @streaming_api = Shodanz.api.streaming.new(key: key)
  @exploits_api  = Shodanz.api.exploits.new(key: key)
end

Public Instance Methods

community_queries(**params) click to toggle source
# File lib/shodanz/client.rb, line 70
def community_queries(**params)
  rest_api.community_queries(params)
end
crawl_for(**params) click to toggle source
# File lib/shodanz/client.rb, line 62
def crawl_for(**params)
  rest_api.scan(params)
end
exploit_count(query = '', page: 1, **params) click to toggle source
# File lib/shodanz/client.rb, line 114
def exploit_count(query = '', page: 1, **params)
  exploits_api.count(query, page: page, **params)
end
honeypot_score(ip) click to toggle source
# File lib/shodanz/client.rb, line 102
def honeypot_score(ip)
  rest_api.honeypot_score(ip)
end
host(ip, **params) click to toggle source
# File lib/shodanz/client.rb, line 34
def host(ip, **params)
  rest_api.host(ip, **params)
end
host_count(query = '', facets: {}, **params) click to toggle source
# File lib/shodanz/client.rb, line 38
def host_count(query = '', facets: {}, **params)
  rest_api.host_count(query, facets: facets, **params)
end
host_search_tokens(query = '', **params) click to toggle source
# File lib/shodanz/client.rb, line 46
def host_search_tokens(query = '', **params)
  rest_api.host_search(query, params)
end
http_headers() click to toggle source
# File lib/shodanz/client.rb, line 94
def http_headers
  rest_api.http_headers
end
info() click to toggle source
# File lib/shodanz/client.rb, line 106
def info
  rest_api.info
end
my_ip() click to toggle source
# File lib/shodanz/client.rb, line 98
def my_ip
  rest_api.my_ip
end
ports() click to toggle source
# File lib/shodanz/client.rb, line 50
def ports
  rest_api.ports
end
profile() click to toggle source
# File lib/shodanz/client.rb, line 82
def profile
  rest_api.profile
end
protocols() click to toggle source
# File lib/shodanz/client.rb, line 54
def protocols
  rest_api.protocols
end
resolve(*hostnames) click to toggle source
# File lib/shodanz/client.rb, line 86
def resolve(*hostnames)
  rest_api.resolve(hostnames)
end
reverse_lookup(*ips) click to toggle source
# File lib/shodanz/client.rb, line 90
def reverse_lookup(*ips)
  rest_api.reverse_lookup(ips)
end
scan(*ips) click to toggle source
# File lib/shodanz/client.rb, line 58
def scan(*ips)
  rest_api.scan(ips)
end
scan_status(id) click to toggle source
# File lib/shodanz/client.rb, line 66
def scan_status(id)
  rest_api.scan_status(id)
end
search_for_community_query(query, **params) click to toggle source
# File lib/shodanz/client.rb, line 74
def search_for_community_query(query, **params)
  rest_api.search_for_community_query(query, params)
end