2012-01-27 18:35:39 +00:00
|
|
|
##
|
|
|
|
# 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/
|
2012-01-27 18:35:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Auxiliary::Report
|
2012-11-04 06:13:38 +00:00
|
|
|
include Msf::Auxiliary::UDPScanner
|
2012-01-27 18:35:39 +00:00
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
2012-08-07 20:59:01 +00:00
|
|
|
'Name' => 'PcAnywhere UDP Service Discovery',
|
2012-01-27 18:35:39 +00:00
|
|
|
'Description' => 'Discover active pcAnywhere services through UDP',
|
|
|
|
'Author' => 'hdm',
|
|
|
|
'License' => MSF_LICENSE,
|
2012-02-01 16:59:58 +00:00
|
|
|
'References' =>
|
2012-01-27 18:35:39 +00:00
|
|
|
[
|
2012-02-01 16:59:58 +00:00
|
|
|
['URL', 'http://www.unixwiz.net/tools/pcascan.txt']
|
2012-01-27 18:35:39 +00:00
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
Opt::RPORT(5632)
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
2012-11-04 06:13:38 +00:00
|
|
|
def scanner_prescan(batch)
|
2012-01-27 18:35:39 +00:00
|
|
|
print_status("Sending pcAnywhere discovery requests to #{batch[0]}->#{batch[-1]} (#{batch.length} hosts)")
|
|
|
|
@results = {}
|
2012-11-04 06:13:38 +00:00
|
|
|
end
|
2012-01-27 18:35:39 +00:00
|
|
|
|
2012-11-04 06:13:38 +00:00
|
|
|
def scan_host(ip)
|
|
|
|
scanner_send("NQ", ip, datastore['RPORT'])
|
|
|
|
scanner_send("ST", ip, datastore['RPORT'])
|
|
|
|
end
|
2012-01-27 18:35:39 +00:00
|
|
|
|
2012-11-04 06:13:38 +00:00
|
|
|
def scanner_postscan(batch)
|
2012-01-27 18:35:39 +00:00
|
|
|
@results.keys.each do |ip|
|
|
|
|
data = @results[ip]
|
|
|
|
info = ""
|
2012-02-01 16:59:58 +00:00
|
|
|
|
2012-01-27 18:35:39 +00:00
|
|
|
if data[:name]
|
|
|
|
info << "Name: #{data[:name]} "
|
|
|
|
end
|
2012-02-01 16:59:58 +00:00
|
|
|
|
2012-01-28 19:05:05 +00:00
|
|
|
if data[:stat]
|
|
|
|
info << "- #{data[:stat]} "
|
2012-01-27 18:35:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if data[:caps]
|
2012-01-28 19:05:05 +00:00
|
|
|
info << "( #{data[:caps]} ) "
|
2012-02-01 16:59:58 +00:00
|
|
|
end
|
2012-01-27 18:35:39 +00:00
|
|
|
|
2012-11-05 21:57:59 +00:00
|
|
|
report_service(:host => ip, :port => datastore['RPORT'], :proto => 'udp', :name => "pcanywhere_stat", :info => info)
|
|
|
|
report_note(:host => ip, :port => datastore['RPORT'], :proto => 'udp', :name => "pcanywhere_stat", :update => :unique, :ntype => "pcanywhere.status", :data => data )
|
|
|
|
print_status("#{ip}:#{datastore['RPORT']} #{info}")
|
2012-01-27 18:35:39 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-11-04 06:13:38 +00:00
|
|
|
def scanner_process(data, shost, sport)
|
2012-01-27 18:35:39 +00:00
|
|
|
case data
|
|
|
|
when /^NR(........................)(........)/
|
2012-02-01 16:59:58 +00:00
|
|
|
|
2012-01-27 18:35:39 +00:00
|
|
|
name = $1.dup
|
|
|
|
caps = $2.dup
|
2012-02-01 16:59:58 +00:00
|
|
|
|
2012-01-29 05:33:26 +00:00
|
|
|
name = name.gsub(/_+$/, '').gsub("\x00", '').strip
|
2012-02-01 16:59:58 +00:00
|
|
|
caps = caps.gsub(/_+$/, '').gsub("\x00", '').strip
|
|
|
|
|
2012-11-04 06:13:38 +00:00
|
|
|
@results[shost] ||= {}
|
|
|
|
@results[shost][:name] = name
|
|
|
|
@results[shost][:caps] = caps
|
2012-02-01 16:59:58 +00:00
|
|
|
|
2012-01-27 18:35:39 +00:00
|
|
|
when /^ST(.+)/
|
2012-11-04 06:13:38 +00:00
|
|
|
@results[shost] ||= {}
|
2012-01-27 18:35:39 +00:00
|
|
|
buff = $1.dup
|
|
|
|
stat = 'Unknown'
|
2012-02-01 16:59:58 +00:00
|
|
|
|
2012-01-27 18:35:39 +00:00
|
|
|
if buff[2,1].unpack("C")[0] == 67
|
|
|
|
stat = "Available"
|
|
|
|
end
|
2012-02-01 16:59:58 +00:00
|
|
|
|
2012-01-27 18:35:39 +00:00
|
|
|
if buff[2,1].unpack("C")[0] == 11
|
|
|
|
stat = "Busy"
|
|
|
|
end
|
2012-02-01 16:59:58 +00:00
|
|
|
|
2012-11-04 06:13:38 +00:00
|
|
|
@results[shost][:stat] = stat
|
2012-01-27 18:35:39 +00:00
|
|
|
else
|
2012-11-04 06:13:38 +00:00
|
|
|
print_error("#{shost} Unknown: #{data.inspect}")
|
2012-01-27 18:35:39 +00:00
|
|
|
end
|
2012-02-01 16:59:58 +00:00
|
|
|
|
2012-01-27 18:35:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|