Sha256: 8235507105f9979c273cd8b3054e7795911da977c2b9bc5005f5de793fe4d206

Contents?: true

Size: 803 Bytes

Versions: 9

Compression:

Stored size: 803 Bytes

Contents

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'pry'
require 'async'
require 'shodanz'

client = Shodanz.client.new

stats = Hash.new(0)

ports    = [21, 22, 80, 443]
services = ['ftp', 'ssh', 'http', 'https']

ports_with_service_names = ports.zip(services)

Async do 
  # collect banners for ports
  ports_with_service_names.each do |port, service|
    client.streaming_api.banners_on_port(port) do |banner|
      if ip = banner['ip_str']
        Async do
          resp = client.rest_api.honeypot_score(ip).wait
          binding.pry if resp.nil?
          puts "#{ip} has a #{resp *100}% chance of being a honeypot"
        rescue Shodanz::Errors::RateLimited
          sleep 1
          retry
        rescue => error
          binding.pry
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
shodanz-2.0.8 examples/async_stream_example.rb
shodanz-2.0.7 examples/async_stream_example.rb
shodanz-2.0.6 examples/async_stream_example.rb
shodanz-2.0.5 examples/async_stream_example.rb
shodanz-2.0.4 examples/async_stream_example.rb
shodanz-2.0.3 examples/async_stream_example.rb
shodanz-2.0.2 examples/async_stream_example.rb
shodanz-2.0.1 examples/async_stream_example.rb
shodanz-2.0.0 examples/async_stream_example.rb