Class: Metasploit::Framework::LoginScanner::Result
- Inherits:
-
Object
- Object
- Metasploit::Framework::LoginScanner::Result
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/metasploit/framework/login_scanner/result.rb
Overview
The Result class provides a standard structure in which LoginScanners can return the result of a login attempt
Instance Attribute Summary collapse
-
#access_level ⇒ String
The access level gained.
-
#connection ⇒ Object
The post-authenticated connection object (if the scanner chooses to leave it open).
-
#credential ⇒ Credential
The Credential object the result is for.
-
#host ⇒ String
The address of the target host for this result.
-
#port ⇒ Integer
The port number of the service for this result.
-
#proof ⇒ #to_s
The proof of the login’s success or failure.
-
#protocol ⇒ String
The transport protocol used for this result (tcp/udp).
-
#service_name ⇒ String
The name to give the service for this result.
-
#status ⇒ String
The status of the attempt.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Result
constructor
A new instance of Result.
- #inspect ⇒ Object
- #success? ⇒ Boolean
-
#to_h ⇒ Hash
This method takes all the data inside the Result object and spits out a hash compatible with #create_credential and #create_credential_login.
Constructor Details
#initialize(attributes = {}) ⇒ Result
Returns a new instance of Result.
45 46 47 48 49 |
# File 'lib/metasploit/framework/login_scanner/result.rb', line 45 def initialize(attributes={}) attributes.each do |attribute, value| public_send("#{attribute}=", value) end end |
Instance Attribute Details
#access_level ⇒ String
Returns the access level gained.
13 14 15 |
# File 'lib/metasploit/framework/login_scanner/result.rb', line 13 def access_level @access_level end |
#connection ⇒ Object
Returns the post-authenticated connection object (if the scanner chooses to leave it open).
37 38 39 |
# File 'lib/metasploit/framework/login_scanner/result.rb', line 37 def connection @connection end |
#credential ⇒ Credential
Returns the Credential object the result is for.
16 17 18 |
# File 'lib/metasploit/framework/login_scanner/result.rb', line 16 def credential @credential end |
#host ⇒ String
Returns the address of the target host for this result.
19 20 21 |
# File 'lib/metasploit/framework/login_scanner/result.rb', line 19 def host @host end |
#port ⇒ Integer
Returns the port number of the service for this result.
22 23 24 |
# File 'lib/metasploit/framework/login_scanner/result.rb', line 22 def port @port end |
#proof ⇒ #to_s
Returns the proof of the login’s success or failure.
25 26 27 |
# File 'lib/metasploit/framework/login_scanner/result.rb', line 25 def proof @proof end |
#protocol ⇒ String
Returns the transport protocol used for this result (tcp/udp).
28 29 30 |
# File 'lib/metasploit/framework/login_scanner/result.rb', line 28 def protocol @protocol end |
#service_name ⇒ String
Returns the name to give the service for this result.
31 32 33 |
# File 'lib/metasploit/framework/login_scanner/result.rb', line 31 def service_name @service_name end |
#status ⇒ String
Returns the status of the attempt. Should be a member of ‘Metasploit::Model::Login::Status::ALL`.
34 35 36 |
# File 'lib/metasploit/framework/login_scanner/result.rb', line 34 def status @status end |
Instance Method Details
#inspect ⇒ Object
51 52 53 |
# File 'lib/metasploit/framework/login_scanner/result.rb', line 51 def inspect "#<#{self.class} #{credential.public}:#{credential.private}@#{credential.realm} #{status} >" end |
#success? ⇒ Boolean
55 56 57 |
# File 'lib/metasploit/framework/login_scanner/result.rb', line 55 def success? status == Metasploit::Model::Login::Status::SUCCESSFUL || status == Metasploit::Model::Login::Status::NO_AUTH_REQUIRED end |
#to_h ⇒ Hash
This method takes all the data inside the Result object and spits out a hash compatible with #create_credential and #create_credential_login.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/metasploit/framework/login_scanner/result.rb', line 64 def to_h result_hash = credential.to_h result_hash.merge!( access_level: access_level, address: host, last_attempted_at: DateTime.now, origin_type: :service, port: port, proof: proof, protocol: protocol, service_name: service_name, status: status ) result_hash.delete_if { |k,v| v.nil? } end |