Class: Metasploit::Framework::LoginScanner::Result

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Result

Returns a new instance of Result.

Parameters:

  • attributes (Hash{Symbol => String,nil}) (defaults to: {})


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_levelString

Returns the access level gained.

Returns:

  • (String)

    the access level gained



13
14
15
# File 'lib/metasploit/framework/login_scanner/result.rb', line 13

def access_level
  @access_level
end

#connectionObject

Returns the post-authenticated connection object (if the scanner chooses to leave it open).

Returns:

  • (Object)

    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

#credentialCredential

Returns the Credential object the result is for.

Returns:

  • (Credential)

    the Credential object the result is for



16
17
18
# File 'lib/metasploit/framework/login_scanner/result.rb', line 16

def credential
  @credential
end

#hostString

Returns the address of the target host for this result.

Returns:

  • (String)

    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

#portInteger

Returns the port number of the service for this result.

Returns:

  • (Integer)

    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.

Returns:

  • (#to_s)

    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

#protocolString

Returns the transport protocol used for this result (tcp/udp).

Returns:

  • (String)

    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_nameString

Returns the name to give the service for this result.

Returns:

  • (String)

    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

#statusString

Returns the status of the attempt. Should be a member of ‘Metasploit::Model::Login::Status::ALL`.

Returns:

  • (String)

    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

#inspectObject



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

Returns:

  • (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_hHash

This method takes all the data inside the Result object and spits out a hash compatible with #create_credential and #create_credential_login.

Returns:

  • (Hash)

    the hash to use 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