Module: Msf::Module::Auth

Included in:
Msf::Module, External
Defined in:
lib/msf/core/module/auth.rb

Instance Method Summary collapse

Instance Method Details

#store_valid_credential(user:, private:, private_type: :password, proof: nil, service_data: {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/msf/core/module/auth.rb', line 2

def store_valid_credential(user:, private:, private_type: :password, proof: nil, service_data: {})
  if service_data.empty? && self.respond_to?("service_details")
    service_data = service_details
  end

  creation_data = {
      module_fullname: self.fullname,
      username: user,
      private_data: private,
      private_type: private_type,
      workspace_id: myworkspace_id
  }.merge(service_data)

  if service_data.empty?
    cred_data = {
      origin_type: :import,
      filename: 'msfconsole' # default as values provided on the console
    }.merge(creation_data)
    framework.db.create_credential(cred_data)
  else
     = {
      proof: proof,
      last_attempted_at: DateTime.now,
      status: Metasploit::Model::Login::Status::SUCCESSFUL
    }.merge(creation_data)
    framework.db.()
  end

  nil
end