2009-10-25 03:25:15 +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/
|
2009-10-25 03:25:15 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::Tcp
|
|
|
|
include Msf::Auxiliary::Fuzzer
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2009-10-25 03:25:15 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'SSH 2.0 Version Fuzzer',
|
|
|
|
'Description' => %q{
|
|
|
|
This module sends a series of SSH requests with malicious version strings.
|
|
|
|
},
|
|
|
|
'Author' => [ 'hdm' ],
|
2013-01-03 00:01:18 +00:00
|
|
|
'License' => MSF_LICENSE
|
2009-10-25 03:25:15 +00:00
|
|
|
))
|
|
|
|
register_options([
|
|
|
|
Opt::RPORT(22)
|
|
|
|
], self.class)
|
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2009-10-25 03:25:15 +00:00
|
|
|
def do_ssh_version(pkt,opts={})
|
|
|
|
@connected = false
|
|
|
|
connect
|
|
|
|
@connected = true
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2009-10-25 03:25:15 +00:00
|
|
|
@banner = sock.get_once(-1,opts[:banner_timeout])
|
|
|
|
return if not @banner
|
|
|
|
sock.put("#{pkt}\r\n")
|
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2009-10-25 03:25:15 +00:00
|
|
|
def run
|
|
|
|
last_str = nil
|
|
|
|
last_inp = nil
|
|
|
|
last_err = nil
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2009-10-25 03:25:15 +00:00
|
|
|
ver = make_ssh_version_base
|
|
|
|
cnt = 0
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2009-10-25 03:25:15 +00:00
|
|
|
fuzz_strings do |str|
|
|
|
|
cnt += 1
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2009-10-25 03:25:15 +00:00
|
|
|
pkt = ver + str
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2009-10-25 03:25:15 +00:00
|
|
|
if(cnt % 100 == 0)
|
|
|
|
print_status("Fuzzing with iteration #{cnt} using #{@last_fuzzer_input}")
|
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2009-10-25 03:25:15 +00:00
|
|
|
begin
|
|
|
|
r = do_ssh_version(str,:banner_timeout => 5)
|
|
|
|
rescue ::Interrupt
|
|
|
|
print_status("Exiting on interrupt: iteration #{cnt} using #{@last_fuzzer_input}")
|
|
|
|
raise $!
|
|
|
|
rescue ::Exception => e
|
|
|
|
last_err = e
|
|
|
|
ensure
|
|
|
|
disconnect
|
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2009-10-25 03:25:15 +00:00
|
|
|
if(not @connected)
|
|
|
|
if(last_str)
|
|
|
|
print_status("The service may have crashed: iteration:#{cnt-1} method=#{last_inp} string=#{last_str.unpack("H*")[0]} error=#{last_err}")
|
|
|
|
else
|
2010-05-03 17:13:09 +00:00
|
|
|
print_status("Could not connect to the service: #{last_err}")
|
2009-10-25 03:25:15 +00:00
|
|
|
end
|
|
|
|
return
|
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2009-10-25 03:25:15 +00:00
|
|
|
if(not @banner)
|
|
|
|
print_status("The service may have crashed (no banner): iteration:#{cnt-1} method=#{last_inp} string=#{last_str.unpack("H*")[0]} ")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
last_str = str
|
|
|
|
last_inp = @last_fuzzer_input
|
|
|
|
end
|
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2009-10-25 03:25:15 +00:00
|
|
|
def make_ssh_version_base
|
|
|
|
"SSH-2.0-"
|
|
|
|
end
|
|
|
|
end
|