Path: blob/master/lib/metasploit/framework/login_scanner/advantech_webaccess.rb
32410 views
require 'metasploit/framework/login_scanner/http'12module Metasploit3module Framework4module LoginScanner56class AdvantechWebAccess < HTTP78DEFAULT_PORT = 809PRIVATE_TYPES = [ :password ]10LOGIN_STATUS = Metasploit::Model::Login::Status # Shorter name1112# Checks if the target is Advantech WebAccess13#14# @return [false] Indicates there were no errors15# @return [String] a human-readable error message describing why16# this scanner can't run17def check_setup18uri = normalize_uri("#{uri}broadWeb/bwRoot.asp")1920res = send_request({21'method' => 'GET',22'uri' => uri23})2425if res && res.body =~ /Welcome to Advantech WebAccess/i26return false27end2829'Unable to locate "Welcome to Advantech WebAccess" in body. (Is this really Advantech WebAccess?)'30end3132def do_login(user, pass)33uri = normalize_uri("#{uri}broadweb/user/signin.asp")3435res = send_request({36'method' => 'POST',37'uri' => uri,38'vars_post' =>39{40'page' => '/',41'pos' => '',42'remMe' => '',43'submit1' => 'Login',44'username' => user,45'password' => pass46}47})4849unless res50return {status: LOGIN_STATUS::UNABLE_TO_CONNECT, proof: 'Connection timed out for signin.asp'}51end5253if res.headers['Location'] && res.headers['Location'] == '/broadweb/bwproj.asp'54return {status: LOGIN_STATUS::SUCCESSFUL, proof: res.body}55end5657{status: LOGIN_STATUS::INCORRECT, proof: res.body}58end5960# Attempts to login to Advantech WebAccess.61#62# @param credential [Metasploit::Framework::Credential] The credential object63# @return [Result] A Result object indicating success or failure64def attempt_login(credential)65result_opts = {66credential: credential,67status: Metasploit::Model::Login::Status::INCORRECT,68proof: nil,69host: host,70port: port,71protocol: 'tcp'72}7374begin75result_opts.merge!(do_login(credential.public, credential.private))76rescue ::Rex::ConnectionError => e77# Something went wrong during login. 'e' knows what's up.78result_opts.merge!(status: LOGIN_STATUS::UNABLE_TO_CONNECT, proof: e.message)79end8081Result.new(result_opts)82end8384end85end86end87end888990