2011-03-20 17:28:35 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# ## This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/framework/
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
require 'rex'
|
|
|
|
require 'msf/core/post/common'
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Post
|
|
|
|
|
|
|
|
include Msf::Post::Common
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
|
|
|
|
|
|
|
|
def initialize(info={})
|
|
|
|
super( update_info( info,
|
2011-04-27 16:25:15 +00:00
|
|
|
'Name' => 'Windows Gather ARP Scanner',
|
2011-07-27 02:39:49 +00:00
|
|
|
'Description' => %q{ This Module will perform an ARP scan for a given IP range through a
|
2011-03-20 17:28:35 +00:00
|
|
|
Meterpreter Session.},
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>'],
|
|
|
|
'Version' => '$Revision$',
|
|
|
|
'Platform' => [ 'windows' ],
|
|
|
|
'SessionTypes' => [ 'meterpreter']
|
|
|
|
))
|
|
|
|
register_options(
|
|
|
|
[
|
2011-03-20 17:36:28 +00:00
|
|
|
OptString.new('RHOSTS', [true, 'The target address range or CIDR identifier', nil]),
|
|
|
|
OptInt.new('THREADS', [false, 'The number of concurrent threads', 10])
|
2011-03-20 17:28:35 +00:00
|
|
|
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Run Method for when run command is issued
|
|
|
|
def run
|
|
|
|
print_status("Running module against #{sysinfo['Computer']}")
|
|
|
|
arp_scan(datastore['RHOSTS'], datastore['THREADS'])
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def arp_scan(cidr,threads)
|
|
|
|
print_status("ARP Scanning #{cidr}")
|
|
|
|
ws = client.railgun.ws2_32
|
|
|
|
iphlp = client.railgun.iphlpapi
|
|
|
|
i, a = 0, []
|
|
|
|
iplst,found = [],""
|
|
|
|
ipadd = Rex::Socket::RangeWalker.new(cidr)
|
|
|
|
numip = ipadd.num_ips
|
|
|
|
while (iplst.length < numip)
|
|
|
|
ipa = ipadd.next_ip
|
|
|
|
if (not ipa)
|
|
|
|
break
|
|
|
|
end
|
|
|
|
iplst << ipa
|
|
|
|
end
|
|
|
|
iplst.each do |ip_text|
|
|
|
|
if i < threads
|
|
|
|
a.push(::Thread.new {
|
|
|
|
h = ws.inet_addr(ip_text)
|
|
|
|
ip = h["return"]
|
|
|
|
h = iphlp.SendARP(ip,0,6,6)
|
|
|
|
if h["return"] == client.railgun.const("NO_ERROR")
|
2011-10-23 11:56:13 +00:00
|
|
|
mac_text = h["pMacAddr"].unpack('C*').map { |e| "%02x" % e }.join(':')
|
2011-03-20 17:28:35 +00:00
|
|
|
print_status("\tIP: #{ip_text} MAC #{mac_text}")
|
|
|
|
report_host(:host => ip_text,:mac => mac_text)
|
|
|
|
end
|
|
|
|
})
|
|
|
|
i += 1
|
|
|
|
else
|
|
|
|
sleep(0.05) and a.delete_if {|x| not x.alive?} while not a.empty?
|
|
|
|
i = 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
a.delete_if {|x| not x.alive?} while not a.empty?
|
|
|
|
return found
|
|
|
|
end
|
|
|
|
|
2011-07-27 02:39:49 +00:00
|
|
|
end
|