2006-08-12 08:31:38 +00:00
|
|
|
module Msf
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
2006-08-12 23:08:20 +00:00
|
|
|
# This module provides methods for scanning modules
|
2006-08-12 08:31:38 +00:00
|
|
|
#
|
|
|
|
###
|
|
|
|
|
|
|
|
module Auxiliary::Scanner
|
|
|
|
|
2006-08-12 23:08:20 +00:00
|
|
|
|
2006-08-12 08:31:38 +00:00
|
|
|
#
|
|
|
|
# Initializes an instance of a recon auxiliary module
|
|
|
|
#
|
|
|
|
def initialize(info = {})
|
|
|
|
super
|
|
|
|
|
2006-08-12 23:08:20 +00:00
|
|
|
register_options(
|
2006-08-12 08:31:38 +00:00
|
|
|
[
|
2006-08-12 23:08:20 +00:00
|
|
|
OptAddressRange.new('RHOSTS', [ true, "The target address range or CIDR identifier"]),
|
2006-08-12 08:31:38 +00:00
|
|
|
], Auxiliary::Scanner)
|
2006-08-12 23:08:20 +00:00
|
|
|
|
|
|
|
# RHOST should not be used in scanner modules, only RHOSTS
|
|
|
|
deregister_options('RHOST')
|
2006-08-12 08:31:38 +00:00
|
|
|
end
|
|
|
|
|
2006-08-12 23:08:20 +00:00
|
|
|
|
2006-08-12 08:31:38 +00:00
|
|
|
#
|
|
|
|
# The command handler when launched from the console
|
|
|
|
#
|
|
|
|
def run
|
|
|
|
if (self.respond_to?('run_range'))
|
|
|
|
return run_range(datastore['RHOSTS'])
|
|
|
|
end
|
|
|
|
|
|
|
|
# Add support for multiple threads
|
|
|
|
if (self.respond_to?('run_host'))
|
|
|
|
ar = Rex::Socket::RangeWalker.new(datastore['RHOSTS'])
|
|
|
|
while(ip = ar.next_ip)
|
2006-08-12 23:08:20 +00:00
|
|
|
self.target_host = ip
|
2006-08-12 08:31:38 +00:00
|
|
|
run_host(ip)
|
|
|
|
end
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
# Add support for multiple threads
|
|
|
|
if (self.respond_to?('run_batch'))
|
|
|
|
|
|
|
|
if (! self.respond_to?('run_batch_size'))
|
|
|
|
print_status("This module needs to export run_batch_size()")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
size = run_batch_size()
|
|
|
|
|
|
|
|
ar = Rex::Socket::RangeWalker.new(datastore['RHOSTS'])
|
|
|
|
while(true)
|
|
|
|
batch = []
|
|
|
|
|
|
|
|
while (batch.length < size)
|
|
|
|
ip = ar.next_ip
|
|
|
|
break if not ip
|
|
|
|
batch << ip
|
|
|
|
end
|
|
|
|
return if batch.length == 0
|
|
|
|
run_batch(batch)
|
|
|
|
end
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
print_status("This module defined no run_host or run_range methods")
|
|
|
|
end
|
|
|
|
|
2006-08-12 23:08:20 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# The current target host (replaces RHOST)
|
|
|
|
#
|
|
|
|
attr_accessor :target_host
|
|
|
|
|
|
|
|
#
|
|
|
|
# Overloads the Exploit mixins for rhost
|
|
|
|
#
|
|
|
|
def rhost
|
|
|
|
self.target_host
|
|
|
|
end
|
|
|
|
|
2006-08-12 08:31:38 +00:00
|
|
|
end
|
|
|
|
end
|