2009-10-25 05:05:54 +00:00
|
|
|
##
|
2017-07-24 13:26:21 +00:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2009-10-25 05:05:54 +00:00
|
|
|
##
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2015-02-13 23:17:59 +00:00
|
|
|
include Msf::Exploit::Remote::SMB::Client
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Auxiliary::Fuzzer
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'SMB Tree Connect Request Fuzzer',
|
|
|
|
'Description' => %q{
|
|
|
|
This module sends a series of SMB tree connect
|
|
|
|
requests using malicious strings.
|
|
|
|
},
|
|
|
|
'Author' => [ 'hdm' ],
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
))
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def do_smb_connect(pkt,opts={})
|
|
|
|
@connected = false
|
|
|
|
connect
|
|
|
|
simple.login(
|
|
|
|
datastore['SMBName'],
|
|
|
|
datastore['SMBUser'],
|
|
|
|
datastore['SMBPass'],
|
|
|
|
datastore['SMBDomain']
|
|
|
|
)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
@connected = true
|
|
|
|
simple.connect("\\\\#{datastore['RHOST']}\\#{pkt}")
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def run
|
|
|
|
last_str = nil
|
|
|
|
last_inp = nil
|
|
|
|
last_err = nil
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
cnt = 0
|
2009-10-25 05:05:54 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
fuzz_strings do |str|
|
|
|
|
cnt += 1
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
if(cnt % 100 == 0)
|
|
|
|
print_status("Fuzzing with iteration #{cnt} using #{@last_fuzzer_input}")
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
begin
|
|
|
|
do_smb_connect(str, 0.25)
|
|
|
|
rescue ::Interrupt
|
|
|
|
print_status("Exiting on interrupt: iteration #{cnt} using #{@last_fuzzer_input}")
|
|
|
|
raise $!
|
|
|
|
rescue ::Exception => e
|
|
|
|
last_err = e
|
|
|
|
ensure
|
|
|
|
disconnect
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2013-08-30 21:28:54 +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
|
|
|
|
print_status("Could not connect to the service: #{last_err}")
|
|
|
|
end
|
|
|
|
return
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
last_str = str
|
|
|
|
last_inp = @last_fuzzer_input
|
|
|
|
end
|
|
|
|
end
|
2009-10-25 05:05:54 +00:00
|
|
|
end
|