Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/achillean/shodan-ruby
Ruby library for SHODAN
https://github.com/achillean/shodan-ruby
Last synced: about 7 hours ago
JSON representation
Ruby library for SHODAN
- Host: GitHub
- URL: https://github.com/achillean/shodan-ruby
- Owner: achillean
- License: other
- Archived: true
- Created: 2010-09-10T08:51:01.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2019-11-24T01:58:07.000Z (almost 5 years ago)
- Last Synced: 2024-10-01T23:17:38.477Z (about 2 months ago)
- Language: Ruby
- Homepage: http://www.shodanhq.com
- Size: 23.4 KB
- Stars: 74
- Watchers: 11
- Forks: 19
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ip-search-engines - Shodan Ruby
README
Visit the official Shodan API documentation at:
[https://developer.shodan.io](https://developer.shodan.io)
## Installation
To install the library use rubygems:
gem install shodan
## Usage
Before you can use the API, you need to have an API key.
[Get your API key here](http://www.shodanhq.com/api_doc)
Setup the Shodan wrapper object:
require 'shodan'
api = Shodan::Shodan.new(MY_API_KEY)Print a list of cisco-ios devices:
result = api.search("cisco-ios")
result['matches'].each{ |host|
puts host['ip_str']
}Print the 2nd page of results for the cisco-ios query:
result = api.search("cisco-ios", :page => 2)
result['matches'].each{ |host|
puts host['ip_str']
}Find out how many results there are for "apache" and also return the top 5 organizations for the results:
result = api.count("apache", :facets => 'org:5')
puts "Total number of results: #{result['total']}"
puts result['facets']Get all the information SHODAN has on the IP 217.140.75.46:
host = api.host('217.140.75.46')
puts host.to_sTo properly handle potential errors, you should wrap all requests in a try/except block:
begin
api.search("cisco-ios")
rescue Exception => e
puts "Error: #{e.to_s}"
else
puts "Unknown error"
end