Module: Msf::Payload::Windows::PayloadDBConf

Included in:
EncryptedReverseTcp, Sessions::EncryptedShell
Defined in:
lib/msf/core/payload/windows/payload_db_conf.rb

Instance Method Summary collapse

Instance Method Details

#initialize(*args) ⇒ Object


6
7
8
# File 'lib/msf/core/payload/windows/payload_db_conf.rb', line 6

def initialize(*args)
  super
end

#retrieve_chacha_creds(uuid = nil) ⇒ Object

Parameters:

  • uuid (String) (defaults to: nil)

    retrieves the key and nonce for payloads using the chacha cipher from the database


55
56
57
58
59
60
61
62
# File 'lib/msf/core/payload/windows/payload_db_conf.rb', line 55

def retrieve_chacha_creds(uuid=nil)
  return nil unless uuid

  build_opts = retrieve_conf_from_db(uuid)
  return nil unless build_opts['key'] && build_opts['nonce']

  return build_opts['key'], build_opts['nonce']
end

#retrieve_conf_from_db(uuid = nil) ⇒ Object

Retrieve payload configuration from db

Parameters:

  • uuid (String) (defaults to: nil)

    accepts the payload uuid and a hash of the payload information will be returned


41
42
43
44
45
46
47
48
# File 'lib/msf/core/payload/windows/payload_db_conf.rb', line 41

def retrieve_conf_from_db(uuid=nil)
  return nil unless (framework.db && framework.db.active)

  curr_payload = framework.db.get_payload(uuid: uuid)
  return nil unless curr_payload && curr_payload[:build_opts]

  return curr_payload[:build_opts]
end

#save_conf_to_db(conf = {}) ⇒ Object

Saves a payload configuration to the db

Parameters:

  • conf (Hash) (defaults to: {})

    accepts a uuid, which will be used as the payload identifier. Additional hash values will be saved within `build_opts`


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/msf/core/payload/windows/payload_db_conf.rb', line 17

def save_conf_to_db(conf={})
  return nil unless (framework.db && framework.db.active)

  return nil unless conf['uuid']
  payload_uuid = conf['uuid']
  conf.delete('uuid')

  saved_payload = framework.db.get_payload(uuid: payload_uuid)
  if saved_payload
    framework.db.update_payload(id: saved_payload.id, build_opts: conf)
  else
    print_status('Payload does not exist in database. Attempting to save it now.')
    framework.db.create_payload(uuid: payload_uuid, build_opts: conf)
  end
rescue
  print_error('Failed to save payload info to database')
end