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: {})


51
52
53
54
55
# File 'lib/metasploit/framework/login_scanner/result.rb', line 51

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)



40
41
42
# File 'lib/metasploit/framework/login_scanner/result.rb', line 40

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

#parentsObject

Returns the service parents of this result’s service. These get reported when creating credentials.

Returns:

  • (Object)

    the service parents of this result’s service. These get reported when creating credentials.



25
26
27
# File 'lib/metasploit/framework/login_scanner/result.rb', line 25

def parents
  @parents
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



28
29
30
# File 'lib/metasploit/framework/login_scanner/result.rb', line 28

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)



31
32
33
# File 'lib/metasploit/framework/login_scanner/result.rb', line 31

def protocol
  @protocol
end

#resourceObject

Returns the service’s resource, if any, e.g. website URI.

Returns:

  • (Object)

    the service’s resource, if any, e.g. website URI



43
44
45
# File 'lib/metasploit/framework/login_scanner/result.rb', line 43

def resource
  @resource
end

#service_nameString

Returns the name to give the service for this result.

Returns:

  • (String)

    the name to give the service for this result



34
35
36
# File 'lib/metasploit/framework/login_scanner/result.rb', line 34

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`



37
38
39
# File 'lib/metasploit/framework/login_scanner/result.rb', line 37

def status
  @status
end

Instance Method Details

#inspectObject



57
58
59
# File 'lib/metasploit/framework/login_scanner/result.rb', line 57

def inspect
  "#<#{self.class} #{credential.public}:#{credential.private}@#{credential.realm} #{status} >"
end

#success?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/metasploit/framework/login_scanner/result.rb', line 61

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



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/metasploit/framework/login_scanner/result.rb', line 70

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,
      parents: parents,
      resource: resource
  )
  result_hash.delete_if { |k,v| v.nil? }
end