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
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2011-03-20 17:28:35 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
require 'rex'
|
|
|
|
require 'msf/core/post/common'
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Post
|
|
|
|
|
|
|
|
include Msf::Post::Common
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
|
2012-07-10 17:28:24 +00:00
|
|
|
OUI_LIST = Rex::Oui
|
2011-03-20 17:28:35 +00:00
|
|
|
|
|
|
|
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
|
2012-07-22 03:38:41 +00:00
|
|
|
a = []
|
2011-03-20 17:28:35 +00:00
|
|
|
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
|
2012-07-22 03:38:41 +00:00
|
|
|
|
|
|
|
while(not iplst.nil? and not iplst.empty?)
|
|
|
|
1.upto(threads) do
|
|
|
|
a << framework.threads.spawn("Module(#{self.refname})", false, iplst.shift) do |ip_text|
|
2012-08-07 20:59:01 +00:00
|
|
|
next if ip_text.nil?
|
2012-07-22 03:38:41 +00:00
|
|
|
h = ws.inet_addr(ip_text)
|
|
|
|
ip = h["return"]
|
|
|
|
h = iphlp.SendARP(ip,0,6,6)
|
|
|
|
if h["return"] == client.railgun.const("NO_ERROR")
|
|
|
|
mac_text = h["pMacAddr"].unpack('C*').map { |e| "%02x" % e }.join(':')
|
|
|
|
company = OUI_LIST::lookup_oui_company_name(mac_text )
|
|
|
|
print_status("\tIP: #{ip_text} MAC #{mac_text} (#{company})")
|
|
|
|
report_host(:host => ip_text,:mac => mac_text)
|
|
|
|
next if company.nil?
|
|
|
|
report_note(:host => ip_text, :type => "mac_oui", :data => company)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
a.map {|x| x.join }
|
2011-03-20 17:28:35 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
return found
|
|
|
|
end
|
|
|
|
|
2011-07-27 02:39:49 +00:00
|
|
|
end
|