mirror of
https://github.com/rapid7/metasploit-framework
synced 2024-11-12 11:52:01 +01:00
Wrap SSH and Telnet version checkers in a timeout, or else they sometimes hang forever.
git-svn-id: file:///home/svn/framework3/trunk@10365 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
parent
af19a0d924
commit
b023d89469
@ -34,23 +34,37 @@ class Metasploit3 < Msf::Auxiliary
|
||||
register_options(
|
||||
[
|
||||
Opt::RPORT(22),
|
||||
OptInt.new('TIMEOUT', [true, 'Timeout for the SSH probe', 30])
|
||||
], self.class)
|
||||
end
|
||||
|
||||
def to
|
||||
return 30 if datastore['TIMEOUT'].to_i.zero?
|
||||
datastore['TIMEOUT'].to_i
|
||||
end
|
||||
|
||||
def run_host(target_host)
|
||||
connect
|
||||
begin
|
||||
timeout(to) do
|
||||
|
||||
ver = sock.get_once(-1, 5)
|
||||
connect
|
||||
|
||||
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!")
|
||||
ver = sock.get_once(-1, 5)
|
||||
|
||||
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
|
||||
|
||||
disconnect
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -25,16 +25,29 @@ class Metasploit3 < Msf::Auxiliary
|
||||
'Author' => 'hdm',
|
||||
'License' => MSF_LICENSE
|
||||
)
|
||||
register_options(
|
||||
[
|
||||
Opt::RPORT(23),
|
||||
OptInt.new('TIMEOUT', [true, 'Timeout for the Telnet probe', 30])
|
||||
], self.class)
|
||||
end
|
||||
|
||||
def to
|
||||
return 30 if datastore['TIMEOUT'].to_i.zero?
|
||||
datastore['TIMEOUT'].to_i
|
||||
end
|
||||
|
||||
def run_host(ip)
|
||||
begin
|
||||
timeout(to) do
|
||||
res = connect
|
||||
# This makes db_services look a lot nicer.
|
||||
banner_santized = Rex::Text.to_hex_ascii(banner.to_s)
|
||||
print_status("#{ip}:#{rport} TELNET #{banner_santized}")
|
||||
report_service(:host => rhost, :port => rport, :name => "telnet", :info => banner_santized)
|
||||
rescue ::Rex::ConnectionError
|
||||
rescue Timeout::Error
|
||||
print_error("#{target_host}:#{rport}, Server timed out after #{to} seconds. Skipping.")
|
||||
rescue ::Exception => e
|
||||
print_error("#{e} #{e.backtrace}")
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user