2008-10-15 14:00:56 +00:00
|
|
|
##
|
2008-10-23 02:43:21 +00:00
|
|
|
# $Id$
|
2008-10-15 14:00:56 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# 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/projects/Framework/
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
2008-10-15 22:25:35 +00:00
|
|
|
class Metasploit3 < Msf::Auxiliary
|
2008-10-15 14:00:56 +00:00
|
|
|
|
2008-10-15 22:25:35 +00:00
|
|
|
include Msf::Exploit::Remote::Tcp
|
2008-10-15 14:00:56 +00:00
|
|
|
|
2008-10-15 22:25:35 +00:00
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
include Msf::Auxiliary::Scanner
|
2008-10-15 14:00:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'TCP Port Scanner',
|
2008-10-23 02:43:21 +00:00
|
|
|
'Version' => '$Revision$',
|
2008-10-15 14:00:56 +00:00
|
|
|
'Description' => 'Enumerate open TCP services',
|
2009-04-03 15:05:35 +00:00
|
|
|
'Author' => [ 'hdm', 'kris katterjohn' ],
|
2008-10-15 14:00:56 +00:00
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
2008-10-27 23:33:34 +00:00
|
|
|
OptString.new('PORTS', [true, "Ports to scan (e.g. 22-25,80,110-900)", "1-10000"]),
|
|
|
|
OptInt.new('TIMEOUT', [true, "The socket connect timeout in milliseconds", 1000])
|
2008-10-15 14:00:56 +00:00
|
|
|
], self.class)
|
|
|
|
|
|
|
|
deregister_options('RPORT')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def run_host(ip)
|
|
|
|
|
2008-10-27 23:33:34 +00:00
|
|
|
timeout = datastore['TIMEOUT'].to_i
|
|
|
|
|
2008-12-20 20:34:05 +00:00
|
|
|
ports = Rex::Socket.portspec_crack(datastore['PORTS'])
|
2008-10-27 23:33:34 +00:00
|
|
|
|
|
|
|
if ports.empty?
|
|
|
|
print_status("Error: No valid ports specified")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
ports.each do |port|
|
2008-10-15 14:00:56 +00:00
|
|
|
|
|
|
|
begin
|
|
|
|
s = connect(false,
|
|
|
|
{
|
|
|
|
'RPORT' => port,
|
|
|
|
'RHOST' => ip,
|
|
|
|
'ConnectTimeout' => (timeout / 1000.0)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
print_status(" TCP OPEN #{ip}:#{port}")
|
2008-11-19 04:05:35 +00:00
|
|
|
report_service(:host => ip, :port => port)
|
2008-10-15 14:00:56 +00:00
|
|
|
s.close
|
|
|
|
rescue ::Interrupt
|
|
|
|
raise $!
|
2008-11-11 05:12:52 +00:00
|
|
|
rescue ::Rex::ConnectionError
|
2008-10-15 14:00:56 +00:00
|
|
|
rescue ::Exception => e
|
2008-12-19 07:11:08 +00:00
|
|
|
print_status("Unknown error: #{e.class} #{e}")
|
2008-10-15 14:00:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-10-27 23:33:34 +00:00
|
|
|
end
|