From 1bc001832b9f3bb46ca851266131056643748f49 Mon Sep 17 00:00:00 2001 From: booboy Date: Thu, 14 Mar 2019 00:55:44 -0500 Subject: [PATCH] added a file for getting calibre ips from shodan --- get_calibre_ips.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 get_calibre_ips.rb diff --git a/get_calibre_ips.rb b/get_calibre_ips.rb new file mode 100755 index 0000000..e96b5c5 --- /dev/null +++ b/get_calibre_ips.rb @@ -0,0 +1,22 @@ +#!/usr/bin/env ruby +# get all of the calibre servers +require 'shodan' +require 'pry' + +client = Shodan::Shodan.new(ENV['shodan_api_key']) +search_results = client.search('server: calibre') + +matches = search_results['matches'] +total = search_results['total'] +pages = (0..(total / 100)) + +puts "total number of matches: #{total}" +puts "total number of pages: #{pages}" + +pages.each do |page| + result = client.search("server: calbire", :page => page) + matches = search_results['matches'] + matches.each do |host| + puts host['ip_str'] + host['port'] + end +end