Class: Shodanz::API::Exploits
- Inherits:
-
Object
- Object
- Shodanz::API::Exploits
- Includes:
- Utils
- Defined in:
- lib/shodanz/apis/exploits.rb
Overview
The Exploits API provides access to several exploit and vulnerability data sources. At the moment, it searches across the following:
- Exploit DB
- Metasploit
- Common Vulnerabilities and Exposures (CVE)
Constant Summary collapse
- URL =
The path to the REST API endpoint.
'https://exploits.shodan.io/'
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#count(query = '', facets: {}, page: 1, **params) ⇒ Object
This method behaves identical to the “/search” method with the difference that it doesn’t return any results.
-
#initialize(key: ENV['SHODAN_API_KEY']) ⇒ Exploits
constructor
the SHODAN_API_KEY enviroment variable.
-
#key? ⇒ String
Check if there’s an API key.
-
#search(query = '', facets: {}, page: 1, **params) ⇒ Object
Search across a variety of data sources for exploits and use facets to get summary information.
Methods included from Utils
#get, #post, #slurp_stream, #turn_into_facets, #turn_into_query
Constructor Details
#initialize(key: ENV['SHODAN_API_KEY']) ⇒ Exploits
the SHODAN_API_KEY enviroment variable.
26 27 28 29 30 31 32 |
# File 'lib/shodanz/apis/exploits.rb', line 26 def initialize(key: ENV['SHODAN_API_KEY']) @url = URL @client = Async::HTTP::Client.new(Async::HTTP::Endpoint.parse(@url)) self.key = key warn 'No key has been found or provided!' unless key? end |
Instance Attribute Details
#key ⇒ String
19 20 21 |
# File 'lib/shodanz/apis/exploits.rb', line 19 def key @key end |
Instance Method Details
#count(query = '', facets: {}, page: 1, **params) ⇒ Object
This method behaves identical to the “/search” method with the difference that it doesn’t return any results.
Example
api.count(type: "dos")
60 61 62 63 64 65 66 |
# File 'lib/shodanz/apis/exploits.rb', line 60 def count(query = '', facets: {}, page: 1, **params) params[:query] = query params = turn_into_query(**params) facets = turn_into_facets(**facets) params[:page] = page get('api/count', **params.merge(**facets)) end |
#key? ⇒ String
Check if there’s an API key.
36 37 38 39 40 |
# File 'lib/shodanz/apis/exploits.rb', line 36 def key? return true if @key false end |
#search(query = '', facets: {}, page: 1, **params) ⇒ Object
Search across a variety of data sources for exploits and use facets to get summary information.
Example
api.search("SQL", port: 443)
api.search(port: 22)
api.search(type: "dos")
48 49 50 51 52 53 54 |
# File 'lib/shodanz/apis/exploits.rb', line 48 def search(query = '', facets: {}, page: 1, **params) params[:query] = query params = turn_into_query(**params) facets = turn_into_facets(**facets) params[:page] = page get('api/search', **params.merge(**facets)) end |