2011-03-20 17:28:35 +00:00
|
|
|
##
|
2017-07-24 13:26:21 +00:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2011-03-20 17:28:35 +00:00
|
|
|
##
|
|
|
|
|
2012-10-23 18:24:05 +00:00
|
|
|
require 'msf/core/auxiliary/report'
|
2011-03-20 17:28:35 +00:00
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Post
|
2013-09-05 18:41:25 +00:00
|
|
|
include Msf::Auxiliary::Report
|
2011-03-20 17:28:35 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
OUI_LIST = Rex::Oui
|
2011-03-20 17:28:35 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize(info={})
|
|
|
|
super( update_info( info,
|
|
|
|
'Name' => 'Windows Gather ARP Scanner',
|
|
|
|
'Description' => %q{ This Module will perform an ARP scan for a given IP range through a
|
|
|
|
Meterpreter Session.},
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>'],
|
|
|
|
'Platform' => [ 'win' ],
|
|
|
|
'SessionTypes' => [ 'meterpreter']
|
|
|
|
))
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
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
|
|
|
|
2017-05-03 20:42:21 +00:00
|
|
|
])
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2011-03-20 17:28:35 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
# Run Method for when run command is issued
|
|
|
|
def run
|
|
|
|
print_status("Running module against #{sysinfo['Computer']}")
|
|
|
|
arp_scan(datastore['RHOSTS'], datastore['THREADS'])
|
|
|
|
end
|
2011-03-20 17:28:35 +00:00
|
|
|
|
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def arp_scan(cidr,threads)
|
|
|
|
print_status("ARP Scanning #{cidr}")
|
|
|
|
ws = client.railgun.ws2_32
|
|
|
|
iphlp = client.railgun.iphlpapi
|
|
|
|
a = []
|
|
|
|
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
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
while(not iplst.nil? and not iplst.empty?)
|
|
|
|
a = []
|
|
|
|
1.upto(threads) do
|
|
|
|
a << framework.threads.spawn("Module(#{self.refname})", false, iplst.shift) do |ip_text|
|
|
|
|
next if ip_text.nil?
|
|
|
|
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 )
|
2017-07-19 10:46:39 +00:00
|
|
|
print_good("\tIP: #{ip_text} MAC #{mac_text} (#{company})")
|
2013-08-30 21:28:54 +00:00
|
|
|
report_host(:host => ip_text,:mac => mac_text)
|
|
|
|
next if company.nil?
|
|
|
|
report_note(:host => ip_text, :type => "mac_oui", :data => company)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
a.map {|x| x.join }
|
|
|
|
end
|
|
|
|
return found
|
|
|
|
end
|
2011-07-27 02:39:49 +00:00
|
|
|
end
|