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.
|
2009-04-13 14:33:26 +00:00
|
|
|
# http://metasploit.com/framework/
|
2008-10-15 14:00:56 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
2009-07-17 20:36:40 +00:00
|
|
|
require 'racket'
|
2008-10-15 14:00:56 +00:00
|
|
|
|
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)
|
2009-07-09 07:08:25 +00:00
|
|
|
disconnect(s)
|
2010-03-02 23:08:05 +00:00
|
|
|
rescue ::Rex::ConnectionError
|
|
|
|
rescue ::TimeoutError
|
2008-10-15 14:00:56 +00:00
|
|
|
rescue ::Interrupt
|
|
|
|
raise $!
|
|
|
|
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
|