Class: Webb::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions, Thor::Shell
Defined in:
lib/webb/cli.rb

Instance Method Summary collapse

Instance Method Details

#scan(address) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/webb/cli.rb', line 12

def scan(address)
  request = Typhoeus::Request.new(address, followlocation: true)

  request.on_complete do |response|
    %x{open http://#{address}} if response.success?
  end
  request.run
end

#sweep(from, to) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/webb/cli.rb', line 22

def sweep( from, to)
  range = (IPAddr.new(from)..IPAddr.new(to))

  queue = Typhoeus::Hydra.new
  range.each do |ip|
    request = Typhoeus::Request.new(ip.to_s, followlocation: true)
    request.on_complete do |response|
      %x{open http://#{ip}} if response.success?
    end
    queue.queue(request)
  end
  queue.run
end