CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/lib/metasploit/framework/login_scanner/result.rb
Views: 1904
module Metasploit1module Framework2module LoginScanner34# The Result class provides a standard structure in which5# LoginScanners can return the result of a login attempt67class Result8include ActiveModel::Validations910# @!attribute access_level11# @return [String] the access level gained12attr_accessor :access_level13# @!attribute credential14# @return [Credential] the Credential object the result is for15attr_accessor :credential16# @!attribute host17# @return [String] the address of the target host for this result18attr_accessor :host19# @!attribute port20# @return [Integer] the port number of the service for this result21attr_accessor :port22# @!attribute proof23# @return [#to_s] the proof of the login's success or failure24attr_accessor :proof25# @!attribute protocol26# @return [String] the transport protocol used for this result (tcp/udp)27attr_accessor :protocol28# @!attribute service_name29# @return [String] the name to give the service for this result30attr_accessor :service_name31# @!attribute status32# @return [String] the status of the attempt. Should be a member of `Metasploit::Model::Login::Status::ALL`33attr_accessor :status34# @!attribute connection35# @return [Object] the post-authenticated connection object (if the scanner chooses to leave it open)36attr_accessor :connection3738validates :status,39inclusion: {40in: Metasploit::Model::Login::Status::ALL41}4243# @param attributes [Hash{Symbol => String,nil}]44def initialize(attributes={})45attributes.each do |attribute, value|46public_send("#{attribute}=", value)47end48end4950def inspect51"#<#{self.class} #{credential.public}:#{credential.private}@#{credential.realm} #{status} >"52end5354def success?55status == Metasploit::Model::Login::Status::SUCCESSFUL || status == Metasploit::Model::Login::Status::NO_AUTH_REQUIRED56end5758# This method takes all the data inside the Result object59# and spits out a hash compatible with #create_credential60# and #create_credential_login.61#62# @return [Hash] the hash to use with #create_credential and #create_credential_login63def to_h64result_hash = credential.to_h65result_hash.merge!(66access_level: access_level,67address: host,68last_attempted_at: DateTime.now,69origin_type: :service,70port: port,71proof: proof,72protocol: protocol,73service_name: service_name,74status: status75)76result_hash.delete_if { |k,v| v.nil? }77end7879end8081end82end83end848586