#!/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