Path: blob/master/lib/metasploit/framework/login_scanner/nessus.rb
32538 views
1require 'metasploit/framework/login_scanner/http'23module Metasploit4module Framework5module LoginScanner67class Nessus < HTTP89DEFAULT_PORT = 883410PRIVATE_TYPES = [ :password ]11LIKELY_SERVICE_NAMES = self.superclass::LIKELY_SERVICE_NAMES + [ 'nessus' ]12LOGIN_STATUS = Metasploit::Model::Login::Status # Shorter name131415# Checks if the target is correct16#17# @return [false] Indicates there were no errors18# @return [String] a human-readable error message describing why19# this scanner can't run20def check_setup21login_uri = "/server/properties"22res = send_request({'uri'=> login_uri})23if res && res.body.include?('Nessus')24return false25end2627'Unable to locate "Nessus" in body. (Is this really Nessus?)'28end2930# Actually doing the login. Called by #attempt_login31#32# @param username [String] The username to try33# @param password [String] The password to try34# @return [Hash]35# * :status [Metasploit::Model::Login::Status]36# * :proof [String] the HTTP response body37def get_login_state(username, password)38login_uri = "#{uri}"3940res = send_request({41'uri' => login_uri,42'method' => 'POST',43'vars_post' => {44'username' => username,45'password' => password46}47})4849unless res50return {:status => LOGIN_STATUS::UNABLE_TO_CONNECT, :proof => res.to_s}51end52if res.code == 200 && res.body =~ /token/53return {:status => LOGIN_STATUS::SUCCESSFUL, :proof => res.body.to_s}54end5556{:status => LOGIN_STATUS::INCORRECT, :proof => res.to_s}57end585960# Attempts to login to Nessus.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!(get_login_state(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)82end8384def set_sane_defaults85super86# nessus_rest_login has the same default in TARGETURI, but rspec doesn't check nessus_rest_login87# so we have to set the default here, too.88self.uri = '/session'89end9091end92end93end94end95969798