Last active
October 21, 2017 17:22
-
-
Save picatz/6a88f9bea63b7257f0d2fe0c8fce0f1b to your computer and use it in GitHub Desktop.
Top 10 Countries Running Apache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "shodanz" | |
require "chart_js" | |
module Top10 | |
# Create RESP API client. | |
@rest_api = Shodanz.api.rest.new | |
# Check a given product. | |
def self.check(product) | |
begin | |
@rest_api.host_count(product: product, facets: { country: 10 })["facets"]["country"].collect { |x| x.values }.to_h.invert | |
rescue | |
puts "Unable to succesffully check the Shodan API." | |
exit 1 | |
end | |
end | |
end | |
results = Top10.check("apache") | |
ChartJS.bar do | |
file "top_10_apache.html" | |
data do | |
labels results.keys | |
dataset "Countries" do | |
color :random | |
data results.values | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment