Class: Shodanz::Client
- Inherits:
-
Object
- Object
- Shodanz::Client
- Defined in:
- lib/shodanz/client.rb
Overview
General client container class for all three of the available API endpoints in a convenient place to use.
Instance Attribute Summary collapse
- #exploits_api ⇒ Shodanz::API::Exploits readonly
- #rest_api ⇒ Shodanz::API::REST readonly
- #streaming_api ⇒ Shodanz::API::Streaming readonly
Instance Method Summary collapse
- #community_queries(**params) ⇒ Object
- #crawl_for(**params) ⇒ Object
- #exploit_count(query = '', page: 1, **params) ⇒ Object
- #exploit_search(query = '', page: 1, **params) ⇒ Object
- #honeypot_score(ip) ⇒ Object
- #host(ip, **params) ⇒ Object
- #host_count(query = '', facets: {}, **params) ⇒ Object
- #host_search(query = '', facets: {}, page: 1, minify: true, **params) ⇒ Object
- #host_search_tokens(query = '', **params) ⇒ Object
- #http_headers ⇒ Object
- #info ⇒ Object
-
#initialize(key: ENV['SHODAN_API_KEY']) ⇒ Client
constructor
Create a new client to connect to any of the APIs.
- #my_ip ⇒ Object
- #popular_query_tags(size = 10) ⇒ Object
- #ports ⇒ Object
- #profile ⇒ Object
- #protocols ⇒ Object
- #resolve(*hostnames) ⇒ Object
- #reverse_lookup(*ips) ⇒ Object
- #scan(*ips) ⇒ Object
- #scan_status(id) ⇒ Object
- #search_for_community_query(query, **params) ⇒ Object
Constructor Details
#initialize(key: ENV['SHODAN_API_KEY']) ⇒ Client
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.
21 22 23 24 25 26 27 28 29 30 31 32 |
# 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 |
Instance Attribute Details
#exploits_api ⇒ Shodanz::API::Exploits (readonly)
15 16 17 |
# File 'lib/shodanz/client.rb', line 15 def exploits_api @exploits_api end |
#rest_api ⇒ Shodanz::API::REST (readonly)
11 12 13 |
# File 'lib/shodanz/client.rb', line 11 def rest_api @rest_api end |
#streaming_api ⇒ Shodanz::API::Streaming (readonly)
13 14 15 |
# File 'lib/shodanz/client.rb', line 13 def streaming_api @streaming_api end |
Instance Method Details
#community_queries(**params) ⇒ Object
70 71 72 |
# File 'lib/shodanz/client.rb', line 70 def community_queries(**params) rest_api.community_queries(params) end |
#crawl_for(**params) ⇒ Object
62 63 64 |
# File 'lib/shodanz/client.rb', line 62 def crawl_for(**params) rest_api.scan(params) end |
#exploit_count(query = '', page: 1, **params) ⇒ Object
114 115 116 |
# File 'lib/shodanz/client.rb', line 114 def exploit_count(query = '', page: 1, **params) exploits_api.count(query, page: page, **params) end |
#exploit_search(query = '', page: 1, **params) ⇒ Object
110 111 112 |
# File 'lib/shodanz/client.rb', line 110 def exploit_search(query = '', page: 1, **params) exploits_api.search(query, page: page, **params) end |
#honeypot_score(ip) ⇒ Object
102 103 104 |
# File 'lib/shodanz/client.rb', line 102 def honeypot_score(ip) rest_api.honeypot_score(ip) end |
#host(ip, **params) ⇒ Object
34 35 36 |
# File 'lib/shodanz/client.rb', line 34 def host(ip, **params) rest_api.host(ip, **params) end |
#host_count(query = '', facets: {}, **params) ⇒ Object
38 39 40 |
# File 'lib/shodanz/client.rb', line 38 def host_count(query = '', facets: {}, **params) rest_api.host_count(query, facets: facets, **params) end |
#host_search(query = '', facets: {}, page: 1, minify: true, **params) ⇒ Object
42 43 44 |
# File 'lib/shodanz/client.rb', line 42 def host_search(query = '', facets: {}, page: 1, minify: true, **params) rest_api.host_search(query, facets: facets, page: page, minify: minify, **params) end |
#host_search_tokens(query = '', **params) ⇒ Object
46 47 48 |
# File 'lib/shodanz/client.rb', line 46 def host_search_tokens(query = '', **params) rest_api.host_search(query, params) end |
#http_headers ⇒ Object
94 95 96 |
# File 'lib/shodanz/client.rb', line 94 def http_headers rest_api.http_headers end |
#info ⇒ Object
106 107 108 |
# File 'lib/shodanz/client.rb', line 106 def info rest_api.info end |
#my_ip ⇒ Object
98 99 100 |
# File 'lib/shodanz/client.rb', line 98 def my_ip rest_api.my_ip end |
#popular_query_tags(size = 10) ⇒ Object
78 79 80 |
# File 'lib/shodanz/client.rb', line 78 def (size = 10) rest_api.(size) end |
#ports ⇒ Object
50 51 52 |
# File 'lib/shodanz/client.rb', line 50 def ports rest_api.ports end |
#profile ⇒ Object
82 83 84 |
# File 'lib/shodanz/client.rb', line 82 def profile rest_api.profile end |
#protocols ⇒ Object
54 55 56 |
# File 'lib/shodanz/client.rb', line 54 def protocols rest_api.protocols end |
#resolve(*hostnames) ⇒ Object
86 87 88 |
# File 'lib/shodanz/client.rb', line 86 def resolve(*hostnames) rest_api.resolve(hostnames) end |
#reverse_lookup(*ips) ⇒ Object
90 91 92 |
# File 'lib/shodanz/client.rb', line 90 def reverse_lookup(*ips) rest_api.reverse_lookup(ips) end |
#scan(*ips) ⇒ Object
58 59 60 |
# File 'lib/shodanz/client.rb', line 58 def scan(*ips) rest_api.scan(ips) end |
#scan_status(id) ⇒ Object
66 67 68 |
# File 'lib/shodanz/client.rb', line 66 def scan_status(id) rest_api.scan_status(id) end |
#search_for_community_query(query, **params) ⇒ Object
74 75 76 |
# File 'lib/shodanz/client.rb', line 74 def search_for_community_query(query, **params) rest_api.search_for_community_query(query, params) end |