Skip to content

Instantly share code, notes, and snippets.

@picatz
Last active October 21, 2017 17:22
Show Gist options
  • Save picatz/6a88f9bea63b7257f0d2fe0c8fce0f1b to your computer and use it in GitHub Desktop.
Save picatz/6a88f9bea63b7257f0d2fe0c8fce0f1b to your computer and use it in GitHub Desktop.
Top 10 Countries Running Apache
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