Files
metasploit-gs/modules/auxiliary/scanner/ssh/ssh_version.rb
T

71 lines
1.5 KiB
Ruby
Raw Normal View History

2009-05-11 02:46:59 +00:00
##
# $Id$
##
##
# This file is part of the Metasploit Framework and may be subject to
2009-05-11 02:46:59 +00:00
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'msf/core'
class Metasploit3 < Msf::Auxiliary
include Msf::Exploit::Remote::Tcp
include Msf::Auxiliary::Scanner
include Msf::Auxiliary::Report
2009-05-11 02:46:59 +00:00
def initialize
super(
2010-11-22 22:43:34 +00:00
'Name' => 'SSH Version Scanner',
2009-05-11 02:46:59 +00:00
'Version' => '$Revision$',
'Description' => 'Detect SSH Version.',
'References' =>
[
[ 'URL', 'http://en.wikipedia.org/wiki/SecureShell' ],
],
2010-02-17 14:42:11 +00:00
'Author' => [ 'Daniel van Eeden <metasploit[at]myname.nl>' ],
2009-05-11 02:46:59 +00:00
'License' => MSF_LICENSE
)
register_options(
[
Opt::RPORT(22),
OptInt.new('TIMEOUT', [true, 'Timeout for the SSH probe', 30])
2009-05-11 02:46:59 +00:00
], self.class)
end
def to
return 30 if datastore['TIMEOUT'].to_i.zero?
datastore['TIMEOUT'].to_i
end
2009-05-11 02:46:59 +00:00
def run_host(target_host)
begin
2010-09-18 04:15:32 +00:00
::Timeout.timeout(to) do
2009-05-11 02:46:59 +00:00
connect
2009-05-11 02:46:59 +00:00
ver = sock.get_once(-1, 5)
2009-05-11 02:46:59 +00:00
if (ver and ver =~ /SSH/)
ver,msg = (ver.split(/(\n|\r)/))
print_status("#{target_host}:#{rport}, SSH server version: #{ver}")
report_service(:host => rhost, :port => rport, :name => "ssh", :info => ver)
else
print_error("#{target_host}:#{rport}, SSH server version detection failed!")
end
disconnect
end
rescue Timeout::Error
print_error("#{target_host}:#{rport}, Server timed out after #{to} seconds. Skipping.")
end
2009-05-11 02:46:59 +00:00
end
end